diff options
author | Thinkofdeath <thinkofdeath@spigotmc.org> | 2014-11-26 08:32:16 +1100 |
---|---|---|
committer | md_5 <git@md-5.net> | 2014-11-28 17:16:30 +1100 |
commit | 24557bc2b37deb6a0edf497d547471832457b1dd (patch) | |
tree | c560572889a3b0b34964a0cddb35dc87fda3c914 /src/main/java/net/minecraft/server | |
parent | a4805dbd77da057cc1ea0bf344379bc6e53ca1f6 (diff) | |
download | craftbukkit-24557bc2b37deb6a0edf497d547471832457b1dd.tar craftbukkit-24557bc2b37deb6a0edf497d547471832457b1dd.tar.gz craftbukkit-24557bc2b37deb6a0edf497d547471832457b1dd.tar.lz craftbukkit-24557bc2b37deb6a0edf497d547471832457b1dd.tar.xz craftbukkit-24557bc2b37deb6a0edf497d547471832457b1dd.zip |
Update to Minecraft 1.8
For more information please see http://www.spigotmc.org/
Diffstat (limited to 'src/main/java/net/minecraft/server')
281 files changed, 0 insertions, 63889 deletions
diff --git a/src/main/java/net/minecraft/server/BiomeTheEndDecorator.java b/src/main/java/net/minecraft/server/BiomeTheEndDecorator.java deleted file mode 100644 index 2f4e7495..00000000 --- a/src/main/java/net/minecraft/server/BiomeTheEndDecorator.java +++ /dev/null @@ -1,28 +0,0 @@ -package net.minecraft.server; - -public class BiomeTheEndDecorator extends BiomeDecorator { - - protected WorldGenerator J; - - public BiomeTheEndDecorator() { - this.J = new WorldGenEnder(Blocks.WHITESTONE); - } - - protected void a(BiomeBase biomebase) { - this.a(); - if (this.b.nextInt(5) == 0) { - int i = this.c + this.b.nextInt(16) + 8; - int j = this.d + this.b.nextInt(16) + 8; - int k = this.a.i(i, j); - - this.J.generate(this.a, this.b, i, k, j); - } - - if (this.c == 0 && this.d == 0) { - EntityEnderDragon entityenderdragon = new EntityEnderDragon(this.a); - - entityenderdragon.setPositionRotation(0.0D, 128.0D, 0.0D, this.b.nextFloat() * 360.0F, 0.0F); - this.a.addEntity(entityenderdragon, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN); // CraftBukkit - add SpawnReason - } - } -} diff --git a/src/main/java/net/minecraft/server/Block.java b/src/main/java/net/minecraft/server/Block.java deleted file mode 100644 index 9876ebfa..00000000 --- a/src/main/java/net/minecraft/server/Block.java +++ /dev/null @@ -1,807 +0,0 @@ -package net.minecraft.server; - -import java.util.Iterator; -import java.util.List; -import java.util.Random; - -public class Block { - - public static final RegistryMaterials REGISTRY = new RegistryBlocks("air"); - private CreativeModeTab creativeTab; - protected String d; - public static final StepSound e = new StepSound("stone", 1.0F, 1.0F); - public static final StepSound f = new StepSound("wood", 1.0F, 1.0F); - public static final StepSound g = new StepSound("gravel", 1.0F, 1.0F); - public static final StepSound h = new StepSound("grass", 1.0F, 1.0F); - public static final StepSound i = new StepSound("stone", 1.0F, 1.0F); - public static final StepSound j = new StepSound("stone", 1.0F, 1.5F); - public static final StepSound k = new StepSoundStone("stone", 1.0F, 1.0F); - public static final StepSound l = new StepSound("cloth", 1.0F, 1.0F); - public static final StepSound m = new StepSound("sand", 1.0F, 1.0F); - public static final StepSound n = new StepSound("snow", 1.0F, 1.0F); - public static final StepSound o = new StepSoundLadder("ladder", 1.0F, 1.0F); - public static final StepSound p = new StepSoundAnvil("anvil", 0.3F, 1.0F); - protected boolean q; - protected int r; - protected boolean s; - protected int t; - protected boolean u; - protected float strength; - protected float durability; - protected boolean x = true; - protected boolean y = true; - protected boolean z; - protected boolean isTileEntity; - protected double minX; - protected double minY; - protected double minZ; - protected double maxX; - protected double maxY; - protected double maxZ; - public StepSound stepSound; - public float I; - protected final Material material; - public float frictionFactor; - private String name; - - public static int getId(Block block) { - return REGISTRY.b(block); - } - - public static Block getById(int i) { - return (Block) REGISTRY.a(i); - } - - public static Block a(Item item) { - return getById(Item.getId(item)); - } - - public static Block b(String s) { - if (REGISTRY.b(s)) { - return (Block) REGISTRY.get(s); - } else { - try { - return (Block) REGISTRY.a(Integer.parseInt(s)); - } catch (NumberFormatException numberformatexception) { - return null; - } - } - } - - public boolean j() { - return this.q; - } - - public int k() { - return this.r; - } - - public int m() { - return this.t; - } - - public boolean n() { - return this.u; - } - - public Material getMaterial() { - return this.material; - } - - public MaterialMapColor f(int i) { - return this.getMaterial().r(); - } - - public static void p() { - REGISTRY.a(0, "air", (new BlockAir()).c("air")); - REGISTRY.a(1, "stone", (new BlockStone()).c(1.5F).b(10.0F).a(i).c("stone").d("stone")); - REGISTRY.a(2, "grass", (new BlockGrass()).c(0.6F).a(h).c("grass").d("grass")); - REGISTRY.a(3, "dirt", (new BlockDirt()).c(0.5F).a(g).c("dirt").d("dirt")); - Block block = (new Block(Material.STONE)).c(2.0F).b(10.0F).a(i).c("stonebrick").a(CreativeModeTab.b).d("cobblestone"); - - REGISTRY.a(4, "cobblestone", block); - Block block1 = (new BlockWood()).c(2.0F).b(5.0F).a(f).c("wood").d("planks"); - - REGISTRY.a(5, "planks", block1); - REGISTRY.a(6, "sapling", (new BlockSapling()).c(0.0F).a(h).c("sapling").d("sapling")); - REGISTRY.a(7, "bedrock", (new Block(Material.STONE)).s().b(6000000.0F).a(i).c("bedrock").H().a(CreativeModeTab.b).d("bedrock")); - REGISTRY.a(8, "flowing_water", (new BlockFlowing(Material.WATER)).c(100.0F).g(3).c("water").H().d("water_flow")); - REGISTRY.a(9, "water", (new BlockStationary(Material.WATER)).c(100.0F).g(3).c("water").H().d("water_still")); - REGISTRY.a(10, "flowing_lava", (new BlockFlowing(Material.LAVA)).c(100.0F).a(1.0F).c("lava").H().d("lava_flow")); - REGISTRY.a(11, "lava", (new BlockStationary(Material.LAVA)).c(100.0F).a(1.0F).c("lava").H().d("lava_still")); - REGISTRY.a(12, "sand", (new BlockSand()).c(0.5F).a(m).c("sand").d("sand")); - REGISTRY.a(13, "gravel", (new BlockGravel()).c(0.6F).a(g).c("gravel").d("gravel")); - REGISTRY.a(14, "gold_ore", (new BlockOre()).c(3.0F).b(5.0F).a(i).c("oreGold").d("gold_ore")); - REGISTRY.a(15, "iron_ore", (new BlockOre()).c(3.0F).b(5.0F).a(i).c("oreIron").d("iron_ore")); - REGISTRY.a(16, "coal_ore", (new BlockOre()).c(3.0F).b(5.0F).a(i).c("oreCoal").d("coal_ore")); - REGISTRY.a(17, "log", (new BlockLog1()).c("log").d("log")); - REGISTRY.a(18, "leaves", (new BlockLeaves1()).c("leaves").d("leaves")); - REGISTRY.a(19, "sponge", (new BlockSponge()).c(0.6F).a(h).c("sponge").d("sponge")); - REGISTRY.a(20, "glass", (new BlockGlass(Material.SHATTERABLE, false)).c(0.3F).a(k).c("glass").d("glass")); - REGISTRY.a(21, "lapis_ore", (new BlockOre()).c(3.0F).b(5.0F).a(i).c("oreLapis").d("lapis_ore")); - REGISTRY.a(22, "lapis_block", (new BlockOreBlock(MaterialMapColor.H)).c(3.0F).b(5.0F).a(i).c("blockLapis").a(CreativeModeTab.b).d("lapis_block")); - REGISTRY.a(23, "dispenser", (new BlockDispenser()).c(3.5F).a(i).c("dispenser").d("dispenser")); - Block block2 = (new BlockSandStone()).a(i).c(0.8F).c("sandStone").d("sandstone"); - - REGISTRY.a(24, "sandstone", block2); - REGISTRY.a(25, "noteblock", (new BlockNote()).c(0.8F).c("musicBlock").d("noteblock")); - REGISTRY.a(26, "bed", (new BlockBed()).c(0.2F).c("bed").H().d("bed")); - REGISTRY.a(27, "golden_rail", (new BlockPoweredRail()).c(0.7F).a(j).c("goldenRail").d("rail_golden")); - REGISTRY.a(28, "detector_rail", (new BlockMinecartDetector()).c(0.7F).a(j).c("detectorRail").d("rail_detector")); - REGISTRY.a(29, "sticky_piston", (new BlockPiston(true)).c("pistonStickyBase")); - REGISTRY.a(30, "web", (new BlockWeb()).g(1).c(4.0F).c("web").d("web")); - REGISTRY.a(31, "tallgrass", (new BlockLongGrass()).c(0.0F).a(h).c("tallgrass")); - REGISTRY.a(32, "deadbush", (new BlockDeadBush()).c(0.0F).a(h).c("deadbush").d("deadbush")); - REGISTRY.a(33, "piston", (new BlockPiston(false)).c("pistonBase")); - REGISTRY.a(34, "piston_head", new BlockPistonExtension()); - REGISTRY.a(35, "wool", (new BlockCloth(Material.CLOTH)).c(0.8F).a(l).c("cloth").d("wool_colored")); - REGISTRY.a(36, "piston_extension", new BlockPistonMoving()); - REGISTRY.a(37, "yellow_flower", (new BlockFlowers(0)).c(0.0F).a(h).c("flower1").d("flower_dandelion")); - REGISTRY.a(38, "red_flower", (new BlockFlowers(1)).c(0.0F).a(h).c("flower2").d("flower_rose")); - REGISTRY.a(39, "brown_mushroom", (new BlockMushroom()).c(0.0F).a(h).a(0.125F).c("mushroom").d("mushroom_brown")); - REGISTRY.a(40, "red_mushroom", (new BlockMushroom()).c(0.0F).a(h).c("mushroom").d("mushroom_red")); - REGISTRY.a(41, "gold_block", (new BlockOreBlock(MaterialMapColor.F)).c(3.0F).b(10.0F).a(j).c("blockGold").d("gold_block")); - REGISTRY.a(42, "iron_block", (new BlockOreBlock(MaterialMapColor.h)).c(5.0F).b(10.0F).a(j).c("blockIron").d("iron_block")); - REGISTRY.a(43, "double_stone_slab", (new BlockStep(true)).c(2.0F).b(10.0F).a(i).c("stoneSlab")); - REGISTRY.a(44, "stone_slab", (new BlockStep(false)).c(2.0F).b(10.0F).a(i).c("stoneSlab")); - Block block3 = (new Block(Material.STONE)).c(2.0F).b(10.0F).a(i).c("brick").a(CreativeModeTab.b).d("brick"); - - REGISTRY.a(45, "brick_block", block3); - REGISTRY.a(46, "tnt", (new BlockTNT()).c(0.0F).a(h).c("tnt").d("tnt")); - REGISTRY.a(47, "bookshelf", (new BlockBookshelf()).c(1.5F).a(f).c("bookshelf").d("bookshelf")); - REGISTRY.a(48, "mossy_cobblestone", (new Block(Material.STONE)).c(2.0F).b(10.0F).a(i).c("stoneMoss").a(CreativeModeTab.b).d("cobblestone_mossy")); - REGISTRY.a(49, "obsidian", (new BlockObsidian()).c(50.0F).b(2000.0F).a(i).c("obsidian").d("obsidian")); - REGISTRY.a(50, "torch", (new BlockTorch()).c(0.0F).a(0.9375F).a(f).c("torch").d("torch_on")); - REGISTRY.a(51, "fire", (new BlockFire()).c(0.0F).a(1.0F).a(f).c("fire").H().d("fire")); - REGISTRY.a(52, "mob_spawner", (new BlockMobSpawner()).c(5.0F).a(j).c("mobSpawner").H().d("mob_spawner")); - REGISTRY.a(53, "oak_stairs", (new BlockStairs(block1, 0)).c("stairsWood")); - REGISTRY.a(54, "chest", (new BlockChest(0)).c(2.5F).a(f).c("chest")); - REGISTRY.a(55, "redstone_wire", (new BlockRedstoneWire()).c(0.0F).a(e).c("redstoneDust").H().d("redstone_dust")); - REGISTRY.a(56, "diamond_ore", (new BlockOre()).c(3.0F).b(5.0F).a(i).c("oreDiamond").d("diamond_ore")); - REGISTRY.a(57, "diamond_block", (new BlockOreBlock(MaterialMapColor.G)).c(5.0F).b(10.0F).a(j).c("blockDiamond").d("diamond_block")); - REGISTRY.a(58, "crafting_table", (new BlockWorkbench()).c(2.5F).a(f).c("workbench").d("crafting_table")); - REGISTRY.a(59, "wheat", (new BlockCrops()).c("crops").d("wheat")); - Block block4 = (new BlockSoil()).c(0.6F).a(g).c("farmland").d("farmland"); - - REGISTRY.a(60, "farmland", block4); - REGISTRY.a(61, "furnace", (new BlockFurnace(false)).c(3.5F).a(i).c("furnace").a(CreativeModeTab.c)); - REGISTRY.a(62, "lit_furnace", (new BlockFurnace(true)).c(3.5F).a(i).a(0.875F).c("furnace")); - REGISTRY.a(63, "standing_sign", (new BlockSign(TileEntitySign.class, true)).c(1.0F).a(f).c("sign").H()); - REGISTRY.a(64, "wooden_door", (new BlockDoor(Material.WOOD)).c(3.0F).a(f).c("doorWood").H().d("door_wood")); - REGISTRY.a(65, "ladder", (new BlockLadder()).c(0.4F).a(o).c("ladder").d("ladder")); - REGISTRY.a(66, "rail", (new BlockMinecartTrack()).c(0.7F).a(j).c("rail").d("rail_normal")); - REGISTRY.a(67, "stone_stairs", (new BlockStairs(block, 0)).c("stairsStone")); - REGISTRY.a(68, "wall_sign", (new BlockSign(TileEntitySign.class, false)).c(1.0F).a(f).c("sign").H()); - REGISTRY.a(69, "lever", (new BlockLever()).c(0.5F).a(f).c("lever").d("lever")); - REGISTRY.a(70, "stone_pressure_plate", (new BlockPressurePlateBinary("stone", Material.STONE, EnumMobType.MOBS)).c(0.5F).a(i).c("pressurePlate")); - REGISTRY.a(71, "iron_door", (new BlockDoor(Material.ORE)).c(5.0F).a(j).c("doorIron").H().d("door_iron")); - REGISTRY.a(72, "wooden_pressure_plate", (new BlockPressurePlateBinary("planks_oak", Material.WOOD, EnumMobType.EVERYTHING)).c(0.5F).a(f).c("pressurePlate")); - REGISTRY.a(73, "redstone_ore", (new BlockRedstoneOre(false)).c(3.0F).b(5.0F).a(i).c("oreRedstone").a(CreativeModeTab.b).d("redstone_ore")); - REGISTRY.a(74, "lit_redstone_ore", (new BlockRedstoneOre(true)).a(0.625F).c(3.0F).b(5.0F).a(i).c("oreRedstone").d("redstone_ore")); - REGISTRY.a(75, "unlit_redstone_torch", (new BlockRedstoneTorch(false)).c(0.0F).a(f).c("notGate").d("redstone_torch_off")); - REGISTRY.a(76, "redstone_torch", (new BlockRedstoneTorch(true)).c(0.0F).a(0.5F).a(f).c("notGate").a(CreativeModeTab.d).d("redstone_torch_on")); - REGISTRY.a(77, "stone_button", (new BlockStoneButton()).c(0.5F).a(i).c("button")); - REGISTRY.a(78, "snow_layer", (new BlockSnow()).c(0.1F).a(n).c("snow").g(0).d("snow")); - REGISTRY.a(79, "ice", (new BlockIce()).c(0.5F).g(3).a(k).c("ice").d("ice")); - REGISTRY.a(80, "snow", (new BlockSnowBlock()).c(0.2F).a(n).c("snow").d("snow")); - REGISTRY.a(81, "cactus", (new BlockCactus()).c(0.4F).a(l).c("cactus").d("cactus")); - REGISTRY.a(82, "clay", (new BlockClay()).c(0.6F).a(g).c("clay").d("clay")); - REGISTRY.a(83, "reeds", (new BlockReed()).c(0.0F).a(h).c("reeds").H().d("reeds")); - REGISTRY.a(84, "jukebox", (new BlockJukeBox()).c(2.0F).b(10.0F).a(i).c("jukebox").d("jukebox")); - REGISTRY.a(85, "fence", (new BlockFence("planks_oak", Material.WOOD)).c(2.0F).b(5.0F).a(f).c("fence")); - Block block5 = (new BlockPumpkin(false)).c(1.0F).a(f).c("pumpkin").d("pumpkin"); - - REGISTRY.a(86, "pumpkin", block5); - REGISTRY.a(87, "netherrack", (new BlockBloodStone()).c(0.4F).a(i).c("hellrock").d("netherrack")); - REGISTRY.a(88, "soul_sand", (new BlockSlowSand()).c(0.5F).a(m).c("hellsand").d("soul_sand")); - REGISTRY.a(89, "glowstone", (new BlockLightStone(Material.SHATTERABLE)).c(0.3F).a(k).a(1.0F).c("lightgem").d("glowstone")); - REGISTRY.a(90, "portal", (new BlockPortal()).c(-1.0F).a(k).a(0.75F).c("portal").d("portal")); - REGISTRY.a(91, "lit_pumpkin", (new BlockPumpkin(true)).c(1.0F).a(f).a(1.0F).c("litpumpkin").d("pumpkin")); - REGISTRY.a(92, "cake", (new BlockCake()).c(0.5F).a(l).c("cake").H().d("cake")); - REGISTRY.a(93, "unpowered_repeater", (new BlockRepeater(false)).c(0.0F).a(f).c("diode").H().d("repeater_off")); - REGISTRY.a(94, "powered_repeater", (new BlockRepeater(true)).c(0.0F).a(0.625F).a(f).c("diode").H().d("repeater_on")); - REGISTRY.a(95, "stained_glass", (new BlockStainedGlass(Material.SHATTERABLE)).c(0.3F).a(k).c("stainedGlass").d("glass")); - REGISTRY.a(96, "trapdoor", (new BlockTrapdoor(Material.WOOD)).c(3.0F).a(f).c("trapdoor").H().d("trapdoor")); - REGISTRY.a(97, "monster_egg", (new BlockMonsterEggs()).c(0.75F).c("monsterStoneEgg")); - Block block6 = (new BlockSmoothBrick()).c(1.5F).b(10.0F).a(i).c("stonebricksmooth").d("stonebrick"); - - REGISTRY.a(98, "stonebrick", block6); - REGISTRY.a(99, "brown_mushroom_block", (new BlockHugeMushroom(Material.WOOD, 0)).c(0.2F).a(f).c("mushroom").d("mushroom_block")); - REGISTRY.a(100, "red_mushroom_block", (new BlockHugeMushroom(Material.WOOD, 1)).c(0.2F).a(f).c("mushroom").d("mushroom_block")); - REGISTRY.a(101, "iron_bars", (new BlockThin("iron_bars", "iron_bars", Material.ORE, true)).c(5.0F).b(10.0F).a(j).c("fenceIron")); - REGISTRY.a(102, "glass_pane", (new BlockThin("glass", "glass_pane_top", Material.SHATTERABLE, false)).c(0.3F).a(k).c("thinGlass")); - Block block7 = (new BlockMelon()).c(1.0F).a(f).c("melon").d("melon"); - - REGISTRY.a(103, "melon_block", block7); - REGISTRY.a(104, "pumpkin_stem", (new BlockStem(block5)).c(0.0F).a(f).c("pumpkinStem").d("pumpkin_stem")); - REGISTRY.a(105, "melon_stem", (new BlockStem(block7)).c(0.0F).a(f).c("pumpkinStem").d("melon_stem")); - REGISTRY.a(106, "vine", (new BlockVine()).c(0.2F).a(h).c("vine").d("vine")); - REGISTRY.a(107, "fence_gate", (new BlockFenceGate()).c(2.0F).b(5.0F).a(f).c("fenceGate")); - REGISTRY.a(108, "brick_stairs", (new BlockStairs(block3, 0)).c("stairsBrick")); - REGISTRY.a(109, "stone_brick_stairs", (new BlockStairs(block6, 0)).c("stairsStoneBrickSmooth")); - REGISTRY.a(110, "mycelium", (new BlockMycel()).c(0.6F).a(h).c("mycel").d("mycelium")); - REGISTRY.a(111, "waterlily", (new BlockWaterLily()).c(0.0F).a(h).c("waterlily").d("waterlily")); - Block block8 = (new Block(Material.STONE)).c(2.0F).b(10.0F).a(i).c("netherBrick").a(CreativeModeTab.b).d("nether_brick"); - - REGISTRY.a(112, "nether_brick", block8); - REGISTRY.a(113, "nether_brick_fence", (new BlockFence("nether_brick", Material.STONE)).c(2.0F).b(10.0F).a(i).c("netherFence")); - REGISTRY.a(114, "nether_brick_stairs", (new BlockStairs(block8, 0)).c("stairsNetherBrick")); - REGISTRY.a(115, "nether_wart", (new BlockNetherWart()).c("netherStalk").d("nether_wart")); - REGISTRY.a(116, "enchanting_table", (new BlockEnchantmentTable()).c(5.0F).b(2000.0F).c("enchantmentTable").d("enchanting_table")); - REGISTRY.a(117, "brewing_stand", (new BlockBrewingStand()).c(0.5F).a(0.125F).c("brewingStand").d("brewing_stand")); - REGISTRY.a(118, "cauldron", (new BlockCauldron()).c(2.0F).c("cauldron").d("cauldron")); - REGISTRY.a(119, "end_portal", (new BlockEnderPortal(Material.PORTAL)).c(-1.0F).b(6000000.0F)); - REGISTRY.a(120, "end_portal_frame", (new BlockEnderPortalFrame()).a(k).a(0.125F).c(-1.0F).c("endPortalFrame").b(6000000.0F).a(CreativeModeTab.c).d("endframe")); - REGISTRY.a(121, "end_stone", (new Block(Material.STONE)).c(3.0F).b(15.0F).a(i).c("whiteStone").a(CreativeModeTab.b).d("end_stone")); - REGISTRY.a(122, "dragon_egg", (new BlockDragonEgg()).c(3.0F).b(15.0F).a(i).a(0.125F).c("dragonEgg").d("dragon_egg")); - REGISTRY.a(123, "redstone_lamp", (new BlockRedstoneLamp(false)).c(0.3F).a(k).c("redstoneLight").a(CreativeModeTab.d).d("redstone_lamp_off")); - REGISTRY.a(124, "lit_redstone_lamp", (new BlockRedstoneLamp(true)).c(0.3F).a(k).c("redstoneLight").d("redstone_lamp_on")); - REGISTRY.a(125, "double_wooden_slab", (new BlockWoodStep(true)).c(2.0F).b(5.0F).a(f).c("woodSlab")); - REGISTRY.a(126, "wooden_slab", (new BlockWoodStep(false)).c(2.0F).b(5.0F).a(f).c("woodSlab")); - REGISTRY.a(127, "cocoa", (new BlockCocoa()).c(0.2F).b(5.0F).a(f).c("cocoa").d("cocoa")); - REGISTRY.a(128, "sandstone_stairs", (new BlockStairs(block2, 0)).c("stairsSandStone")); - REGISTRY.a(129, "emerald_ore", (new BlockOre()).c(3.0F).b(5.0F).a(i).c("oreEmerald").d("emerald_ore")); - REGISTRY.a(130, "ender_chest", (new BlockEnderChest()).c(22.5F).b(1000.0F).a(i).c("enderChest").a(0.5F)); - REGISTRY.a(131, "tripwire_hook", (new BlockTripwireHook()).c("tripWireSource").d("trip_wire_source")); - REGISTRY.a(132, "tripwire", (new BlockTripwire()).c("tripWire").d("trip_wire")); - REGISTRY.a(133, "emerald_block", (new BlockOreBlock(MaterialMapColor.I)).c(5.0F).b(10.0F).a(j).c("blockEmerald").d("emerald_block")); - REGISTRY.a(134, "spruce_stairs", (new BlockStairs(block1, 1)).c("stairsWoodSpruce")); - REGISTRY.a(135, "birch_stairs", (new BlockStairs(block1, 2)).c("stairsWoodBirch")); - REGISTRY.a(136, "jungle_stairs", (new BlockStairs(block1, 3)).c("stairsWoodJungle")); - REGISTRY.a(137, "command_block", (new BlockCommand()).s().b(6000000.0F).c("commandBlock").d("command_block")); - REGISTRY.a(138, "beacon", (new BlockBeacon()).c("beacon").a(1.0F).d("beacon")); - REGISTRY.a(139, "cobblestone_wall", (new BlockCobbleWall(block)).c("cobbleWall")); - REGISTRY.a(140, "flower_pot", (new BlockFlowerPot()).c(0.0F).a(e).c("flowerPot").d("flower_pot")); - REGISTRY.a(141, "carrots", (new BlockCarrots()).c("carrots").d("carrots")); - REGISTRY.a(142, "potatoes", (new BlockPotatoes()).c("potatoes").d("potatoes")); - REGISTRY.a(143, "wooden_button", (new BlockWoodButton()).c(0.5F).a(f).c("button")); - REGISTRY.a(144, "skull", (new BlockSkull()).c(1.0F).a(i).c("skull").d("skull")); - REGISTRY.a(145, "anvil", (new BlockAnvil()).c(5.0F).a(p).b(2000.0F).c("anvil")); - REGISTRY.a(146, "trapped_chest", (new BlockChest(1)).c(2.5F).a(f).c("chestTrap")); - REGISTRY.a(147, "light_weighted_pressure_plate", (new BlockPressurePlateWeighted("gold_block", Material.ORE, 15)).c(0.5F).a(f).c("weightedPlate_light")); - REGISTRY.a(148, "heavy_weighted_pressure_plate", (new BlockPressurePlateWeighted("iron_block", Material.ORE, 150)).c(0.5F).a(f).c("weightedPlate_heavy")); - REGISTRY.a(149, "unpowered_comparator", (new BlockRedstoneComparator(false)).c(0.0F).a(f).c("comparator").H().d("comparator_off")); - REGISTRY.a(150, "powered_comparator", (new BlockRedstoneComparator(true)).c(0.0F).a(0.625F).a(f).c("comparator").H().d("comparator_on")); - REGISTRY.a(151, "daylight_detector", (new BlockDaylightDetector()).c(0.2F).a(f).c("daylightDetector").d("daylight_detector")); - REGISTRY.a(152, "redstone_block", (new BlockRedstone(MaterialMapColor.f)).c(5.0F).b(10.0F).a(j).c("blockRedstone").d("redstone_block")); - REGISTRY.a(153, "quartz_ore", (new BlockOre()).c(3.0F).b(5.0F).a(i).c("netherquartz").d("quartz_ore")); - REGISTRY.a(154, "hopper", (new BlockHopper()).c(3.0F).b(8.0F).a(f).c("hopper").d("hopper")); - Block block9 = (new BlockQuartz()).a(i).c(0.8F).c("quartzBlock").d("quartz_block"); - - REGISTRY.a(155, "quartz_block", block9); - REGISTRY.a(156, "quartz_stairs", (new BlockStairs(block9, 0)).c("stairsQuartz")); - REGISTRY.a(157, "activator_rail", (new BlockPoweredRail()).c(0.7F).a(j).c("activatorRail").d("rail_activator")); - REGISTRY.a(158, "dropper", (new BlockDropper()).c(3.5F).a(i).c("dropper").d("dropper")); - REGISTRY.a(159, "stained_hardened_clay", (new BlockCloth(Material.STONE)).c(1.25F).b(7.0F).a(i).c("clayHardenedStained").d("hardened_clay_stained")); - REGISTRY.a(160, "stained_glass_pane", (new BlockStainedGlassPane()).c(0.3F).a(k).c("thinStainedGlass").d("glass")); - REGISTRY.a(161, "leaves2", (new BlockLeaves2()).c("leaves").d("leaves")); - REGISTRY.a(162, "log2", (new BlockLog2()).c("log").d("log")); - REGISTRY.a(163, "acacia_stairs", (new BlockStairs(block1, 4)).c("stairsWoodAcacia")); - REGISTRY.a(164, "dark_oak_stairs", (new BlockStairs(block1, 5)).c("stairsWoodDarkOak")); - REGISTRY.a(170, "hay_block", (new BlockHay()).c(0.5F).a(h).c("hayBlock").a(CreativeModeTab.b).d("hay_block")); - REGISTRY.a(171, "carpet", (new BlockCarpet()).c(0.1F).a(l).c("woolCarpet").g(0)); - REGISTRY.a(172, "hardened_clay", (new BlockHardenedClay()).c(1.25F).b(7.0F).a(i).c("clayHardened").d("hardened_clay")); - REGISTRY.a(173, "coal_block", (new Block(Material.STONE)).c(5.0F).b(10.0F).a(i).c("blockCoal").a(CreativeModeTab.b).d("coal_block")); - REGISTRY.a(174, "packed_ice", (new BlockPackedIce()).c(0.5F).a(k).c("icePacked").d("ice_packed")); - REGISTRY.a(175, "double_plant", new BlockTallPlant()); - Iterator iterator = REGISTRY.iterator(); - - while (iterator.hasNext()) { - Block block10 = (Block) iterator.next(); - - if (block10.material == Material.AIR) { - block10.u = false; - } else { - boolean flag = false; - boolean flag1 = block10.b() == 10; - boolean flag2 = block10 instanceof BlockStepAbstract; - boolean flag3 = block10 == block4; - boolean flag4 = block10.s; - boolean flag5 = block10.r == 0; - - if (flag1 || flag2 || flag3 || flag4 || flag5) { - flag = true; - } - - block10.u = flag; - } - } - } - - protected Block(Material material) { - this.stepSound = e; - this.I = 1.0F; - this.frictionFactor = 0.6F; - this.material = material; - this.a(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); - this.q = this.c(); - this.r = this.c() ? 255 : 0; - this.s = !material.blocksLight(); - } - - protected Block a(StepSound stepsound) { - this.stepSound = stepsound; - return this; - } - - protected Block g(int i) { - this.r = i; - return this; - } - - protected Block a(float f) { - this.t = (int) (15.0F * f); - return this; - } - - protected Block b(float f) { - this.durability = f * 3.0F; - return this; - } - - public boolean r() { - return this.material.k() && this.d() && !this.isPowerSource(); - } - - public boolean d() { - return true; - } - - public boolean b(IBlockAccess iblockaccess, int i, int j, int k) { - return !this.material.isSolid(); - } - - public int b() { - return 0; - } - - protected Block c(float f) { - this.strength = f; - if (this.durability < f * 5.0F) { - this.durability = f * 5.0F; - } - - return this; - } - - protected Block s() { - this.c(-1.0F); - return this; - } - - public float f(World world, int i, int j, int k) { - return this.strength; - } - - protected Block a(boolean flag) { - this.z = flag; - return this; - } - - public boolean isTicking() { - return this.z; - } - - public boolean isTileEntity() { - return this.isTileEntity; - } - - 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; - this.maxX = (double) f3; - this.maxY = (double) f4; - this.maxZ = (double) f5; - } - - public boolean d(IBlockAccess iblockaccess, int i, int j, int k, int l) { - return iblockaccess.getType(i, j, k).getMaterial().isBuildable(); - } - - public void a(World world, int i, int j, int k, AxisAlignedBB axisalignedbb, List list, Entity entity) { - AxisAlignedBB axisalignedbb1 = this.a(world, i, j, k); - - if (axisalignedbb1 != null && axisalignedbb.b(axisalignedbb1)) { - list.add(axisalignedbb1); - } - } - - public AxisAlignedBB a(World world, int i, int j, int k) { - return AxisAlignedBB.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 c() { - return true; - } - - public boolean a(int i, boolean flag) { - return this.v(); - } - - public boolean v() { - return true; - } - - public void a(World world, int i, int j, int k, Random random) {} - - public void postBreak(World world, int i, int j, int k, int l) {} - - public void doPhysics(World world, int i, int j, int k, Block block) {} - - public int a(World world) { - return 10; - } - - public void onPlace(World world, int i, int j, int k) {} - - public void remove(World world, int i, int j, int k, Block block, int l) {} - - public int a(Random random) { - return 1; - } - - public Item getDropType(int i, Random random, int j) { - return Item.getItemOf(this); - } - - public float getDamage(EntityHuman entityhuman, World world, int i, int j, int k) { - float f = this.f(world, i, j, k); - - return f < 0.0F ? 0.0F : (!entityhuman.a(this) ? entityhuman.a(this, false) / f / 100.0F : entityhuman.a(this, true) / f / 30.0F); - } - - public final void b(World world, int i, int j, int k, int l, int i1) { - this.dropNaturally(world, i, j, k, l, 1.0F, i1); - } - - public void dropNaturally(World world, int i, int j, int k, int l, float f, int i1) { - if (!world.isStatic) { - int j1 = this.getDropCount(i1, world.random); - - for (int k1 = 0; k1 < j1; ++k1) { - // CraftBukkit - <= to < to allow for plugins to completely disable block drops from explosions - if (world.random.nextFloat() < f) { - Item item = this.getDropType(l, world.random, i1); - - if (item != null) { - this.a(world, i, j, k, new ItemStack(item, 1, this.getDropData(l))); - } - } - } - } - } - - protected void a(World world, int i, int j, int k, ItemStack itemstack) { - 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; - 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, itemstack); - - entityitem.pickupDelay = 10; - world.addEntity(entityitem); - } - } - - protected void dropExperience(World world, int i, int j, int k, int l) { - if (!world.isStatic) { - while (l > 0) { - int i1 = EntityExperienceOrb.getOrbValue(l); - - l -= i1; - world.addEntity(new EntityExperienceOrb(world, (double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, i1)); - } - } - } - - public int getDropData(int i) { - return 0; - } - - public float a(Entity entity) { - return this.durability / 5.0F; - } - - public MovingObjectPosition a(World world, int i, int j, int k, Vec3D vec3d, Vec3D vec3d1) { - this.updateShape(world, i, j, k); - vec3d = vec3d.add((double) (-i), (double) (-j), (double) (-k)); - vec3d1 = vec3d1.add((double) (-i), (double) (-j), (double) (-k)); - Vec3D vec3d2 = vec3d.b(vec3d1, this.minX); - Vec3D vec3d3 = vec3d.b(vec3d1, this.maxX); - Vec3D vec3d4 = vec3d.c(vec3d1, this.minY); - Vec3D vec3d5 = vec3d.c(vec3d1, this.maxY); - Vec3D vec3d6 = vec3d.d(vec3d1, this.minZ); - Vec3D vec3d7 = vec3d.d(vec3d1, this.maxZ); - - if (!this.a(vec3d2)) { - vec3d2 = null; - } - - if (!this.a(vec3d3)) { - vec3d3 = null; - } - - if (!this.b(vec3d4)) { - vec3d4 = null; - } - - if (!this.b(vec3d5)) { - vec3d5 = null; - } - - if (!this.c(vec3d6)) { - vec3d6 = null; - } - - if (!this.c(vec3d7)) { - vec3d7 = null; - } - - Vec3D vec3d8 = null; - - if (vec3d2 != null && (vec3d8 == null || vec3d.distanceSquared(vec3d2) < vec3d.distanceSquared(vec3d8))) { - vec3d8 = vec3d2; - } - - if (vec3d3 != null && (vec3d8 == null || vec3d.distanceSquared(vec3d3) < vec3d.distanceSquared(vec3d8))) { - vec3d8 = vec3d3; - } - - if (vec3d4 != null && (vec3d8 == null || vec3d.distanceSquared(vec3d4) < vec3d.distanceSquared(vec3d8))) { - vec3d8 = vec3d4; - } - - if (vec3d5 != null && (vec3d8 == null || vec3d.distanceSquared(vec3d5) < vec3d.distanceSquared(vec3d8))) { - vec3d8 = vec3d5; - } - - if (vec3d6 != null && (vec3d8 == null || vec3d.distanceSquared(vec3d6) < vec3d.distanceSquared(vec3d8))) { - vec3d8 = vec3d6; - } - - if (vec3d7 != null && (vec3d8 == null || vec3d.distanceSquared(vec3d7) < vec3d.distanceSquared(vec3d8))) { - vec3d8 = vec3d7; - } - - if (vec3d8 == null) { - return null; - } else { - byte b0 = -1; - - if (vec3d8 == vec3d2) { - b0 = 4; - } - - if (vec3d8 == vec3d3) { - b0 = 5; - } - - if (vec3d8 == vec3d4) { - b0 = 0; - } - - if (vec3d8 == vec3d5) { - b0 = 1; - } - - if (vec3d8 == vec3d6) { - b0 = 2; - } - - if (vec3d8 == vec3d7) { - b0 = 3; - } - - return new MovingObjectPosition(i, j, k, b0, vec3d8.add((double) i, (double) j, (double) k)); - } - } - - 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; - } - - 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; - } - - 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; - } - - public void wasExploded(World world, int i, int j, int k, Explosion explosion) {} - - public boolean canPlace(World world, int i, int j, int k, int l, ItemStack itemstack) { - return this.canPlace(world, i, j, k, l); - } - - public boolean canPlace(World world, int i, int j, int k, int l) { - return this.canPlace(world, i, j, k); - } - - public boolean canPlace(World world, int i, int j, int k) { - return world.getType(i, j, k).material.isReplaceable(); - } - - public boolean interact(World world, int i, int j, int k, EntityHuman entityhuman, int l, float f, float f1, float f2) { - return false; - } - - public void b(World world, int i, int j, int k, Entity entity) {} - - public int getPlacedData(World world, int i, int j, int k, int l, float f, float f1, float f2, int i1) { - return i1; - } - - public void attack(World world, int i, int j, int k, EntityHuman entityhuman) {} - - public void a(World world, int i, int j, int k, Entity entity, Vec3D vec3d) {} - - public void updateShape(IBlockAccess iblockaccess, int i, int j, int k) {} - - public final double x() { - return this.minX; - } - - public final double y() { - return this.maxX; - } - - public final double z() { - return this.minY; - } - - public final double A() { - return this.maxY; - } - - public final double B() { - return this.minZ; - } - - public final double C() { - return this.maxZ; - } - - public int b(IBlockAccess iblockaccess, int i, int j, int k, int l) { - return 0; - } - - public boolean isPowerSource() { - return false; - } - - public void a(World world, int i, int j, int k, Entity entity) {} - - public int c(IBlockAccess iblockaccess, int i, int j, int k, int l) { - return 0; - } - - public void g() {} - - public void a(World world, EntityHuman entityhuman, int i, int j, int k, int l) { - entityhuman.a(StatisticList.MINE_BLOCK_COUNT[getId(this)], 1); - entityhuman.applyExhaustion(0.025F); - if (this.E() && EnchantmentManager.hasSilkTouchEnchantment(entityhuman)) { - ItemStack itemstack = this.j(l); - - if (itemstack != null) { - this.a(world, i, j, k, itemstack); - } - } else { - int i1 = EnchantmentManager.getBonusBlockLootEnchantmentLevel(entityhuman); - - this.b(world, i, j, k, l, i1); - } - } - - protected boolean E() { - return this.d() && !this.isTileEntity; - } - - protected ItemStack j(int i) { - int j = 0; - Item item = Item.getItemOf(this); - - if (item != null && item.n()) { - j = i; - } - - return new ItemStack(item, 1, j); - } - - public int getDropCount(int i, Random random) { - return this.a(random); - } - - public boolean j(World world, int i, int j, int k) { - return true; - } - - public void postPlace(World world, int i, int j, int k, EntityLiving entityliving, ItemStack itemstack) {} - - public void postPlace(World world, int i, int j, int k, int l) {} - - public Block c(String s) { - this.name = s; - return this; - } - - public String getName() { - return LocaleI18n.get(this.a() + ".name"); - } - - public String a() { - return "tile." + this.name; - } - - public boolean a(World world, int i, int j, int k, int l, int i1) { - return false; - } - - public boolean G() { - return this.y; - } - - protected Block H() { - this.y = false; - return this; - } - - public int h() { - 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; - } - - public void a(World world, int i, int j, int k, int l, EntityHuman entityhuman) {} - - public void f(World world, int i, int j, int k, int l) {} - - public void l(World world, int i, int j, int k) {} - - public boolean L() { - return true; - } - - public boolean a(Explosion explosion) { - return true; - } - - public boolean c(Block block) { - return this == block; - } - - public static boolean a(Block block, Block block1) { - return block != null && block1 != null ? (block == block1 ? true : block.c(block1)) : false; - } - - public boolean isComplexRedstone() { - return false; - } - - public int g(World world, int i, int j, int k, int l) { - return 0; - } - - protected Block d(String s) { - this.d = s; - return this; - } - - // CraftBukkit start - public int getExpDrop(World world, int data, int enchantmentLevel) { - return 0; - } - // CraftBukkit end -} diff --git a/src/main/java/net/minecraft/server/BlockActionDataList.java b/src/main/java/net/minecraft/server/BlockActionDataList.java deleted file mode 100644 index 30109ecc..00000000 --- a/src/main/java/net/minecraft/server/BlockActionDataList.java +++ /dev/null @@ -1,13 +0,0 @@ -package net.minecraft.server; - -import java.util.ArrayList; - -// CraftBukkit - imported class because the constructor is package private -class BlockActionDataList extends ArrayList { - - private BlockActionDataList() {} - - BlockActionDataList(BananaAPI bananaapi) { - this(); - } -} diff --git a/src/main/java/net/minecraft/server/BlockBloodStone.java b/src/main/java/net/minecraft/server/BlockBloodStone.java deleted file mode 100644 index ca46ea62..00000000 --- a/src/main/java/net/minecraft/server/BlockBloodStone.java +++ /dev/null @@ -1,27 +0,0 @@ -package net.minecraft.server; - -import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit - -public class BlockBloodStone extends Block { - - public BlockBloodStone() { - super(Material.STONE); - this.a(CreativeModeTab.b); - } - - public MaterialMapColor f(int i) { - return MaterialMapColor.K; - } - - // CraftBukkit start - public void doPhysics(World world, int i, int j, int k, int l) { - if (net.minecraft.server.Block.getById(l) != null && net.minecraft.server.Block.getById(l).isPowerSource()) { - org.bukkit.block.Block block = world.getWorld().getBlockAt(i, j, k); - int power = block.getBlockPower(); - - BlockRedstoneEvent event = new BlockRedstoneEvent(block, power, power); - world.getServer().getPluginManager().callEvent(event); - } - } - // CraftBukkit end -} diff --git a/src/main/java/net/minecraft/server/BlockButtonAbstract.java b/src/main/java/net/minecraft/server/BlockButtonAbstract.java deleted file mode 100644 index 6e542058..00000000 --- a/src/main/java/net/minecraft/server/BlockButtonAbstract.java +++ /dev/null @@ -1,332 +0,0 @@ -package net.minecraft.server; - -import java.util.List; -import java.util.Random; - -// CraftBukkit start -import org.bukkit.event.block.BlockRedstoneEvent; -import org.bukkit.event.entity.EntityInteractEvent; -// CraftBukkit end - -public abstract class BlockButtonAbstract extends Block { - - private final boolean a; - - protected BlockButtonAbstract(boolean flag) { - super(Material.ORIENTABLE); - this.a(true); - this.a(CreativeModeTab.d); - this.a = flag; - } - - public AxisAlignedBB a(World world, int i, int j, int k) { - return null; - } - - public int a(World world) { - return this.a ? 30 : 20; - } - - public boolean c() { - return false; - } - - public boolean d() { - return false; - } - - public boolean canPlace(World world, int i, int j, int k, int l) { - return l == 2 && world.getType(i, j, k + 1).r() ? true : (l == 3 && world.getType(i, j, k - 1).r() ? true : (l == 4 && world.getType(i + 1, j, k).r() ? true : l == 5 && world.getType(i - 1, j, k).r())); - } - - public boolean canPlace(World world, int i, int j, int k) { - return world.getType(i - 1, j, k).r() ? true : (world.getType(i + 1, j, k).r() ? true : (world.getType(i, j, k - 1).r() ? true : world.getType(i, j, k + 1).r())); - } - - public int getPlacedData(World world, int i, int j, int k, int l, float f, float f1, float f2, int i1) { - int j1 = world.getData(i, j, k); - int k1 = j1 & 8; - - j1 &= 7; - if (l == 2 && world.getType(i, j, k + 1).r()) { - j1 = 4; - } else if (l == 3 && world.getType(i, j, k - 1).r()) { - j1 = 3; - } else if (l == 4 && world.getType(i + 1, j, k).r()) { - j1 = 2; - } else if (l == 5 && world.getType(i - 1, j, k).r()) { - j1 = 1; - } else { - j1 = this.e(world, i, j, k); - } - - return j1 + k1; - } - - private int e(World world, int i, int j, int k) { - return world.getType(i - 1, j, k).r() ? 1 : (world.getType(i + 1, j, k).r() ? 2 : (world.getType(i, j, k - 1).r() ? 3 : (world.getType(i, j, k + 1).r() ? 4 : 1))); - } - - public void doPhysics(World world, int i, int j, int k, Block block) { - if (this.m(world, i, j, k)) { - int l = world.getData(i, j, k) & 7; - boolean flag = false; - - if (!world.getType(i - 1, j, k).r() && l == 1) { - flag = true; - } - - if (!world.getType(i + 1, j, k).r() && l == 2) { - flag = true; - } - - if (!world.getType(i, j, k - 1).r() && l == 3) { - flag = true; - } - - if (!world.getType(i, j, k + 1).r() && l == 4) { - flag = true; - } - - if (flag) { - this.b(world, i, j, k, world.getData(i, j, k), 0); - world.setAir(i, j, k); - } - } - } - - private boolean m(World world, int i, int j, int k) { - if (!this.canPlace(world, i, j, k)) { - this.b(world, i, j, k, world.getData(i, j, k), 0); - world.setAir(i, j, k); - return false; - } else { - return true; - } - } - - public void updateShape(IBlockAccess iblockaccess, int i, int j, int k) { - int l = iblockaccess.getData(i, j, k); - - this.b(l); - } - - private void b(int i) { - int j = i & 7; - boolean flag = (i & 8) > 0; - float f = 0.375F; - float f1 = 0.625F; - float f2 = 0.1875F; - float f3 = 0.125F; - - if (flag) { - f3 = 0.0625F; - } - - if (j == 1) { - this.a(0.0F, f, 0.5F - f2, f3, f1, 0.5F + f2); - } else if (j == 2) { - this.a(1.0F - f3, f, 0.5F - f2, 1.0F, f1, 0.5F + f2); - } else if (j == 3) { - this.a(0.5F - f2, f, 0.0F, 0.5F + f2, f1, f3); - } 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) {} - - 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); - int j1 = i1 & 7; - int k1 = 8 - (i1 & 8); - - if (k1 == 0) { - return true; - } else { - // CraftBukkit start - org.bukkit.block.Block block = world.getWorld().getBlockAt(i, j, k); - int old = (k1 != 8) ? 15 : 0; - int current = (k1 == 8) ? 15 : 0; - - BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, old, current); - world.getServer().getPluginManager().callEvent(eventRedstone); - - if ((eventRedstone.getNewCurrent() > 0) != (k1 == 8)) { - return true; - } - // CraftBukkit end - - world.setData(i, j, k, j1 + k1, 3); - world.c(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); - this.a(world, i, j, k, j1); - world.a(i, j, k, this, this.a(world)); - return true; - } - } - - public void remove(World world, int i, int j, int k, Block block, int l) { - if ((l & 8) > 0) { - int i1 = l & 7; - - this.a(world, i, j, k, i1); - } - - super.remove(world, i, j, k, block, l); - } - - public int b(IBlockAccess iblockaccess, int i, int j, int k, int l) { - return (iblockaccess.getData(i, j, k) & 8) > 0 ? 15 : 0; - } - - public int c(IBlockAccess iblockaccess, int i, int j, int k, int l) { - int i1 = iblockaccess.getData(i, j, k); - - if ((i1 & 8) == 0) { - return 0; - } else { - int j1 = i1 & 7; - - return j1 == 5 && l == 1 ? 15 : (j1 == 4 && l == 2 ? 15 : (j1 == 3 && l == 3 ? 15 : (j1 == 2 && l == 4 ? 15 : (j1 == 1 && l == 5 ? 15 : 0)))); - } - } - - public boolean isPowerSource() { - return true; - } - - public void a(World world, int i, int j, int k, Random random) { - if (!world.isStatic) { - int l = world.getData(i, j, k); - - if ((l & 8) != 0) { - if (this.a) { - this.n(world, i, j, k); - } else { - // CraftBukkit start - org.bukkit.block.Block block = world.getWorld().getBlockAt(i, j, k); - - BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, 15, 0); - world.getServer().getPluginManager().callEvent(eventRedstone); - - if (eventRedstone.getNewCurrent() > 0) { - return; - } - // CraftBukkit end - world.setData(i, j, k, l & 7, 3); - int i1 = l & 7; - - this.a(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.c(i, j, k, i, j, k); - } - } - } - } - - public void g() { - float f = 0.1875F; - float f1 = 0.125F; - float f2 = 0.125F; - - this.a(0.5F - f, 0.5F - f1, 0.5F - f2, 0.5F + f, 0.5F + f1, 0.5F + f2); - } - - 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.n(world, i, j, k); - } - } - } - } - - private void n(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.b(l); - List list = world.a(EntityArrow.class, AxisAlignedBB.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(); - - // CraftBukkit start - Call interact event when arrows turn on wooden buttons - if (flag != flag1 && flag1) { - org.bukkit.block.Block block = world.getWorld().getBlockAt(i, j, k); - boolean allowed = false; - - // If all of the events are cancelled block the button press, else allow - for (Object object : list) { - if (object != null) { - EntityInteractEvent event = new EntityInteractEvent(((Entity) object).getBukkitEntity(), block); - world.getServer().getPluginManager().callEvent(event); - - if (!event.isCancelled()) { - allowed = true; - break; - } - } - } - - if (!allowed) { - return; - } - } - // CraftBukkit end - - if (flag1 && !flag) { - // CraftBukkit start - org.bukkit.block.Block block = world.getWorld().getBlockAt(i, j, k); - - BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, 0, 15); - world.getServer().getPluginManager().callEvent(eventRedstone); - - if (eventRedstone.getNewCurrent() <= 0) { - return; - } - // CraftBukkit end - world.setData(i, j, k, i1 | 8, 3); - this.a(world, i, j, k, i1); - world.c(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) { - // CraftBukkit start - org.bukkit.block.Block block = world.getWorld().getBlockAt(i, j, k); - - BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, 15, 0); - world.getServer().getPluginManager().callEvent(eventRedstone); - - if (eventRedstone.getNewCurrent() > 0) { - return; - } - // CraftBukkit end - world.setData(i, j, k, i1, 3); - this.a(world, i, j, k, i1); - world.c(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, this.a(world)); - } - } - - private void a(World world, int i, int j, int k, int l) { - world.applyPhysics(i, j, k, this); - if (l == 1) { - world.applyPhysics(i - 1, j, k, this); - } else if (l == 2) { - world.applyPhysics(i + 1, j, k, this); - } else if (l == 3) { - world.applyPhysics(i, j, k - 1, this); - } else if (l == 4) { - world.applyPhysics(i, j, k + 1, this); - } else { - world.applyPhysics(i, j - 1, k, this); - } - } -} diff --git a/src/main/java/net/minecraft/server/BlockCactus.java b/src/main/java/net/minecraft/server/BlockCactus.java deleted file mode 100644 index e920c6f4..00000000 --- a/src/main/java/net/minecraft/server/BlockCactus.java +++ /dev/null @@ -1,86 +0,0 @@ -package net.minecraft.server; - -import java.util.Random; - -import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit - -public class BlockCactus extends Block { - - protected BlockCactus() { - super(Material.CACTUS); - this.a(true); - this.a(CreativeModeTab.c); - } - - public void a(World world, int i, int j, int k, Random random) { - if (world.isEmpty(i, j + 1, k)) { - int l; - - for (l = 1; world.getType(i, j - l, k) == this; ++l) { - ; - } - - if (l < 3) { - int i1 = world.getData(i, j, k); - - if (i1 == 15) { - CraftEventFactory.handleBlockGrowEvent(world, i, j + 1, k, this, 0); // CraftBukkit - world.setData(i, j, k, 0, 4); - this.doPhysics(world, i, j + 1, k, this); - } else { - world.setData(i, j, k, i1 + 1, 4); - } - } - } - } - - public AxisAlignedBB a(World world, int i, int j, int k) { - float f = 0.0625F; - - return AxisAlignedBB.a((double) ((float) i + f), (double) j, (double) ((float) k + f), (double) ((float) (i + 1) - f), (double) ((float) (j + 1) - f), (double) ((float) (k + 1) - f)); - } - - public boolean d() { - return false; - } - - public boolean c() { - return false; - } - - public int b() { - return 13; - } - - public boolean canPlace(World world, int i, int j, int k) { - return !super.canPlace(world, i, j, k) ? false : this.j(world, i, j, k); - } - - public void doPhysics(World world, int i, int j, int k, Block block) { - if (!this.j(world, i, j, k)) { - world.setAir(i, j, k, true); - } - } - - public boolean j(World world, int i, int j, int k) { - if (world.getType(i - 1, j, k).getMaterial().isBuildable()) { - return false; - } else if (world.getType(i + 1, j, k).getMaterial().isBuildable()) { - return false; - } else if (world.getType(i, j, k - 1).getMaterial().isBuildable()) { - return false; - } else if (world.getType(i, j, k + 1).getMaterial().isBuildable()) { - return false; - } else { - Block block = world.getType(i, j - 1, k); - - return block == Blocks.CACTUS || block == Blocks.SAND; - } - } - - public void a(World world, int i, int j, int k, Entity entity) { - CraftEventFactory.blockDamage = world.getWorld().getBlockAt(i, j, k); // CraftBukkit - entity.damageEntity(DamageSource.CACTUS, 1.0F); - CraftEventFactory.blockDamage = null; // CraftBukkit - } -} diff --git a/src/main/java/net/minecraft/server/BlockCake.java b/src/main/java/net/minecraft/server/BlockCake.java deleted file mode 100644 index e65a2705..00000000 --- a/src/main/java/net/minecraft/server/BlockCake.java +++ /dev/null @@ -1,98 +0,0 @@ -package net.minecraft.server; - -import java.util.Random; - -public class BlockCake extends Block { - - protected BlockCake() { - super(Material.CAKE); - this.a(true); - } - - public void updateShape(IBlockAccess iblockaccess, int i, int j, int k) { - int l = iblockaccess.getData(i, j, k); - float f = 0.0625F; - float f1 = (float) (1 + l * 2) / 16.0F; - float f2 = 0.5F; - - this.a(f1, 0.0F, f, 1.0F - f, f2, 1.0F - f); - } - - public void g() { - float f = 0.0625F; - float f1 = 0.5F; - - this.a(f, 0.0F, f, 1.0F - f, f1, 1.0F - f); - } - - public AxisAlignedBB a(World world, int i, int j, int k) { - int l = world.getData(i, j, k); - float f = 0.0625F; - float f1 = (float) (1 + l * 2) / 16.0F; - float f2 = 0.5F; - - return AxisAlignedBB.a((double) ((float) i + f1), (double) j, (double) ((float) k + f), (double) ((float) (i + 1) - f), (double) ((float) j + f2 - f), (double) ((float) (k + 1) - f)); - } - - public boolean d() { - return false; - } - - public boolean c() { - return false; - } - - public boolean interact(World world, int i, int j, int k, EntityHuman entityhuman, int l, float f, float f1, float f2) { - this.b(world, i, j, k, entityhuman); - return true; - } - - public void attack(World world, int i, int j, int k, EntityHuman entityhuman) { - this.b(world, i, j, k, entityhuman); - } - - private void b(World world, int i, int j, int k, EntityHuman entityhuman) { - if (entityhuman.g(false)) { - // CraftBukkit start - int oldFoodLevel = entityhuman.getFoodData().foodLevel; - - org.bukkit.event.entity.FoodLevelChangeEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callFoodLevelChangeEvent(entityhuman, 2 + oldFoodLevel); - - if (!event.isCancelled()) { - entityhuman.getFoodData().eat(event.getFoodLevel() - oldFoodLevel, 0.1F); - } - - ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutUpdateHealth(((EntityPlayer) entityhuman).getBukkitEntity().getScaledHealth(), entityhuman.getFoodData().foodLevel, entityhuman.getFoodData().saturationLevel)); - // CraftBukkit end - int l = world.getData(i, j, k) + 1; - - if (l >= 6) { - world.setAir(i, j, k); - } else { - world.setData(i, j, k, l, 2); - } - } - } - - public boolean canPlace(World world, int i, int j, int k) { - return !super.canPlace(world, i, j, k) ? false : this.j(world, i, j, k); - } - - public void doPhysics(World world, int i, int j, int k, Block block) { - if (!this.j(world, i, j, k)) { - world.setAir(i, j, k); - } - } - - public boolean j(World world, int i, int j, int k) { - return world.getType(i, j - 1, k).getMaterial().isBuildable(); - } - - public int a(Random random) { - return 0; - } - - public Item getDropType(int i, Random random, int j) { - return null; - } -} diff --git a/src/main/java/net/minecraft/server/BlockCocoa.java b/src/main/java/net/minecraft/server/BlockCocoa.java deleted file mode 100644 index 5584fbd9..00000000 --- a/src/main/java/net/minecraft/server/BlockCocoa.java +++ /dev/null @@ -1,144 +0,0 @@ -package net.minecraft.server; - -import java.util.Random; - -import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit - -public class BlockCocoa extends BlockDirectional implements IBlockFragilePlantElement { - - public BlockCocoa() { - super(Material.PLANT); - this.a(true); - } - - public void a(World world, int i, int j, int k, Random random) { - if (!this.j(world, i, j, k)) { - this.b(world, i, j, k, world.getData(i, j, k), 0); - world.setTypeAndData(i, j, k, getById(0), 0, 2); - } else if (world.random.nextInt(5) == 0) { - int l = world.getData(i, j, k); - int i1 = c(l); - - if (i1 < 2) { - ++i1; - // CraftBukkit - CraftEventFactory.handleBlockGrowEvent(world, i, j, k, this, i1 << 2 | l(l)); - } - } - } - - public boolean j(World world, int i, int j, int k) { - int l = l(world.getData(i, j, k)); - - i += Direction.a[l]; - k += Direction.b[l]; - Block block = world.getType(i, j, k); - - return block == Blocks.LOG && BlockLogAbstract.c(world.getData(i, j, k)) == 3; - } - - public int b() { - return 28; - } - - public boolean d() { - return false; - } - - public boolean c() { - return false; - } - - public AxisAlignedBB a(World world, int i, int j, int k) { - this.updateShape(world, i, j, k); - return super.a(world, i, j, k); - } - - public void updateShape(IBlockAccess iblockaccess, int i, int j, int k) { - int l = iblockaccess.getData(i, j, k); - int i1 = l(l); - int j1 = c(l); - int k1 = 4 + j1 * 2; - int l1 = 5 + j1 * 2; - float f = (float) k1 / 2.0F; - - switch (i1) { - case 0: - this.a((8.0F - f) / 16.0F, (12.0F - (float) l1) / 16.0F, (15.0F - (float) k1) / 16.0F, (8.0F + f) / 16.0F, 0.75F, 0.9375F); - break; - - case 1: - this.a(0.0625F, (12.0F - (float) l1) / 16.0F, (8.0F - f) / 16.0F, (1.0F + (float) k1) / 16.0F, 0.75F, (8.0F + f) / 16.0F); - break; - - case 2: - this.a((8.0F - f) / 16.0F, (12.0F - (float) l1) / 16.0F, 0.0625F, (8.0F + f) / 16.0F, 0.75F, (1.0F + (float) k1) / 16.0F); - break; - - case 3: - this.a((15.0F - (float) k1) / 16.0F, (12.0F - (float) l1) / 16.0F, (8.0F - f) / 16.0F, 0.9375F, 0.75F, (8.0F + f) / 16.0F); - } - } - - public void postPlace(World world, int i, int j, int k, EntityLiving entityliving, ItemStack itemstack) { - int l = ((MathHelper.floor((double) (entityliving.yaw * 4.0F / 360.0F) + 0.5D) & 3) + 0) % 4; - - world.setData(i, j, k, l, 2); - } - - public int getPlacedData(World world, int i, int j, int k, int l, float f, float f1, float f2, int i1) { - if (l == 1 || l == 0) { - l = 2; - } - - return Direction.f[Direction.e[l]]; - } - - public void doPhysics(World world, int i, int j, int k, Block block) { - if (!this.j(world, i, j, k)) { - this.b(world, i, j, k, world.getData(i, j, k), 0); - world.setTypeAndData(i, j, k, getById(0), 0, 2); - } - } - - public static int c(int i) { - return (i & 12) >> 2; - } - - public void dropNaturally(World world, int i, int j, int k, int l, float f, int i1) { - int j1 = c(l); - byte b0 = 1; - - if (j1 >= 2) { - b0 = 3; - } - - for (int k1 = 0; k1 < b0; ++k1) { - this.a(world, i, j, k, new ItemStack(Items.INK_SACK, 1, 3)); - } - } - - public int getDropData(World world, int i, int j, int k) { - return 3; - } - - public boolean a(World world, int i, int j, int k, boolean flag) { - int l = world.getData(i, j, k); - int i1 = c(l); - - return i1 < 2; - } - - public boolean a(World world, Random random, int i, int j, int k) { - return true; - } - - public void b(World world, Random random, int i, int j, int k) { - int l = world.getData(i, j, k); - int i1 = BlockDirectional.l(l); - int j1 = c(l); - - ++j1; - CraftEventFactory.handleBlockGrowEvent(world, i, j, k, this, j1 << 2 | i1); // CraftBukkit - } -} diff --git a/src/main/java/net/minecraft/server/BlockCommand.java b/src/main/java/net/minecraft/server/BlockCommand.java deleted file mode 100644 index c60f0a94..00000000 --- a/src/main/java/net/minecraft/server/BlockCommand.java +++ /dev/null @@ -1,87 +0,0 @@ -package net.minecraft.server; - -import java.util.Random; - -import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit - -public class BlockCommand extends BlockContainer { - - public BlockCommand() { - super(Material.ORE); - } - - public TileEntity a(World world, int i) { - return new TileEntityCommand(); - } - - public void doPhysics(World world, int i, int j, int k, Block block) { - if (!world.isStatic) { - boolean flag = world.isBlockIndirectlyPowered(i, j, k); - int l = world.getData(i, j, k); - boolean flag1 = (l & 1) != 0; - - // CraftBukkit start - org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(i, j, k); - int old = flag1 ? 15 : 0; - int current = flag ? 15 : 0; - - BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bukkitBlock, old, current); - world.getServer().getPluginManager().callEvent(eventRedstone); - // CraftBukkit end - - if (eventRedstone.getNewCurrent() > 0 && !(eventRedstone.getOldCurrent() > 0)) { // CraftBukkit - world.setData(i, j, k, l | 1, 4); - world.a(i, j, k, this, this.a(world)); - } else if (!(eventRedstone.getNewCurrent() > 0) && eventRedstone.getOldCurrent() > 0) { // CraftBukkit - world.setData(i, j, k, l & -2, 4); - } - } - } - - public void a(World world, int i, int j, int k, Random random) { - TileEntity tileentity = world.getTileEntity(i, j, k); - - if (tileentity != null && tileentity instanceof TileEntityCommand) { - CommandBlockListenerAbstract commandblocklistenerabstract = ((TileEntityCommand) tileentity).getCommandBlock(); - - commandblocklistenerabstract.a(world); - world.updateAdjacentComparators(i, j, k, this); - } - } - - public int a(World world) { - return 1; - } - - 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; - } - - public boolean isComplexRedstone() { - return true; - } - - public int g(World world, int i, int j, int k, int l) { - TileEntity tileentity = world.getTileEntity(i, j, k); - - return tileentity != null && tileentity instanceof TileEntityCommand ? ((TileEntityCommand) tileentity).getCommandBlock().g() : 0; - } - - public void postPlace(World world, int i, int j, int k, EntityLiving entityliving, ItemStack itemstack) { - TileEntityCommand tileentitycommand = (TileEntityCommand) world.getTileEntity(i, j, k); - - if (itemstack.hasName()) { - tileentitycommand.getCommandBlock().setName(itemstack.getName()); - } - } - - public int a(Random random) { - return 0; - } -} diff --git a/src/main/java/net/minecraft/server/BlockCrops.java b/src/main/java/net/minecraft/server/BlockCrops.java deleted file mode 100644 index 875181f5..00000000 --- a/src/main/java/net/minecraft/server/BlockCrops.java +++ /dev/null @@ -1,136 +0,0 @@ -package net.minecraft.server; - -import java.util.Random; - -import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit - -public class BlockCrops extends BlockPlant implements IBlockFragilePlantElement { - - protected BlockCrops() { - this.a(true); - float f = 0.5F; - - 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(h); - this.H(); - } - - protected boolean a(Block block) { - return block == Blocks.SOIL; - } - - public void a(World world, int i, int j, int k, Random random) { - super.a(world, i, j, k, random); - if (world.getLightLevel(i, j + 1, k) >= 9) { - int l = world.getData(i, j, k); - - if (l < 7) { - float f = this.n(world, i, j, k); - - if (random.nextInt((int) (25.0F / f) + 1) == 0) { - ++l; - CraftEventFactory.handleBlockGrowEvent(world, i, j, k, this, l); // CraftBukkit - } - } - } - } - - public void m(World world, int i, int j, int k) { - int l = world.getData(i, j, k) + MathHelper.nextInt(world.random, 2, 5); - - if (l > 7) { - l = 7; - } - - CraftEventFactory.handleBlockGrowEvent(world, i, j, k, this, l); // CraftBukkit - } - - private float n(World world, int i, int j, int k) { - float f = 1.0F; - Block block = world.getType(i, j, k - 1); - Block block1 = world.getType(i, j, k + 1); - Block block2 = world.getType(i - 1, j, k); - Block block3 = world.getType(i + 1, j, k); - Block block4 = world.getType(i - 1, j, k - 1); - Block block5 = world.getType(i + 1, j, k - 1); - Block block6 = world.getType(i + 1, j, k + 1); - Block block7 = world.getType(i - 1, j, k + 1); - boolean flag = block2 == this || block3 == this; - boolean flag1 = block == this || block1 == this; - boolean flag2 = block4 == this || block5 == this || block6 == this || block7 == this; - - for (int l = i - 1; l <= i + 1; ++l) { - for (int i1 = k - 1; i1 <= k + 1; ++i1) { - float f1 = 0.0F; - - if (world.getType(l, j - 1, i1) == Blocks.SOIL) { - f1 = 1.0F; - if (world.getData(l, j - 1, i1) > 0) { - f1 = 3.0F; - } - } - - if (l != i || i1 != k) { - f1 /= 4.0F; - } - - f += f1; - } - } - - if (flag2 || flag && flag1) { - f /= 2.0F; - } - - return f; - } - - public int b() { - return 6; - } - - protected Item i() { - return Items.SEEDS; - } - - protected Item P() { - return Items.WHEAT; - } - - 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) { - 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.i(), 1, 0)); - } - } - } - } - } - - public Item getDropType(int i, Random random, int j) { - return i == 7 ? this.P() : this.i(); - } - - public int a(Random random) { - return 1; - } - - public boolean a(World world, int i, int j, int k, boolean flag) { - return world.getData(i, j, k) != 7; - } - - public boolean a(World world, Random random, int i, int j, int k) { - return true; - } - - public void b(World world, Random random, int i, int j, int k) { - this.m(world, i, j, k); - } -} diff --git a/src/main/java/net/minecraft/server/BlockDaylightDetector.java b/src/main/java/net/minecraft/server/BlockDaylightDetector.java deleted file mode 100644 index 96e9c37e..00000000 --- a/src/main/java/net/minecraft/server/BlockDaylightDetector.java +++ /dev/null @@ -1,72 +0,0 @@ -package net.minecraft.server; - -import java.util.Random; - -public class BlockDaylightDetector extends BlockContainer { - - private IIcon[] a = new IIcon[2]; - - public BlockDaylightDetector() { - super(Material.WOOD); - this.a(0.0F, 0.0F, 0.0F, 1.0F, 0.375F, 1.0F); - this.a(CreativeModeTab.d); - } - - public void updateShape(IBlockAccess iblockaccess, int i, int j, int k) { - this.a(0.0F, 0.0F, 0.0F, 1.0F, 0.375F, 1.0F); - } - - public int b(IBlockAccess iblockaccess, int i, int j, int k, int l) { - return iblockaccess.getData(i, j, k); - } - - public void a(World world, int i, int j, int k, Random random) {} - - public void doPhysics(World world, int i, int j, int k, Block block) {} - - public void onPlace(World world, int i, int j, int k) {} - - public void e(World world, int i, int j, int k) { - if (!world.worldProvider.g) { - int l = world.getData(i, j, k); - int i1 = world.b(EnumSkyBlock.SKY, i, j, k) - world.j; - float f = world.d(1.0F); - - if (f < 3.1415927F) { - f += (0.0F - f) * 0.2F; - } else { - f += (6.2831855F - f) * 0.2F; - } - - i1 = Math.round((float) i1 * MathHelper.cos(f)); - if (i1 < 0) { - i1 = 0; - } - - if (i1 > 15) { - i1 = 15; - } - - if (l != i1) { - i1 = org.bukkit.craftbukkit.event.CraftEventFactory.callRedstoneChange(world, i, j, k, l, i1).getNewCurrent(); // CraftBukkit - Call BlockRedstoneEvent - world.setData(i, j, k, i1, 3); - } - } - } - - public boolean d() { - return false; - } - - public boolean c() { - return false; - } - - public boolean isPowerSource() { - return true; - } - - public TileEntity a(World world, int i) { - return new TileEntityLightDetector(); - } -} diff --git a/src/main/java/net/minecraft/server/BlockDiodeAbstract.java b/src/main/java/net/minecraft/server/BlockDiodeAbstract.java deleted file mode 100644 index ec581e0f..00000000 --- a/src/main/java/net/minecraft/server/BlockDiodeAbstract.java +++ /dev/null @@ -1,259 +0,0 @@ -package net.minecraft.server; - -import java.util.Random; - -import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit - -public abstract class BlockDiodeAbstract extends BlockDirectional { - - protected final boolean a; - - protected BlockDiodeAbstract(boolean flag) { - super(Material.ORIENTABLE); - this.a = flag; - this.a(0.0F, 0.0F, 0.0F, 1.0F, 0.125F, 1.0F); - } - - public boolean d() { - return false; - } - - public boolean canPlace(World world, int i, int j, int k) { - return !World.a((IBlockAccess) world, i, j - 1, k) ? false : super.canPlace(world, i, j, k); - } - - public boolean j(World world, int i, int j, int k) { - return !World.a((IBlockAccess) world, i, j - 1, k) ? false : super.j(world, i, j, k); - } - - public void a(World world, int i, int j, int k, Random random) { - int l = world.getData(i, j, k); - - if (!this.g((IBlockAccess) world, i, j, k, l)) { // CraftBukkit - Cast world to IBlockAccess to call the right method. - boolean flag = this.a(world, i, j, k, l); - - if (this.a && !flag) { - // CraftBukkit start - if (CraftEventFactory.callRedstoneChange(world, i, j, k, 15, 0).getNewCurrent() != 0) { - return; - } - // CraftBukkit end - - world.setTypeAndData(i, j, k, this.i(), l, 2); - } else if (!this.a) { - // CraftBukkit start - if (CraftEventFactory.callRedstoneChange(world, i, j, k, 0, 15).getNewCurrent() != 15) { - return; - } - // CraftBukkit end - - world.setTypeAndData(i, j, k, this.e(), l, 2); - if (!flag) { - world.a(i, j, k, this.e(), this.k(l), -1); - } - } - } - } - - public int b() { - return 36; - } - - protected boolean c(int i) { - return this.a; - } - - public int c(IBlockAccess iblockaccess, int i, int j, int k, int l) { - return this.b(iblockaccess, i, j, k, l); - } - - public int b(IBlockAccess iblockaccess, int i, int j, int k, int l) { - int i1 = iblockaccess.getData(i, j, k); - - if (!this.c(i1)) { - return 0; - } else { - int j1 = l(i1); - - return j1 == 0 && l == 3 ? this.f(iblockaccess, i, j, k, i1) : (j1 == 1 && l == 4 ? this.f(iblockaccess, i, j, k, i1) : (j1 == 2 && l == 2 ? this.f(iblockaccess, i, j, k, i1) : (j1 == 3 && l == 5 ? this.f(iblockaccess, i, j, k, i1) : 0))); - } - } - - public void doPhysics(World world, int i, int j, int k, Block block) { - if (!this.j(world, i, j, k)) { - this.b(world, i, j, k, world.getData(i, j, k), 0); - world.setAir(i, j, k); - world.applyPhysics(i + 1, j, k, this); - world.applyPhysics(i - 1, j, k, this); - world.applyPhysics(i, j, k + 1, this); - world.applyPhysics(i, j, k - 1, this); - world.applyPhysics(i, j - 1, k, this); - world.applyPhysics(i, j + 1, k, this); - } else { - this.b(world, i, j, k, block); - } - } - - protected void b(World world, int i, int j, int k, Block block) { - int l = world.getData(i, j, k); - - if (!this.g((IBlockAccess) world, i, j, k, l)) { // CraftBukkit - Cast world to IBlockAccess to call the right method. - boolean flag = this.a(world, i, j, k, l); - - if ((this.a && !flag || !this.a && flag) && !world.a(i, j, k, (Block) this)) { - byte b0 = -1; - - if (this.i(world, i, j, k, l)) { - b0 = -3; - } else if (this.a) { - b0 = -2; - } - - world.a(i, j, k, this, this.b(l), b0); - } - } - } - - public boolean g(IBlockAccess iblockaccess, int i, int j, int k, int l) { - return false; - } - - protected boolean a(World world, int i, int j, int k, int l) { - return this.h(world, i, j, k, l) > 0; - } - - protected int h(World world, int i, int j, int k, int l) { - int i1 = l(l); - int j1 = i + Direction.a[i1]; - int k1 = k + Direction.b[i1]; - int l1 = world.getBlockFacePower(j1, j, k1, Direction.d[i1]); - - return l1 >= 15 ? l1 : Math.max(l1, world.getType(j1, j, k1) == Blocks.REDSTONE_WIRE ? world.getData(j1, j, k1) : 0); - } - - protected int h(IBlockAccess iblockaccess, int i, int j, int k, int l) { - int i1 = l(l); - - switch (i1) { - case 0: - case 2: - return Math.max(this.i(iblockaccess, i - 1, j, k, 4), this.i(iblockaccess, i + 1, j, k, 5)); - - case 1: - case 3: - return Math.max(this.i(iblockaccess, i, j, k + 1, 3), this.i(iblockaccess, i, j, k - 1, 2)); - - default: - return 0; - } - } - - protected int i(IBlockAccess iblockaccess, int i, int j, int k, int l) { - Block block = iblockaccess.getType(i, j, k); - - return this.a(block) ? (block == Blocks.REDSTONE_WIRE ? iblockaccess.getData(i, j, k) : iblockaccess.getBlockPower(i, j, k, l)) : 0; - } - - public boolean isPowerSource() { - return true; - } - - public void postPlace(World world, int i, int j, int k, EntityLiving entityliving, ItemStack itemstack) { - int l = ((MathHelper.floor((double) (entityliving.yaw * 4.0F / 360.0F) + 0.5D) & 3) + 2) % 4; - - world.setData(i, j, k, l, 3); - boolean flag = this.a(world, i, j, k, l); - - if (flag) { - world.a(i, j, k, this, 1); - } - } - - public void onPlace(World world, int i, int j, int k) { - this.e(world, i, j, k); - } - - protected void e(World world, int i, int j, int k) { - int l = l(world.getData(i, j, k)); - - if (l == 1) { - world.e(i + 1, j, k, this); - world.b(i + 1, j, k, this, 4); - } - - if (l == 3) { - world.e(i - 1, j, k, this); - world.b(i - 1, j, k, this, 5); - } - - if (l == 2) { - world.e(i, j, k + 1, this); - world.b(i, j, k + 1, this, 2); - } - - if (l == 0) { - world.e(i, j, k - 1, this); - world.b(i, j, k - 1, this, 3); - } - } - - public void postBreak(World world, int i, int j, int k, int l) { - if (this.a) { - world.applyPhysics(i + 1, j, k, this); - world.applyPhysics(i - 1, j, k, this); - world.applyPhysics(i, j, k + 1, this); - world.applyPhysics(i, j, k - 1, this); - world.applyPhysics(i, j - 1, k, this); - world.applyPhysics(i, j + 1, k, this); - } - - super.postBreak(world, i, j, k, l); - } - - public boolean c() { - return false; - } - - protected boolean a(Block block) { - return block.isPowerSource(); - } - - protected int f(IBlockAccess iblockaccess, int i, int j, int k, int l) { - return 15; - } - - public static boolean d(Block block) { - return Blocks.DIODE_OFF.e(block) || Blocks.REDSTONE_COMPARATOR_OFF.e(block); - } - - public boolean e(Block block) { - return block == this.e() || block == this.i(); - } - - public boolean i(World world, int i, int j, int k, int l) { - int i1 = l(l); - - if (d(world.getType(i - Direction.a[i1], j, k - Direction.b[i1]))) { - int j1 = world.getData(i - Direction.a[i1], j, k - Direction.b[i1]); - int k1 = l(j1); - - return k1 != i1; - } else { - return false; - } - } - - protected int k(int i) { - return this.b(i); - } - - protected abstract int b(int i); - - protected abstract BlockDiodeAbstract e(); - - protected abstract BlockDiodeAbstract i(); - - public boolean c(Block block) { - return this.e(block); - } -} diff --git a/src/main/java/net/minecraft/server/BlockDispenser.java b/src/main/java/net/minecraft/server/BlockDispenser.java deleted file mode 100644 index 9450df9b..00000000 --- a/src/main/java/net/minecraft/server/BlockDispenser.java +++ /dev/null @@ -1,189 +0,0 @@ -package net.minecraft.server; - -import java.util.Random; - -public class BlockDispenser extends BlockContainer { - - public static final IRegistry a = new RegistryDefault(new DispenseBehaviorItem()); - protected Random b = new Random(); - public static boolean eventFired = false; // CraftBukkit - - protected BlockDispenser() { - super(Material.STONE); - this.a(CreativeModeTab.d); - } - - public int a(World world) { - return 4; - } - - public void onPlace(World world, int i, int j, int k) { - super.onPlace(world, i, j, k); - this.m(world, i, j, k); - } - - private void m(World world, int i, int j, int k) { - if (!world.isStatic) { - Block block = world.getType(i, j, k - 1); - Block block1 = world.getType(i, j, k + 1); - Block block2 = world.getType(i - 1, j, k); - Block block3 = world.getType(i + 1, j, k); - byte b0 = 3; - - if (block.j() && !block1.j()) { - b0 = 3; - } - - if (block1.j() && !block.j()) { - b0 = 2; - } - - if (block2.j() && !block3.j()) { - b0 = 5; - } - - if (block3.j() && !block2.j()) { - b0 = 4; - } - - world.setData(i, j, k, b0, 2); - } - } - - public boolean interact(World world, int i, int j, int k, EntityHuman entityhuman, int l, float f, float f1, float f2) { - if (world.isStatic) { - return true; - } else { - TileEntityDispenser tileentitydispenser = (TileEntityDispenser) world.getTileEntity(i, j, k); - - if (tileentitydispenser != null) { - entityhuman.openDispenser(tileentitydispenser); - } - - return true; - } - } - - // CraftBukkit - protected -> 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 l = tileentitydispenser.i(); - - if (l < 0) { - world.triggerEffect(1001, i, j, k, 0); - } else { - ItemStack itemstack = tileentitydispenser.getItem(l); - IDispenseBehavior idispensebehavior = this.a(itemstack); - - if (idispensebehavior != IDispenseBehavior.a) { - ItemStack itemstack1 = idispensebehavior.a(sourceblock, itemstack); - eventFired = false; // CraftBukkit - reset event status - - tileentitydispenser.setItem(l, itemstack1.count == 0 ? null : itemstack1); - } - } - } - } - - protected IDispenseBehavior a(ItemStack itemstack) { - return (IDispenseBehavior) a.get(itemstack.getItem()); - } - - public void doPhysics(World world, int i, int j, int k, Block block) { - boolean flag = world.isBlockIndirectlyPowered(i, j, k) || world.isBlockIndirectlyPowered(i, j + 1, k); - int l = world.getData(i, j, k); - boolean flag1 = (l & 8) != 0; - - if (flag && !flag1) { - world.a(i, j, k, this, this.a(world)); - world.setData(i, j, k, l | 8, 4); - } else if (!flag && flag1) { - world.setData(i, j, k, l & -9, 4); - } - } - - public void a(World world, int i, int j, int k, Random random) { - if (!world.isStatic) { - this.dispense(world, i, j, k); - } - } - - public TileEntity a(World world, int i) { - return new TileEntityDispenser(); - } - - public void postPlace(World world, int i, int j, int k, EntityLiving entityliving, ItemStack itemstack) { - int l = BlockPiston.a(world, i, j, k, entityliving); - - world.setData(i, j, k, l, 2); - if (itemstack.hasName()) { - ((TileEntityDispenser) world.getTileEntity(i, j, k)).a(itemstack.getName()); - } - } - - public void remove(World world, int i, int j, int k, Block block, int l) { - TileEntityDispenser tileentitydispenser = (TileEntityDispenser) world.getTileEntity(i, j, k); - - if (tileentitydispenser != null) { - for (int i1 = 0; i1 < tileentitydispenser.getSize(); ++i1) { - ItemStack itemstack = tileentitydispenser.getItem(i1); - - if (itemstack != null) { - 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 j1 = this.b.nextInt(21) + 10; - - if (j1 > itemstack.count) { - j1 = itemstack.count; - } - - itemstack.count -= j1; - EntityItem entityitem = new EntityItem(world, (double) ((float) i + f), (double) ((float) j + f1), (double) ((float) k + f2), new ItemStack(itemstack.getItem(), j1, itemstack.getData())); - - if (itemstack.hasTag()) { - entityitem.getItemStack().setTag((NBTTagCompound) itemstack.getTag().clone()); - } - - float f3 = 0.05F; - - 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); - } - } - } - - world.updateAdjacentComparators(i, j, k, block); - } - - super.remove(world, i, j, k, block, l); - } - - public static IPosition a(ISourceBlock isourceblock) { - EnumFacing enumfacing = b(isourceblock.h()); - double d0 = isourceblock.getX() + 0.7D * (double) enumfacing.getAdjacentX(); - double d1 = isourceblock.getY() + 0.7D * (double) enumfacing.getAdjacentY(); - double d2 = isourceblock.getZ() + 0.7D * (double) enumfacing.getAdjacentZ(); - - return new Position(d0, d1, d2); - } - - public static EnumFacing b(int i) { - return EnumFacing.a(i & 7); - } - - public boolean isComplexRedstone() { - return true; - } - - public int g(World world, int i, int j, int k, int l) { - return Container.b((IInventory) world.getTileEntity(i, j, k)); - } -} diff --git a/src/main/java/net/minecraft/server/BlockDoor.java b/src/main/java/net/minecraft/server/BlockDoor.java deleted file mode 100644 index 9c3ae2e1..00000000 --- a/src/main/java/net/minecraft/server/BlockDoor.java +++ /dev/null @@ -1,240 +0,0 @@ -package net.minecraft.server; - -import java.util.Random; - -import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit - -public class BlockDoor extends Block { - - protected BlockDoor(Material material) { - super(material); - float f = 0.5F; - float f1 = 1.0F; - - this.a(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f1, 0.5F + f); - } - - public boolean c() { - return false; - } - - public boolean b(IBlockAccess iblockaccess, int i, int j, int k) { - int l = this.g(iblockaccess, i, j, k); - - return (l & 4) != 0; - } - - public boolean d() { - return false; - } - - public int b() { - return 7; - } - - public AxisAlignedBB a(World world, int i, int j, int k) { - this.updateShape(world, i, j, k); - return super.a(world, i, j, k); - } - - public void updateShape(IBlockAccess iblockaccess, int i, int j, int k) { - this.b(this.g(iblockaccess, i, j, k)); - } - - public int e(IBlockAccess iblockaccess, int i, int j, int k) { - return this.g(iblockaccess, i, j, k) & 3; - } - - public boolean f(IBlockAccess iblockaccess, int i, int j, int k) { - return (this.g(iblockaccess, i, j, k) & 4) != 0; - } - - private void b(int i) { - float f = 0.1875F; - - this.a(0.0F, 0.0F, 0.0F, 1.0F, 2.0F, 1.0F); - int j = i & 3; - boolean flag = (i & 4) != 0; - boolean flag1 = (i & 16) != 0; - - if (j == 0) { - if (flag) { - if (!flag1) { - this.a(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f); - } else { - this.a(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F); - } - } else { - this.a(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F); - } - } else if (j == 1) { - if (flag) { - if (!flag1) { - this.a(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); - } else { - this.a(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F); - } - } else { - this.a(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f); - } - } else if (j == 2) { - if (flag) { - if (!flag1) { - this.a(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F); - } else { - this.a(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f); - } - } else { - this.a(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); - } - } else if (j == 3) { - if (flag) { - if (!flag1) { - this.a(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F); - } else { - this.a(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); - } - } else { - this.a(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.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) { - return true; - } else { - int i1 = this.g(world, i, j, k); - int j1 = i1 & 7; - - j1 ^= 4; - if ((i1 & 8) == 0) { - world.setData(i, j, k, j1, 2); - world.c(i, j, k, i, j, k); - } else { - world.setData(i, j - 1, k, j1, 2); - world.c(i, j - 1, k, i, j, k); - } - - world.a(entityhuman, 1003, i, j, k, 0); - return true; - } - } - - public void setDoor(World world, int i, int j, int k, boolean flag) { - int l = this.g(world, i, j, k); - boolean flag1 = (l & 4) != 0; - - if (flag1 != flag) { - int i1 = l & 7; - - i1 ^= 4; - if ((l & 8) == 0) { - world.setData(i, j, k, i1, 2); - world.c(i, j, k, i, j, k); - } else { - world.setData(i, j - 1, k, i1, 2); - world.c(i, j - 1, k, i, j, k); - } - - world.a((EntityHuman) null, 1003, i, j, k, 0); - } - } - - public void doPhysics(World world, int i, int j, int k, Block block) { - int l = world.getData(i, j, k); - - if ((l & 8) == 0) { - boolean flag = false; - - if (world.getType(i, j + 1, k) != this) { - world.setAir(i, j, k); - flag = true; - } - - if (!World.a((IBlockAccess) world, i, j - 1, k)) { - world.setAir(i, j, k); - flag = true; - if (world.getType(i, j + 1, k) == this) { - world.setAir(i, j + 1, k); - } - } - - if (flag) { - if (!world.isStatic) { - this.b(world, i, j, k, l, 0); - } - // CraftBukkit start - } else if (block.isPowerSource()) { - org.bukkit.World bworld = world.getWorld(); - org.bukkit.block.Block bukkitBlock = bworld.getBlockAt(i, j, k); - org.bukkit.block.Block blockTop = bworld.getBlockAt(i, j + 1, k); - - int power = bukkitBlock.getBlockPower(); - int powerTop = blockTop.getBlockPower(); - if (powerTop > power) power = powerTop; - int oldPower = (world.getData(i, j, k) & 4) > 0 ? 15 : 0; - - if (oldPower == 0 ^ power == 0) { - BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bukkitBlock, oldPower, power); - world.getServer().getPluginManager().callEvent(eventRedstone); - - this.setDoor(world, i, j, k, eventRedstone.getNewCurrent() > 0); - } - // CraftBukkit end - } - } else { - if (world.getType(i, j - 1, k) != this) { - world.setAir(i, j, k); - } - - if (block != this) { - this.doPhysics(world, i, j - 1, k, block); - } - } - } - - public Item getDropType(int i, Random random, int j) { - return (i & 8) != 0 ? null : (this.material == Material.ORE ? Items.IRON_DOOR : Items.WOOD_DOOR); - } - - public MovingObjectPosition a(World world, int i, int j, int k, Vec3D vec3d, Vec3D vec3d1) { - this.updateShape(world, i, j, k); - return super.a(world, i, j, k, vec3d, vec3d1); - } - - public boolean canPlace(World world, int i, int j, int k) { - return j >= 255 ? false : World.a((IBlockAccess) world, i, j - 1, k) && super.canPlace(world, i, j, k) && super.canPlace(world, i, j + 1, k); - } - - public int h() { - return 1; - } - - public int g(IBlockAccess iblockaccess, int i, int j, int k) { - int l = iblockaccess.getData(i, j, k); - boolean flag = (l & 8) != 0; - int i1; - int j1; - - if (flag) { - i1 = iblockaccess.getData(i, j - 1, k); - j1 = l; - } else { - i1 = l; - j1 = iblockaccess.getData(i, j + 1, k); - } - - boolean flag1 = (j1 & 1) != 0; - - return i1 & 7 | (flag ? 8 : 0) | (flag1 ? 16 : 0); - } - - public void a(World world, int i, int j, int k, int l, EntityHuman entityhuman) { - if (entityhuman.abilities.canInstantlyBuild && (l & 8) != 0 && world.getType(i, j - 1, k) == this) { - world.setAir(i, j - 1, k); - } - } -} diff --git a/src/main/java/net/minecraft/server/BlockDragonEgg.java b/src/main/java/net/minecraft/server/BlockDragonEgg.java deleted file mode 100644 index b1c3f10e..00000000 --- a/src/main/java/net/minecraft/server/BlockDragonEgg.java +++ /dev/null @@ -1,121 +0,0 @@ -package net.minecraft.server; - -import java.util.Random; - -import org.bukkit.event.block.BlockFromToEvent; // CraftBukkit - -public class BlockDragonEgg extends Block { - - public BlockDragonEgg() { - super(Material.DRAGON_EGG); - this.a(0.0625F, 0.0F, 0.0625F, 0.9375F, 1.0F, 0.9375F); - } - - public void onPlace(World world, int i, int j, int k) { - world.a(i, j, k, this, this.a(world)); - } - - public void doPhysics(World world, int i, int j, int k, Block block) { - world.a(i, j, k, this, this.a(world)); - } - - public void a(World world, int i, int j, int k, Random random) { - this.e(world, i, j, k); - } - - private void e(World world, int i, int j, int k) { - if (BlockFalling.canFall(world, i, j - 1, k) && j >= 0) { - byte b0 = 32; - - if (!BlockFalling.instaFall && world.b(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, world.getData(i, j, k)); - - world.addEntity(entityfallingblock); - } else { - world.setAir(i, j, k); - - while (BlockFalling.canFall(world, i, j - 1, k) && j > 0) { - --j; - } - - if (j > 0) { - world.setTypeAndData(i, j, k, this, 0, 2); - } - } - } - } - - public boolean interact(World world, int i, int j, int k, EntityHuman entityhuman, int l, float f, float f1, float f2) { - this.m(world, i, j, k); - return true; - } - - public void attack(World world, int i, int j, int k, EntityHuman entityhuman) { - this.m(world, i, j, k); - } - - private void m(World world, int i, int j, int k) { - if (world.getType(i, j, k) == this) { - for (int l = 0; l < 1000; ++l) { - int i1 = i + world.random.nextInt(16) - world.random.nextInt(16); - int j1 = j + world.random.nextInt(8) - world.random.nextInt(8); - int k1 = k + world.random.nextInt(16) - world.random.nextInt(16); - - if (world.getType(i1, j1, k1).material == Material.AIR) { - // CraftBukkit start - org.bukkit.block.Block from = world.getWorld().getBlockAt(i, j, k); - org.bukkit.block.Block to = world.getWorld().getBlockAt(i1, j1, k1); - BlockFromToEvent event = new BlockFromToEvent(from, to); - org.bukkit.Bukkit.getPluginManager().callEvent(event); - - if (event.isCancelled()) { - return; - } - - i1 = event.getToBlock().getX(); - j1 = event.getToBlock().getY(); - k1 = event.getToBlock().getZ(); - // CraftBukkit end - - if (!world.isStatic) { - world.setTypeAndData(i1, j1, k1, this, world.getData(i, j, k), 2); - world.setAir(i, j, k); - } else { - short short1 = 128; - - for (int l1 = 0; l1 < short1; ++l1) { - double d0 = world.random.nextDouble(); - float f = (world.random.nextFloat() - 0.5F) * 0.2F; - float f1 = (world.random.nextFloat() - 0.5F) * 0.2F; - float f2 = (world.random.nextFloat() - 0.5F) * 0.2F; - double d1 = (double) i1 + (double) (i - i1) * d0 + (world.random.nextDouble() - 0.5D) * 1.0D + 0.5D; - 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.addParticle("portal", d1, d2, d3, (double) f, (double) f1, (double) f2); - } - } - - return; - } - } - } - } - - public int a(World world) { - return 5; - } - - public boolean c() { - return false; - } - - public boolean d() { - return false; - } - - public int b() { - return 27; - } -} diff --git a/src/main/java/net/minecraft/server/BlockDropper.java b/src/main/java/net/minecraft/server/BlockDropper.java deleted file mode 100644 index 039afd39..00000000 --- a/src/main/java/net/minecraft/server/BlockDropper.java +++ /dev/null @@ -1,75 +0,0 @@ -package net.minecraft.server; - -// CraftBukkit start -import org.bukkit.craftbukkit.inventory.CraftItemStack; -import org.bukkit.event.inventory.InventoryMoveItemEvent; -// CraftBukkit end - -public class BlockDropper extends BlockDispenser { - - private final IDispenseBehavior P = new DispenseBehaviorItem(); - - public BlockDropper() {} - - protected IDispenseBehavior a(ItemStack itemstack) { - return this.P; - } - - public TileEntity a(World world, int i) { - return new TileEntityDropper(); - } - - public void dispense(World world, int i, int j, int k) { // CraftBukkit - protected -> public - SourceBlock sourceblock = new SourceBlock(world, i, j, k); - TileEntityDispenser tileentitydispenser = (TileEntityDispenser) sourceblock.getTileEntity(); - - if (tileentitydispenser != null) { - int l = tileentitydispenser.i(); - - if (l < 0) { - world.triggerEffect(1001, i, j, k, 0); - } else { - ItemStack itemstack = tileentitydispenser.getItem(l); - int i1 = world.getData(i, j, k) & 7; - IInventory iinventory = TileEntityHopper.getInventoryAt(world, (double) (i + Facing.b[i1]), (double) (j + Facing.c[i1]), (double) (k + Facing.d[i1])); - ItemStack itemstack1; - - if (iinventory != null) { - // CraftBukkit start - Fire event when pushing items into other inventories - CraftItemStack oitemstack = CraftItemStack.asCraftMirror(itemstack.cloneItemStack().a(1)); - - org.bukkit.inventory.Inventory destinationInventory; - // Have to special case large chests as they work oddly - if (iinventory instanceof InventoryLargeChest) { - destinationInventory = new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest((InventoryLargeChest) iinventory); - } else { - destinationInventory = iinventory.getOwner().getInventory(); - } - - InventoryMoveItemEvent event = new InventoryMoveItemEvent(tileentitydispenser.getOwner().getInventory(), oitemstack.clone(), destinationInventory, true); - world.getServer().getPluginManager().callEvent(event); - if (event.isCancelled()) { - return; - } - itemstack1 = TileEntityHopper.addItem(iinventory, CraftItemStack.asNMSCopy(event.getItem()), Facing.OPPOSITE_FACING[i1]); - if (event.getItem().equals(oitemstack) && itemstack1 == null) { - // CraftBukkit end - itemstack1 = itemstack.cloneItemStack(); - if (--itemstack1.count == 0) { - itemstack1 = null; - } - } else { - itemstack1 = itemstack.cloneItemStack(); - } - } else { - itemstack1 = this.P.a(sourceblock, itemstack); - if (itemstack1 != null && itemstack1.count == 0) { - itemstack1 = null; - } - } - - tileentitydispenser.setItem(l, itemstack1); - } - } - } -} diff --git a/src/main/java/net/minecraft/server/BlockEnderPortal.java b/src/main/java/net/minecraft/server/BlockEnderPortal.java deleted file mode 100644 index 0b24c153..00000000 --- a/src/main/java/net/minecraft/server/BlockEnderPortal.java +++ /dev/null @@ -1,66 +0,0 @@ -package net.minecraft.server; - -import java.util.List; -import java.util.Random; - -import org.bukkit.event.entity.EntityPortalEnterEvent; // CraftBukkit - -public class BlockEnderPortal extends BlockContainer { - - public static boolean a; - - protected BlockEnderPortal(Material material) { - super(material); - this.a(1.0F); - } - - public TileEntity a(World world, int i) { - return new TileEntityEnderPortal(); - } - - public void updateShape(IBlockAccess iblockaccess, int i, int j, int k) { - float f = 0.0625F; - - this.a(0.0F, 0.0F, 0.0F, 1.0F, f, 1.0F); - } - - public void a(World world, int i, int j, int k, AxisAlignedBB axisalignedbb, List list, Entity entity) {} - - public boolean c() { - return false; - } - - public boolean d() { - return false; - } - - public int a(Random random) { - return 0; - } - - public void a(World world, int i, int j, int k, Entity entity) { - if (entity.vehicle == null && entity.passenger == null && !world.isStatic) { - // CraftBukkit start - Entity in portal - EntityPortalEnterEvent event = new EntityPortalEnterEvent(entity.getBukkitEntity(), new org.bukkit.Location(world.getWorld(), i, j, k)); - world.getServer().getPluginManager().callEvent(event); - // CraftBukkit end - entity.b(1); - } - } - - public int b() { - return -1; - } - - public void onPlace(World world, int i, int j, int k) { - if (!a) { - if (world.worldProvider.dimension != 0) { - world.setAir(i, j, k); - } - } - } - - public MaterialMapColor f(int i) { - return MaterialMapColor.J; - } -} diff --git a/src/main/java/net/minecraft/server/BlockFire.java b/src/main/java/net/minecraft/server/BlockFire.java deleted file mode 100644 index 44994a14..00000000 --- a/src/main/java/net/minecraft/server/BlockFire.java +++ /dev/null @@ -1,281 +0,0 @@ -package net.minecraft.server; - -import java.util.Random; - -// CraftBukkit start -import org.bukkit.craftbukkit.event.CraftEventFactory; -import org.bukkit.event.block.BlockBurnEvent; -import org.bukkit.event.block.BlockSpreadEvent; -// CraftBukkit end - -public class BlockFire extends Block { - - private int[] a = new int[256]; - private int[] b = new int[256]; - - protected BlockFire() { - super(Material.FIRE); - this.a(true); - } - - public static void e() { - Blocks.FIRE.a(getId(Blocks.WOOD), 5, 20); - Blocks.FIRE.a(getId(Blocks.WOOD_DOUBLE_STEP), 5, 20); - Blocks.FIRE.a(getId(Blocks.WOOD_STEP), 5, 20); - Blocks.FIRE.a(getId(Blocks.FENCE), 5, 20); - Blocks.FIRE.a(getId(Blocks.WOOD_STAIRS), 5, 20); - Blocks.FIRE.a(getId(Blocks.BIRCH_WOOD_STAIRS), 5, 20); - Blocks.FIRE.a(getId(Blocks.SPRUCE_WOOD_STAIRS), 5, 20); - Blocks.FIRE.a(getId(Blocks.JUNGLE_WOOD_STAIRS), 5, 20); - Blocks.FIRE.a(getId(Blocks.LOG), 5, 5); - Blocks.FIRE.a(getId(Blocks.LOG2), 5, 5); - Blocks.FIRE.a(getId(Blocks.LEAVES), 30, 60); - Blocks.FIRE.a(getId(Blocks.LEAVES2), 30, 60); - Blocks.FIRE.a(getId(Blocks.BOOKSHELF), 30, 20); - Blocks.FIRE.a(getId(Blocks.TNT), 15, 100); - Blocks.FIRE.a(getId(Blocks.LONG_GRASS), 60, 100); - Blocks.FIRE.a(getId(Blocks.DOUBLE_PLANT), 60, 100); - Blocks.FIRE.a(getId(Blocks.YELLOW_FLOWER), 60, 100); - Blocks.FIRE.a(getId(Blocks.RED_ROSE), 60, 100); - Blocks.FIRE.a(getId(Blocks.WOOL), 30, 60); - Blocks.FIRE.a(getId(Blocks.VINE), 15, 100); - Blocks.FIRE.a(getId(Blocks.COAL_BLOCK), 5, 5); - Blocks.FIRE.a(getId(Blocks.HAY_BLOCK), 60, 20); - Blocks.FIRE.a(getId(Blocks.WOOL_CARPET), 60, 20); - } - - public void a(int i, int j, int k) { - this.a[i] = j; - this.b[i] = k; - } - - public AxisAlignedBB a(World world, int i, int j, int k) { - return null; - } - - public boolean c() { - return false; - } - - public boolean d() { - return false; - } - - public int b() { - return 3; - } - - public int a(Random random) { - return 0; - } - - public int a(World world) { - return 30; - } - - public void a(World world, int i, int j, int k, Random random) { - if (world.getGameRules().getBoolean("doFireTick")) { - boolean flag = world.getType(i, j - 1, k) == Blocks.NETHERRACK; - - if (world.worldProvider instanceof WorldProviderTheEnd && world.getType(i, j - 1, k) == Blocks.BEDROCK) { - flag = true; - } - - if (!this.canPlace(world, i, j, k)) { - fireExtinguished(world, i, j, k); // CraftBukkit - invalid place location - } - - if (!flag && world.Q() && (world.isRainingAt(i, j, k) || world.isRainingAt(i - 1, j, k) || world.isRainingAt(i + 1, j, k) || world.isRainingAt(i, j, k - 1) || world.isRainingAt(i, j, k + 1))) { - fireExtinguished(world, i, j, k); // CraftBukkit - extinguished by rain - } else { - int l = world.getData(i, j, k); - - if (l < 15) { - world.setData(i, j, k, l + random.nextInt(3) / 2, 4); - } - - world.a(i, j, k, this, this.a(world) + random.nextInt(10)); - if (!flag && !this.e(world, i, j, k)) { - if (!World.a((IBlockAccess) world, i, j - 1, k) || l > 3) { - fireExtinguished(world, i, j, k); // CraftBukkit - burn out of inflammable block - } - } else if (!flag && !this.e((IBlockAccess) world, i, j - 1, k) && l == 15 && random.nextInt(4) == 0) { - fireExtinguished(world, i, j, k); // CraftBukkit - burn out - } else { - boolean flag1 = world.z(i, j, k); - byte b0 = 0; - - if (flag1) { - b0 = -50; - } - - 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); - - 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.m(world, i1, k1, j1); - - if (i2 > 0) { - int j2 = (i2 + 40 + world.difficulty.a() * 7) / (l + 30); - - if (flag1) { - j2 /= 2; - } - - if (j2 > 0 && random.nextInt(l1) <= j2 && (!world.Q() || !world.isRainingAt(i1, k1, j1)) && !world.isRainingAt(i1 - 1, k1, k) && !world.isRainingAt(i1 + 1, k1, j1) && !world.isRainingAt(i1, k1, j1 - 1) && !world.isRainingAt(i1, k1, j1 + 1)) { - int k2 = l + random.nextInt(5) / 4; - - if (k2 > 15) { - k2 = 15; - } - - // CraftBukkit start - Call to stop spread of fire - if (world.getType(i1, k1, j1) != Blocks.FIRE) { - if (CraftEventFactory.callBlockIgniteEvent(world, i1, k1, j1, i, j, k).isCancelled()) { - continue; - } - - org.bukkit.Server server = world.getServer(); - org.bukkit.World bworld = world.getWorld(); - org.bukkit.block.BlockState blockState = bworld.getBlockAt(i1, k1, j1).getState(); - blockState.setTypeId(Block.getId(this)); - blockState.setData(new org.bukkit.material.MaterialData(Block.getId(this), (byte) k2)); - - BlockSpreadEvent spreadEvent = new BlockSpreadEvent(blockState.getBlock(), bworld.getBlockAt(i, j, k), blockState); - server.getPluginManager().callEvent(spreadEvent); - - if (!spreadEvent.isCancelled()) { - blockState.update(true); - } - } - // CraftBukkit end - } - } - } - } - } - } - } - } - } - } - - 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[Block.getId(world.getType(i, j, k))]; - - if (random.nextInt(l) < j1) { - boolean flag = world.getType(i, j, k) == Blocks.TNT; - - // CraftBukkit start - org.bukkit.block.Block theBlock = world.getWorld().getBlockAt(i, j, k); - - BlockBurnEvent event = new BlockBurnEvent(theBlock); - world.getServer().getPluginManager().callEvent(event); - - if (event.isCancelled()) { - return; - } - // CraftBukkit end - - if (random.nextInt(i1 + 10) < 5 && !world.isRainingAt(i, j, k)) { - int k1 = i1 + random.nextInt(5) / 4; - - if (k1 > 15) { - k1 = 15; - } - - world.setTypeAndData(i, j, k, this, k1, 3); - } else { - world.setAir(i, j, k); - } - - if (flag) { - Blocks.TNT.postBreak(world, i, j, k, 1); - } - } - } - - private boolean e(World world, int i, int j, int k) { - return this.e((IBlockAccess) world, i + 1, j, k) ? true : (this.e((IBlockAccess) world, i - 1, j, k) ? true : (this.e((IBlockAccess) world, i, j - 1, k) ? true : (this.e((IBlockAccess) world, i, j + 1, k) ? true : (this.e((IBlockAccess) world, i, j, k - 1) ? true : this.e((IBlockAccess) world, i, j, k + 1))))); - } - - private int m(World world, int i, int j, int k) { - byte b0 = 0; - - if (!world.isEmpty(i, j, k)) { - return 0; - } else { - int l = this.a(world, i + 1, j, k, b0); - - l = this.a(world, i - 1, j, k, l); - l = this.a(world, i, j - 1, k, l); - l = this.a(world, i, j + 1, k, l); - l = this.a(world, i, j, k - 1, l); - l = this.a(world, i, j, k + 1, l); - return l; - } - } - - public boolean v() { - return false; - } - - public boolean e(IBlockAccess iblockaccess, int i, int j, int k) { - return this.a[Block.getId(iblockaccess.getType(i, j, k))] > 0; - } - - public int a(World world, int i, int j, int k, int l) { - int i1 = this.a[Block.getId(world.getType(i, j, k))]; - - return i1 > l ? i1 : l; - } - - public boolean canPlace(World world, int i, int j, int k) { - return World.a((IBlockAccess) world, i, j - 1, k) || this.e(world, i, j, k); - } - - public void doPhysics(World world, int i, int j, int k, Block block) { - if (!World.a((IBlockAccess) world, i, j - 1, k) && !this.e(world, i, j, k)) { - fireExtinguished(world, i, j, k); // CraftBukkit - fuel block gone - } - } - - public void onPlace(World world, int i, int j, int k) { - if (world.worldProvider.dimension > 0 || !Blocks.PORTAL.e(world, i, j, k)) { - if (!World.a((IBlockAccess) world, i, j - 1, k) && !this.e(world, i, j, k)) { - fireExtinguished(world, i, j, k); // CraftBukkit - fuel block broke - } else { - world.a(i, j, k, this, this.a(world) + world.random.nextInt(10)); - } - } - } - - public MaterialMapColor f(int i) { - return MaterialMapColor.f; - } - - // CraftBukkit start - private void fireExtinguished(World world, int x, int y, int z) { - if (!CraftEventFactory.callBlockFadeEvent(world.getWorld().getBlockAt(x, y, z), Blocks.AIR).isCancelled()) { - world.setAir(x, y, z); - } - } - // CraftBukkit end -} diff --git a/src/main/java/net/minecraft/server/BlockFlowing.java b/src/main/java/net/minecraft/server/BlockFlowing.java deleted file mode 100644 index cdce3ff1..00000000 --- a/src/main/java/net/minecraft/server/BlockFlowing.java +++ /dev/null @@ -1,299 +0,0 @@ -package net.minecraft.server; - -import java.util.Random; - -// CraftBukkit start -import org.bukkit.block.BlockFace; -import org.bukkit.event.block.BlockFromToEvent; -// CraftBukkit end - -public class BlockFlowing extends BlockFluids { - - int a; - boolean[] b = new boolean[4]; - int[] M = new int[4]; - - protected BlockFlowing(Material material) { - super(material); - } - - private void n(World world, int i, int j, int k) { - int l = world.getData(i, j, k); - - world.setTypeAndData(i, j, k, Block.getById(Block.getId(this) + 1), l, 2); - } - - public void a(World world, int i, int j, int k, Random random) { - // CraftBukkit start - org.bukkit.World bworld = world.getWorld(); - org.bukkit.Server server = world.getServer(); - org.bukkit.block.Block source = bworld == null ? null : bworld.getBlockAt(i, j, k); - // CraftBukkit end - - int l = this.e(world, i, j, k); - byte b0 = 1; - - if (this.material == Material.LAVA && !world.worldProvider.f) { - b0 = 2; - } - - boolean flag = true; - int i1 = this.a(world); - int j1; - - if (l > 0) { - byte b1 = -100; - - this.a = 0; - int k1 = this.a(world, i - 1, j, k, b1); - - k1 = this.a(world, i + 1, j, k, k1); - k1 = this.a(world, i, j, k - 1, k1); - k1 = this.a(world, i, j, k + 1, k1); - j1 = k1 + b0; - if (j1 >= 8 || k1 < 0) { - j1 = -1; - } - - if (this.e(world, i, j + 1, k) >= 0) { - int l1 = this.e(world, i, j + 1, k); - - if (l1 >= 8) { - j1 = l1; - } else { - j1 = l1 + 8; - } - } - - if (this.a >= 2 && this.material == Material.WATER) { - if (world.getType(i, j - 1, k).getMaterial().isBuildable()) { - j1 = 0; - } else if (world.getType(i, j - 1, k).getMaterial() == this.material && world.getData(i, j - 1, k) == 0) { - j1 = 0; - } - } - - if (this.material == Material.LAVA && l < 8 && j1 < 8 && j1 > l && random.nextInt(4) != 0) { - i1 *= 4; - } - - if (j1 == l) { - if (flag) { - this.n(world, i, j, k); - } - } else { - l = j1; - if (j1 < 0) { - world.setAir(i, j, k); - } else { - world.setData(i, j, k, j1, 2); - world.a(i, j, k, this, i1); - world.applyPhysics(i, j, k, this); - } - } - } else { - this.n(world, i, j, k); - } - - if (this.q(world, i, j - 1, k)) { - // CraftBukkit start - Send "down" to the server - BlockFromToEvent event = new BlockFromToEvent(source, BlockFace.DOWN); - if (server != null) { - server.getPluginManager().callEvent(event); - } - - if (!event.isCancelled()) { - if (this.material == Material.LAVA && world.getType(i, j - 1, k).getMaterial() == Material.WATER) { - world.setTypeUpdate(i, j - 1, k, Blocks.STONE); - this.fizz(world, i, j - 1, k); - return; - } - - if (l >= 8) { - this.flow(world, i, j - 1, k, l); - } else { - this.flow(world, i, j - 1, k, l + 8); - } - } - // CraftBukkit end - } else if (l >= 0 && (l == 0 || this.p(world, i, j - 1, k))) { - boolean[] aboolean = this.o(world, i, j, k); - - j1 = l + b0; - if (l >= 8) { - j1 = 1; - } - - if (j1 >= 8) { - return; - } - - // CraftBukkit start - All four cardinal directions. Do not change the order! - BlockFace[] faces = new BlockFace[] { BlockFace.WEST, BlockFace.EAST, BlockFace.NORTH, BlockFace.SOUTH }; - int index = 0; - - for (BlockFace currentFace : faces) { - if (aboolean[index]) { - BlockFromToEvent event = new BlockFromToEvent(source, currentFace); - - if (server != null) { - server.getPluginManager().callEvent(event); - } - - if (!event.isCancelled()) { - this.flow(world, i + currentFace.getModX(), j, k + currentFace.getModZ(), j1); - } - } - index++; - } - // CraftBukkit end - } - } - - private void flow(World world, int i, int j, int k, int l) { - if (this.q(world, i, j, k)) { - Block block = world.getType(i, j, k); - - if (this.material == Material.LAVA) { - this.fizz(world, i, j, k); - } else { - block.b(world, i, j, k, world.getData(i, j, k), 0); - } - - world.setTypeAndData(i, j, k, this, l, 3); - } - } - - private int c(World world, int i, int j, int k, int l, int i1) { - int j1 = 1000; - - for (int k1 = 0; k1 < 4; ++k1) { - if ((k1 != 0 || i1 != 1) && (k1 != 1 || i1 != 0) && (k1 != 2 || i1 != 3) && (k1 != 3 || i1 != 2)) { - int l1 = i; - int i2 = k; - - if (k1 == 0) { - l1 = i - 1; - } - - if (k1 == 1) { - ++l1; - } - - if (k1 == 2) { - i2 = k - 1; - } - - if (k1 == 3) { - ++i2; - } - - if (!this.p(world, l1, j, i2) && (world.getType(l1, j, i2).getMaterial() != this.material || world.getData(l1, j, i2) != 0)) { - if (!this.p(world, l1, j - 1, i2)) { - return l; - } - - if (l < 4) { - int j2 = this.c(world, l1, j, i2, l + 1, k1); - - if (j2 < j1) { - j1 = j2; - } - } - } - } - } - - return j1; - } - - private boolean[] o(World world, int i, int j, int k) { - int l; - int i1; - - for (l = 0; l < 4; ++l) { - this.M[l] = 1000; - i1 = i; - int j1 = k; - - if (l == 0) { - i1 = i - 1; - } - - if (l == 1) { - ++i1; - } - - if (l == 2) { - j1 = k - 1; - } - - if (l == 3) { - ++j1; - } - - if (!this.p(world, i1, j, j1) && (world.getType(i1, j, j1).getMaterial() != this.material || world.getData(i1, j, j1) != 0)) { - if (this.p(world, i1, j - 1, j1)) { - this.M[l] = this.c(world, i1, j, j1, 1, l); - } else { - this.M[l] = 0; - } - } - } - - l = this.M[0]; - - for (i1 = 1; i1 < 4; ++i1) { - if (this.M[i1] < l) { - l = this.M[i1]; - } - } - - for (i1 = 0; i1 < 4; ++i1) { - this.b[i1] = this.M[i1] == l; - } - - return this.b; - } - - private boolean p(World world, int i, int j, int k) { - Block block = world.getType(i, j, k); - - return block != Blocks.WOODEN_DOOR && block != Blocks.IRON_DOOR_BLOCK && block != Blocks.SIGN_POST && block != Blocks.LADDER && block != Blocks.SUGAR_CANE_BLOCK ? (block.material == Material.PORTAL ? true : block.material.isSolid()) : true; - } - - protected int a(World world, int i, int j, int k, int l) { - int i1 = this.e(world, i, j, k); - - if (i1 < 0) { - return l; - } else { - if (i1 == 0) { - ++this.a; - } - - if (i1 >= 8) { - i1 = 0; - } - - return l >= 0 && i1 >= l ? l : i1; - } - } - - private boolean q(World world, int i, int j, int k) { - Material material = world.getType(i, j, k).getMaterial(); - - return material == this.material ? false : (material == Material.LAVA ? false : !this.p(world, i, j, k)); - } - - public void onPlace(World world, int i, int j, int k) { - super.onPlace(world, i, j, k); - if (world.getType(i, j, k) == this) { - world.a(i, j, k, this, this.a(world)); - } - } - - public boolean L() { - return true; - } -} diff --git a/src/main/java/net/minecraft/server/BlockGrass.java b/src/main/java/net/minecraft/server/BlockGrass.java deleted file mode 100644 index abd991b4..00000000 --- a/src/main/java/net/minecraft/server/BlockGrass.java +++ /dev/null @@ -1,121 +0,0 @@ -package net.minecraft.server; - -import java.util.Random; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -// CraftBukkit start -import org.bukkit.block.BlockState; -import org.bukkit.craftbukkit.event.CraftEventFactory; -import org.bukkit.craftbukkit.util.CraftMagicNumbers; -import org.bukkit.event.block.BlockSpreadEvent; -import org.bukkit.event.block.BlockFadeEvent; -// CraftBukkit end - -public class BlockGrass extends Block implements IBlockFragilePlantElement { - - private static final Logger a = LogManager.getLogger(); - - protected BlockGrass() { - super(Material.GRASS); - this.a(true); - this.a(CreativeModeTab.b); - } - - public void a(World world, int i, int j, int k, Random random) { - if (!world.isStatic) { - if (world.getLightLevel(i, j + 1, k) < 4 && world.getType(i, j + 1, k).k() > 2) { - // CraftBukkit start - org.bukkit.World bworld = world.getWorld(); - BlockState blockState = bworld.getBlockAt(i, j, k).getState(); - blockState.setType(CraftMagicNumbers.getMaterial(Blocks.DIRT)); - - BlockFadeEvent event = new BlockFadeEvent(blockState.getBlock(), blockState); - world.getServer().getPluginManager().callEvent(event); - - if (!event.isCancelled()) { - blockState.update(true); - } - // CraftBukkit end - } else if (world.getLightLevel(i, j + 1, k) >= 9) { - for (int l = 0; l < 4; ++l) { - int i1 = i + random.nextInt(3) - 1; - int j1 = j + random.nextInt(5) - 3; - int k1 = k + random.nextInt(3) - 1; - Block block = world.getType(i1, j1 + 1, k1); - - if (world.getType(i1, j1, k1) == Blocks.DIRT && world.getData(i1, j1, k1) == 0 && world.getLightLevel(i1, j1 + 1, k1) >= 4 && block.k() <= 2) { - // CraftBukkit start - org.bukkit.World bworld = world.getWorld(); - BlockState blockState = bworld.getBlockAt(i1, j1, k1).getState(); - blockState.setType(CraftMagicNumbers.getMaterial(Blocks.GRASS)); - - BlockSpreadEvent event = new BlockSpreadEvent(blockState.getBlock(), bworld.getBlockAt(i, j, k), blockState); - world.getServer().getPluginManager().callEvent(event); - - if (!event.isCancelled()) { - blockState.update(true); - } - // CraftBukkit end - } - } - } - } - } - - public Item getDropType(int i, Random random, int j) { - return Blocks.DIRT.getDropType(0, random, j); - } - - public boolean a(World world, int i, int j, int k, boolean flag) { - return true; - } - - public boolean a(World world, Random random, int i, int j, int k) { - return true; - } - - public void b(World world, Random random, int i, int j, int k) { - int l = 0; - - while (l < 128) { - int i1 = i; - int j1 = j + 1; - int k1 = k; - int l1 = 0; - - while (true) { - if (l1 < l / 16) { - i1 += random.nextInt(3) - 1; - j1 += (random.nextInt(3) - 1) * random.nextInt(3) / 2; - k1 += random.nextInt(3) - 1; - if (world.getType(i1, j1 - 1, k1) == Blocks.GRASS && !world.getType(i1, j1, k1).r()) { - ++l1; - continue; - } - } else if (world.getType(i1, j1, k1).material == Material.AIR) { - if (random.nextInt(8) != 0) { - if (Blocks.LONG_GRASS.j(world, i1, j1, k1)) { - CraftEventFactory.handleBlockGrowEvent(world, i1, j1, k1, Blocks.LONG_GRASS, 1); // CraftBukkit - } - } else { - String s = world.getBiome(i1, k1).a(random, i1, j1, k1); - - a.debug("Flower in " + world.getBiome(i1, k1).af + ": " + s); - BlockFlowers blockflowers = BlockFlowers.e(s); - - if (blockflowers != null && blockflowers.j(world, i1, j1, k1)) { - int i2 = BlockFlowers.f(s); - - CraftEventFactory.handleBlockGrowEvent(world, i1, j1, k1, blockflowers, i2); // CraftBukkit - } - } - } - - ++l; - break; - } - } - } -} diff --git a/src/main/java/net/minecraft/server/BlockHopper.java b/src/main/java/net/minecraft/server/BlockHopper.java deleted file mode 100644 index b85b72f3..00000000 --- a/src/main/java/net/minecraft/server/BlockHopper.java +++ /dev/null @@ -1,166 +0,0 @@ -package net.minecraft.server; - -import java.util.List; -import java.util.Random; - -public class BlockHopper extends BlockContainer { - - private final Random a = new Random(); - - public BlockHopper() { - super(Material.ORE); - this.a(CreativeModeTab.d); - this.a(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); - } - - public void updateShape(IBlockAccess iblockaccess, int i, int j, int k) { - this.a(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); - } - - public void a(World world, int i, int j, int k, AxisAlignedBB axisalignedbb, List list, Entity entity) { - this.a(0.0F, 0.0F, 0.0F, 1.0F, 0.625F, 1.0F); - super.a(world, i, j, k, axisalignedbb, list, entity); - float f = 0.125F; - - this.a(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F); - super.a(world, i, j, k, axisalignedbb, list, entity); - this.a(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f); - super.a(world, i, j, k, axisalignedbb, list, entity); - this.a(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); - super.a(world, i, j, k, axisalignedbb, list, entity); - this.a(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F); - super.a(world, i, j, k, axisalignedbb, list, entity); - this.a(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); - } - - public int getPlacedData(World world, int i, int j, int k, int l, float f, float f1, float f2, int i1) { - int j1 = Facing.OPPOSITE_FACING[l]; - - if (j1 == 1) { - j1 = 0; - } - - return j1; - } - - public TileEntity a(World world, int i) { - return new TileEntityHopper(); - } - - public void postPlace(World world, int i, int j, int k, EntityLiving entityliving, ItemStack itemstack) { - super.postPlace(world, i, j, k, entityliving, itemstack); - if (itemstack.hasName()) { - TileEntityHopper tileentityhopper = e((IBlockAccess) world, i, j, k); - - tileentityhopper.a(itemstack.getName()); - } - } - - public void onPlace(World world, int i, int j, int k) { - super.onPlace(world, i, j, k); - this.e(world, i, j, k); - } - - public boolean interact(World world, int i, int j, int k, EntityHuman entityhuman, int l, float f, float f1, float f2) { - if (world.isStatic) { - return true; - } else { - TileEntityHopper tileentityhopper = e((IBlockAccess) world, i, j, k); - - if (tileentityhopper != null) { - entityhuman.openHopper(tileentityhopper); - } - - return true; - } - } - - public void doPhysics(World world, int i, int j, int k, Block block) { - this.e(world, i, j, k); - } - - private void e(World world, int i, int j, int k) { - int l = world.getData(i, j, k); - int i1 = b(l); - boolean flag = !world.isBlockIndirectlyPowered(i, j, k); - boolean flag1 = c(l); - - if (flag != flag1) { - world.setData(i, j, k, i1 | (flag ? 0 : 8), 4); - } - } - - public void remove(World world, int i, int j, int k, Block block, int l) { - TileEntityHopper tileentityhopper = (TileEntityHopper) world.getTileEntity(i, j, k); - - if (tileentityhopper != null) { - for (int i1 = 0; i1 < tileentityhopper.getSize(); ++i1) { - ItemStack itemstack = tileentityhopper.getItem(i1); - - if (itemstack != null) { - float f = this.a.nextFloat() * 0.8F + 0.1F; - float f1 = this.a.nextFloat() * 0.8F + 0.1F; - float f2 = this.a.nextFloat() * 0.8F + 0.1F; - - while (itemstack.count > 0) { - int j1 = this.a.nextInt(21) + 10; - - if (j1 > itemstack.count) { - j1 = itemstack.count; - } - - itemstack.count -= j1; - EntityItem entityitem = new EntityItem(world, (double) ((float) i + f), (double) ((float) j + f1), (double) ((float) k + f2), new ItemStack(itemstack.getItem(), j1, itemstack.getData())); - - if (itemstack.hasTag()) { - entityitem.getItemStack().setTag((NBTTagCompound) itemstack.getTag().clone()); - } - - float f3 = 0.05F; - - entityitem.motX = (double) ((float) this.a.nextGaussian() * f3); - entityitem.motY = (double) ((float) this.a.nextGaussian() * f3 + 0.2F); - entityitem.motZ = (double) ((float) this.a.nextGaussian() * f3); - world.addEntity(entityitem); - } - } - } - - world.updateAdjacentComparators(i, j, k, block); - } - - super.remove(world, i, j, k, block, l); - } - - public int b() { - return 38; - } - - public boolean d() { - return false; - } - - public boolean c() { - return false; - } - - public static int b(int i) { - return Math.min(i & 7, 5); // CraftBukkit - Fix AIOOBE in callers - } - - public static boolean c(int i) { - return (i & 8) != 8; - } - - public boolean isComplexRedstone() { - return true; - } - - public int g(World world, int i, int j, int k, int l) { - return Container.b((IInventory) e((IBlockAccess) world, i, j, k)); - } - - public static TileEntityHopper e(IBlockAccess iblockaccess, int i, int j, int k) { - return (TileEntityHopper) iblockaccess.getTileEntity(i, j, k); - } -} diff --git a/src/main/java/net/minecraft/server/BlockIce.java b/src/main/java/net/minecraft/server/BlockIce.java deleted file mode 100644 index 25cb3271..00000000 --- a/src/main/java/net/minecraft/server/BlockIce.java +++ /dev/null @@ -1,65 +0,0 @@ -package net.minecraft.server; - -import java.util.Random; - -public class BlockIce extends BlockHalfTransparent { - - public BlockIce() { - super("ice", Material.ICE, false); - this.frictionFactor = 0.98F; - this.a(true); - this.a(CreativeModeTab.b); - } - - public void a(World world, EntityHuman entityhuman, int i, int j, int k, int l) { - entityhuman.a(StatisticList.MINE_BLOCK_COUNT[Block.getId(this)], 1); - entityhuman.applyExhaustion(0.025F); - if (this.E() && EnchantmentManager.hasSilkTouchEnchantment(entityhuman)) { - ItemStack itemstack = this.j(l); - - if (itemstack != null) { - this.a(world, i, j, k, itemstack); - } - } else { - if (world.worldProvider.f) { - world.setAir(i, j, k); - return; - } - - int i1 = EnchantmentManager.getBonusBlockLootEnchantmentLevel(entityhuman); - - this.b(world, i, j, k, l, i1); - Material material = world.getType(i, j - 1, k).getMaterial(); - - if (material.isSolid() || material.isLiquid()) { - world.setTypeUpdate(i, j, k, Blocks.WATER); - } - } - } - - public int a(Random random) { - return 0; - } - - public void a(World world, int i, int j, int k, Random random) { - if (world.b(EnumSkyBlock.BLOCK, i, j, k) > 11 - this.k()) { - // CraftBukkit start - if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world.getWorld().getBlockAt(i, j, k), world.worldProvider.f ? Blocks.AIR : Blocks.STATIONARY_WATER).isCancelled()) { - return; - } - // CraftBukkit end - - if (world.worldProvider.f) { - world.setAir(i, j, k); - return; - } - - this.b(world, i, j, k, world.getData(i, j, k), 0); - world.setTypeUpdate(i, j, k, Blocks.STATIONARY_WATER); - } - } - - public int h() { - return 0; - } -} diff --git a/src/main/java/net/minecraft/server/BlockLeaves.java b/src/main/java/net/minecraft/server/BlockLeaves.java deleted file mode 100644 index d6afe5b0..00000000 --- a/src/main/java/net/minecraft/server/BlockLeaves.java +++ /dev/null @@ -1,203 +0,0 @@ -package net.minecraft.server; - -import java.util.Random; - -import org.bukkit.event.block.LeavesDecayEvent; // CraftBukkit - -public abstract class BlockLeaves extends BlockTransparent { - - int[] a; - protected IIcon[][] M = new IIcon[2][]; - - public BlockLeaves() { - super(Material.LEAVES, false); - this.a(true); - this.a(CreativeModeTab.c); - this.c(0.2F); - this.g(1); - this.a(h); - } - - public void remove(World world, int i, int j, int k, Block block, int l) { - byte b0 = 1; - int i1 = b0 + 1; - - if (world.b(i - i1, j - i1, k - i1, i + i1, j + i1, k + i1)) { - for (int j1 = -b0; j1 <= b0; ++j1) { - for (int k1 = -b0; k1 <= b0; ++k1) { - for (int l1 = -b0; l1 <= b0; ++l1) { - if (world.getType(i + j1, j + k1, k + l1).getMaterial() == Material.LEAVES) { - int i2 = world.getData(i + j1, j + k1, k + l1); - - world.setData(i + j1, j + k1, k + l1, i2 | 8, 4); - } - } - } - } - } - } - - public void a(World world, int i, int j, int k, Random random) { - if (!world.isStatic) { - int l = world.getData(i, j, k); - - if ((l & 8) != 0 && (l & 4) == 0) { - byte b0 = 4; - int i1 = b0 + 1; - byte b1 = 32; - int j1 = b1 * b1; - int k1 = b1 / 2; - - if (this.a == null) { - this.a = new int[b1 * b1 * b1]; - } - - int l1; - - if (world.b(i - i1, j - i1, k - i1, i + i1, j + i1, k + i1)) { - int i2; - int j2; - - for (l1 = -b0; l1 <= b0; ++l1) { - for (i2 = -b0; i2 <= b0; ++i2) { - for (j2 = -b0; j2 <= b0; ++j2) { - Block block = world.getType(i + l1, j + i2, k + j2); - - if (block != Blocks.LOG && block != Blocks.LOG2) { - if (block.getMaterial() == Material.LEAVES) { - this.a[(l1 + k1) * j1 + (i2 + k1) * b1 + j2 + k1] = -2; - } else { - this.a[(l1 + k1) * j1 + (i2 + k1) * b1 + j2 + k1] = -1; - } - } else { - this.a[(l1 + k1) * j1 + (i2 + k1) * b1 + j2 + k1] = 0; - } - } - } - } - - for (l1 = 1; l1 <= 4; ++l1) { - for (i2 = -b0; i2 <= b0; ++i2) { - for (j2 = -b0; j2 <= b0; ++j2) { - for (int k2 = -b0; k2 <= b0; ++k2) { - if (this.a[(i2 + k1) * j1 + (j2 + k1) * b1 + k2 + k1] == l1 - 1) { - if (this.a[(i2 + k1 - 1) * j1 + (j2 + k1) * b1 + k2 + k1] == -2) { - this.a[(i2 + k1 - 1) * j1 + (j2 + k1) * b1 + k2 + k1] = l1; - } - - if (this.a[(i2 + k1 + 1) * j1 + (j2 + k1) * b1 + k2 + k1] == -2) { - this.a[(i2 + k1 + 1) * j1 + (j2 + k1) * b1 + k2 + k1] = l1; - } - - if (this.a[(i2 + k1) * j1 + (j2 + k1 - 1) * b1 + k2 + k1] == -2) { - this.a[(i2 + k1) * j1 + (j2 + k1 - 1) * b1 + k2 + k1] = l1; - } - - if (this.a[(i2 + k1) * j1 + (j2 + k1 + 1) * b1 + k2 + k1] == -2) { - this.a[(i2 + k1) * j1 + (j2 + k1 + 1) * b1 + k2 + k1] = l1; - } - - if (this.a[(i2 + k1) * j1 + (j2 + k1) * b1 + (k2 + k1 - 1)] == -2) { - this.a[(i2 + k1) * j1 + (j2 + k1) * b1 + (k2 + k1 - 1)] = l1; - } - - if (this.a[(i2 + k1) * j1 + (j2 + k1) * b1 + k2 + k1 + 1] == -2) { - this.a[(i2 + k1) * j1 + (j2 + k1) * b1 + k2 + k1 + 1] = l1; - } - } - } - } - } - } - } - - l1 = this.a[k1 * j1 + k1 * b1 + k1]; - if (l1 >= 0) { - world.setData(i, j, k, l & -9, 4); - } else { - this.e(world, i, j, k); - } - } - } - } - - private void e(World world, int i, int j, int k) { - // CraftBukkit start - LeavesDecayEvent event = new LeavesDecayEvent(world.getWorld().getBlockAt(i, j, k)); - world.getServer().getPluginManager().callEvent(event); - - if (event.isCancelled()) { - return; - } - // CraftBukkit end - - this.b(world, i, j, k, world.getData(i, j, k), 0); - world.setAir(i, j, k); - } - - public int a(Random random) { - return random.nextInt(20) == 0 ? 1 : 0; - } - - public Item getDropType(int i, Random random, int j) { - return Item.getItemOf(Blocks.SAPLING); - } - - public void dropNaturally(World world, int i, int j, int k, int l, float f, int i1) { - if (!world.isStatic) { - int j1 = this.b(l); - - if (i1 > 0) { - j1 -= 2 << i1; - if (j1 < 10) { - j1 = 10; - } - } - - if (world.random.nextInt(j1) == 0) { - Item item = this.getDropType(l, world.random, i1); - - this.a(world, i, j, k, new ItemStack(item, 1, this.getDropData(l))); - } - - j1 = 200; - if (i1 > 0) { - j1 -= 10 << i1; - if (j1 < 40) { - j1 = 40; - } - } - - this.c(world, i, j, k, l, j1); - } - } - - protected void c(World world, int i, int j, int k, int l, int i1) {} - - protected int b(int i) { - return 20; - } - - public void a(World world, EntityHuman entityhuman, int i, int j, int k, int l) { - if (!world.isStatic && entityhuman.bF() != null && entityhuman.bF().getItem() == Items.SHEARS) { - entityhuman.a(StatisticList.MINE_BLOCK_COUNT[Block.getId(this)], 1); - this.a(world, i, j, k, new ItemStack(Item.getItemOf(this), 1, l & 3)); - } else { - super.a(world, entityhuman, i, j, k, l); - } - } - - public int getDropData(int i) { - return i & 3; - } - - public boolean c() { - return !this.P; - } - - protected ItemStack j(int i) { - return new ItemStack(Item.getItemOf(this), 1, i & 3); - } - - public abstract String[] e(); -} diff --git a/src/main/java/net/minecraft/server/BlockLever.java b/src/main/java/net/minecraft/server/BlockLever.java deleted file mode 100644 index e00cea3d..00000000 --- a/src/main/java/net/minecraft/server/BlockLever.java +++ /dev/null @@ -1,278 +0,0 @@ -package net.minecraft.server; - -import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit - -public class BlockLever extends Block { - - protected BlockLever() { - super(Material.ORIENTABLE); - this.a(CreativeModeTab.d); - } - - public AxisAlignedBB a(World world, int i, int j, int k) { - return null; - } - - public boolean c() { - return false; - } - - public boolean d() { - return false; - } - - public int b() { - return 12; - } - - public boolean canPlace(World world, int i, int j, int k, int l) { - return l == 0 && world.getType(i, j + 1, k).r() ? true : (l == 1 && World.a((IBlockAccess) world, i, j - 1, k) ? true : (l == 2 && world.getType(i, j, k + 1).r() ? true : (l == 3 && world.getType(i, j, k - 1).r() ? true : (l == 4 && world.getType(i + 1, j, k).r() ? true : l == 5 && world.getType(i - 1, j, k).r())))); - } - - public boolean canPlace(World world, int i, int j, int k) { - return world.getType(i - 1, j, k).r() ? true : (world.getType(i + 1, j, k).r() ? true : (world.getType(i, j, k - 1).r() ? true : (world.getType(i, j, k + 1).r() ? true : (World.a((IBlockAccess) world, i, j - 1, k) ? true : world.getType(i, j + 1, k).r())))); - } - - public int getPlacedData(World world, int i, int j, int k, int l, float f, float f1, float f2, int i1) { - int j1 = i1 & 8; - int k1 = i1 & 7; - byte b0 = -1; - - if (l == 0 && world.getType(i, j + 1, k).r()) { - b0 = 0; - } - - if (l == 1 && World.a((IBlockAccess) world, i, j - 1, k)) { - b0 = 5; - } - - if (l == 2 && world.getType(i, j, k + 1).r()) { - b0 = 4; - } - - if (l == 3 && world.getType(i, j, k - 1).r()) { - b0 = 3; - } - - if (l == 4 && world.getType(i + 1, j, k).r()) { - b0 = 2; - } - - if (l == 5 && world.getType(i - 1, j, k).r()) { - b0 = 1; - } - - return b0 + j1; - } - - public void postPlace(World world, int i, int j, int k, EntityLiving entityliving, ItemStack itemstack) { - int l = world.getData(i, j, k); - int i1 = l & 7; - int j1 = l & 8; - - if (i1 == b(1)) { - if ((MathHelper.floor((double) (entityliving.yaw * 4.0F / 360.0F) + 0.5D) & 1) == 0) { - world.setData(i, j, k, 5 | j1, 2); - } else { - world.setData(i, j, k, 6 | j1, 2); - } - } else if (i1 == b(0)) { - if ((MathHelper.floor((double) (entityliving.yaw * 4.0F / 360.0F) + 0.5D) & 1) == 0) { - world.setData(i, j, k, 7 | j1, 2); - } else { - world.setData(i, j, k, 0 | j1, 2); - } - } - } - - public static int b(int i) { - switch (i) { - case 0: - return 0; - - case 1: - return 5; - - case 2: - return 4; - - case 3: - return 3; - - case 4: - return 2; - - case 5: - return 1; - - default: - return -1; - } - } - - public void doPhysics(World world, int i, int j, int k, Block block) { - if (this.e(world, i, j, k)) { - int l = world.getData(i, j, k) & 7; - boolean flag = false; - - if (!world.getType(i - 1, j, k).r() && l == 1) { - flag = true; - } - - if (!world.getType(i + 1, j, k).r() && l == 2) { - flag = true; - } - - if (!world.getType(i, j, k - 1).r() && l == 3) { - flag = true; - } - - if (!world.getType(i, j, k + 1).r() && l == 4) { - flag = true; - } - - if (!World.a((IBlockAccess) world, i, j - 1, k) && l == 5) { - flag = true; - } - - if (!World.a((IBlockAccess) world, i, j - 1, k) && l == 6) { - flag = true; - } - - if (!world.getType(i, j + 1, k).r() && l == 0) { - flag = true; - } - - if (!world.getType(i, j + 1, k).r() && l == 7) { - flag = true; - } - - if (flag) { - this.b(world, i, j, k, world.getData(i, j, k), 0); - world.setAir(i, j, k); - } - } - } - - private boolean e(World world, int i, int j, int k) { - if (!this.canPlace(world, i, j, k)) { - this.b(world, i, j, k, world.getData(i, j, k), 0); - world.setAir(i, j, k); - return false; - } else { - return true; - } - } - - public void updateShape(IBlockAccess iblockaccess, int i, int j, int k) { - int l = iblockaccess.getData(i, j, k) & 7; - float f = 0.1875F; - - if (l == 1) { - this.a(0.0F, 0.2F, 0.5F - f, f * 2.0F, 0.8F, 0.5F + f); - } else if (l == 2) { - this.a(1.0F - f * 2.0F, 0.2F, 0.5F - f, 1.0F, 0.8F, 0.5F + f); - } else if (l == 3) { - this.a(0.5F - f, 0.2F, 0.0F, 0.5F + f, 0.8F, f * 2.0F); - } else if (l == 4) { - this.a(0.5F - f, 0.2F, 1.0F - f * 2.0F, 0.5F + f, 0.8F, 1.0F); - } else if (l != 5 && l != 6) { - if (l == 0 || l == 7) { - f = 0.25F; - this.a(0.5F - f, 0.4F, 0.5F - f, 0.5F + f, 1.0F, 0.5F + f); - } - } else { - f = 0.25F; - this.a(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.6F, 0.5F + f); - } - } - - public boolean interact(World world, int i, int j, int k, EntityHuman entityhuman, int l, float f, float f1, float f2) { - if (world.isStatic) { - return true; - } else { - int i1 = world.getData(i, j, k); - int j1 = i1 & 7; - int k1 = 8 - (i1 & 8); - - // CraftBukkit start - Interact Lever - org.bukkit.block.Block block = world.getWorld().getBlockAt(i, j, k); - int old = (k1 != 8) ? 15 : 0; - int current = (k1 == 8) ? 15 : 0; - - BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, old, current); - world.getServer().getPluginManager().callEvent(eventRedstone); - - if ((eventRedstone.getNewCurrent() > 0) != (k1 == 8)) { - return true; - } - // CraftBukkit end - - world.setData(i, j, k, j1 + k1, 3); - 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); - if (j1 == 1) { - world.applyPhysics(i - 1, j, k, this); - } else if (j1 == 2) { - world.applyPhysics(i + 1, j, k, this); - } else if (j1 == 3) { - world.applyPhysics(i, j, k - 1, this); - } else if (j1 == 4) { - world.applyPhysics(i, j, k + 1, this); - } else if (j1 != 5 && j1 != 6) { - if (j1 == 0 || j1 == 7) { - world.applyPhysics(i, j + 1, k, this); - } - } else { - world.applyPhysics(i, j - 1, k, this); - } - - return true; - } - } - - public void remove(World world, int i, int j, int k, Block block, int l) { - if ((l & 8) > 0) { - world.applyPhysics(i, j, k, this); - int i1 = l & 7; - - if (i1 == 1) { - world.applyPhysics(i - 1, j, k, this); - } else if (i1 == 2) { - world.applyPhysics(i + 1, j, k, this); - } else if (i1 == 3) { - world.applyPhysics(i, j, k - 1, this); - } else if (i1 == 4) { - world.applyPhysics(i, j, k + 1, this); - } else if (i1 != 5 && i1 != 6) { - if (i1 == 0 || i1 == 7) { - world.applyPhysics(i, j + 1, k, this); - } - } else { - world.applyPhysics(i, j - 1, k, this); - } - } - - super.remove(world, i, j, k, block, l); - } - - public int b(IBlockAccess iblockaccess, int i, int j, int k, int l) { - return (iblockaccess.getData(i, j, k) & 8) > 0 ? 15 : 0; - } - - public int c(IBlockAccess iblockaccess, int i, int j, int k, int l) { - int i1 = iblockaccess.getData(i, j, k); - - if ((i1 & 8) == 0) { - return 0; - } else { - int j1 = i1 & 7; - - return j1 == 0 && l == 0 ? 15 : (j1 == 7 && l == 0 ? 15 : (j1 == 6 && l == 1 ? 15 : (j1 == 5 && l == 1 ? 15 : (j1 == 4 && l == 2 ? 15 : (j1 == 3 && l == 3 ? 15 : (j1 == 2 && l == 4 ? 15 : (j1 == 1 && l == 5 ? 15 : 0))))))); - } - } - - public boolean isPowerSource() { - return true; - } -} diff --git a/src/main/java/net/minecraft/server/BlockMinecartDetector.java b/src/main/java/net/minecraft/server/BlockMinecartDetector.java deleted file mode 100644 index 207da243..00000000 --- a/src/main/java/net/minecraft/server/BlockMinecartDetector.java +++ /dev/null @@ -1,120 +0,0 @@ -package net.minecraft.server; - -import java.util.List; -import java.util.Random; - -import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit - -public class BlockMinecartDetector extends BlockMinecartTrackAbstract { - - public BlockMinecartDetector() { - super(true); - this.a(true); - } - - public int a(World world) { - return 20; - } - - public boolean isPowerSource() { - return true; - } - - public void a(World world, int i, int j, int k, Entity entity) { - if (!world.isStatic) { - int l = world.getData(i, j, k); - - if ((l & 8) == 0) { - this.a(world, i, j, k, l); - } - } - } - - public void a(World world, int i, int j, int k, Random random) { - if (!world.isStatic) { - int l = world.getData(i, j, k); - - if ((l & 8) != 0) { - this.a(world, i, j, k, l); - } - } - } - - public int b(IBlockAccess iblockaccess, int i, int j, int k, int l) { - return (iblockaccess.getData(i, j, k) & 8) != 0 ? 15 : 0; - } - - public int c(IBlockAccess iblockaccess, int i, int j, int k, int l) { - return (iblockaccess.getData(i, j, k) & 8) == 0 ? 0 : (l == 1 ? 15 : 0); - } - - private void a(World world, int i, int j, int k, int l) { - boolean flag = (l & 8) != 0; - boolean flag1 = false; - float f = 0.125F; - List list = world.a(EntityMinecartAbstract.class, AxisAlignedBB.a((double) ((float) i + f), (double) j, (double) ((float) k + f), (double) ((float) (i + 1) - f), (double) ((float) (j + 1) - f), (double) ((float) (k + 1) - f))); - - if (!list.isEmpty()) { - flag1 = true; - } - - // CraftBukkit start - if (flag != flag1) { - org.bukkit.block.Block block = world.getWorld().getBlockAt(i, j, k); - - BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, flag ? 15 : 0, flag1 ? 15 : 0); - world.getServer().getPluginManager().callEvent(eventRedstone); - - flag1 = eventRedstone.getNewCurrent() > 0; - } - // CraftBukkit end - - if (flag1 && !flag) { - world.setData(i, j, k, l | 8, 3); - world.applyPhysics(i, j, k, this); - world.applyPhysics(i, j - 1, k, this); - world.c(i, j, k, i, j, k); - } - - if (!flag1 && flag) { - world.setData(i, j, k, l & 7, 3); - world.applyPhysics(i, j, k, this); - world.applyPhysics(i, j - 1, k, this); - world.c(i, j, k, i, j, k); - } - - if (flag1) { - world.a(i, j, k, this, this.a(world)); - } - - world.updateAdjacentComparators(i, j, k, this); - } - - public void onPlace(World world, int i, int j, int k) { - super.onPlace(world, i, j, k); - this.a(world, i, j, k, world.getData(i, j, k)); - } - - public boolean isComplexRedstone() { - return true; - } - - public int g(World world, int i, int j, int k, int l) { - if ((world.getData(i, j, k) & 8) > 0) { - float f = 0.125F; - List list = world.a(EntityMinecartCommandBlock.class, AxisAlignedBB.a((double) ((float) i + f), (double) j, (double) ((float) k + f), (double) ((float) (i + 1) - f), (double) ((float) (j + 1) - f), (double) ((float) (k + 1) - f))); - - if (list.size() > 0) { - return ((EntityMinecartCommandBlock) list.get(0)).getCommandBlock().g(); - } - - List list1 = world.a(EntityMinecartAbstract.class, AxisAlignedBB.a((double) ((float) i + f), (double) j, (double) ((float) k + f), (double) ((float) (i + 1) - f), (double) ((float) (j + 1) - f), (double) ((float) (k + 1) - f)), IEntitySelector.c); - - if (list1.size() > 0) { - return Container.b((IInventory) list1.get(0)); - } - } - - return 0; - } -} diff --git a/src/main/java/net/minecraft/server/BlockMobSpawner.java b/src/main/java/net/minecraft/server/BlockMobSpawner.java deleted file mode 100644 index c32db8f6..00000000 --- a/src/main/java/net/minecraft/server/BlockMobSpawner.java +++ /dev/null @@ -1,41 +0,0 @@ -package net.minecraft.server; - -import java.util.Random; - -public class BlockMobSpawner extends BlockContainer { - - protected BlockMobSpawner() { - super(Material.STONE); - } - - public TileEntity a(World world, int i) { - return new TileEntityMobSpawner(); - } - - public Item getDropType(int i, Random random, int j) { - return null; - } - - public int a(Random random) { - return 0; - } - - 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, i1); - /* CraftBukkit start - Delegate to getExpDrop - int j1 = 15 + world.random.nextInt(15) + world.random.nextInt(15); - - this.dropExperience(world, i, j, k, j1)*/ - } - - public int getExpDrop(World world, int data, int enchantmentLevel) { - int j1 = 15 + world.random.nextInt(15) + world.random.nextInt(15); - - return j1; - // CraftBukkit end - } - - public boolean c() { - return false; - } -} diff --git a/src/main/java/net/minecraft/server/BlockMonsterEggs.java b/src/main/java/net/minecraft/server/BlockMonsterEggs.java deleted file mode 100644 index d9f87415..00000000 --- a/src/main/java/net/minecraft/server/BlockMonsterEggs.java +++ /dev/null @@ -1,121 +0,0 @@ -package net.minecraft.server; - -import java.util.Random; - -import net.minecraft.util.org.apache.commons.lang3.tuple.ImmutablePair; - -import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; // CraftBukkit - -public class BlockMonsterEggs extends Block { - - public static final String[] a = new String[] { "stone", "cobble", "brick", "mossybrick", "crackedbrick", "chiseledbrick"}; - - public BlockMonsterEggs() { - super(Material.CLAY); - this.c(0.0F); - this.a(CreativeModeTab.c); - } - - public void postBreak(World world, int i, int j, int k, int l) { - if (!world.isStatic) { - EntitySilverfish entitysilverfish = new EntitySilverfish(world); - - entitysilverfish.setPositionRotation((double) i + 0.5D, (double) j, (double) k + 0.5D, 0.0F, 0.0F); - world.addEntity(entitysilverfish, SpawnReason.SILVERFISH_BLOCK); // CraftBukkit - add SpawnReason - entitysilverfish.s(); - } - - super.postBreak(world, i, j, k, l); - } - - public int a(Random random) { - return 0; - } - - public static boolean a(Block block) { - return block == Blocks.STONE || block == Blocks.COBBLESTONE || block == Blocks.SMOOTH_BRICK; - } - - public static int a(Block block, int i) { - if (i == 0) { - if (block == Blocks.COBBLESTONE) { - return 1; - } - - if (block == Blocks.SMOOTH_BRICK) { - return 2; - } - } else if (block == Blocks.SMOOTH_BRICK) { - switch (i) { - case 1: - return 3; - - case 2: - return 4; - - case 3: - return 5; - } - } - - return 0; - } - - public static ImmutablePair b(int i) { - switch (i) { - case 1: - return new ImmutablePair(Blocks.COBBLESTONE, Integer.valueOf(0)); - - case 2: - return new ImmutablePair(Blocks.SMOOTH_BRICK, Integer.valueOf(0)); - - case 3: - return new ImmutablePair(Blocks.SMOOTH_BRICK, Integer.valueOf(1)); - - case 4: - return new ImmutablePair(Blocks.SMOOTH_BRICK, Integer.valueOf(2)); - - case 5: - return new ImmutablePair(Blocks.SMOOTH_BRICK, Integer.valueOf(3)); - - default: - return new ImmutablePair(Blocks.STONE, Integer.valueOf(0)); - } - } - - protected ItemStack j(int i) { - switch (i) { - case 1: - return new ItemStack(Blocks.COBBLESTONE); - - case 2: - return new ItemStack(Blocks.SMOOTH_BRICK); - - case 3: - return new ItemStack(Blocks.SMOOTH_BRICK, 1, 1); - - case 4: - return new ItemStack(Blocks.SMOOTH_BRICK, 1, 2); - - case 5: - return new ItemStack(Blocks.SMOOTH_BRICK, 1, 3); - - default: - return new ItemStack(Blocks.STONE); - } - } - - public void dropNaturally(World world, int i, int j, int k, int l, float f, int i1) { - if (!world.isStatic) { - EntitySilverfish entitysilverfish = new EntitySilverfish(world); - - entitysilverfish.setPositionRotation((double) i + 0.5D, (double) j, (double) k + 0.5D, 0.0F, 0.0F); - world.addEntity(entitysilverfish, SpawnReason.SILVERFISH_BLOCK); // CraftBukkit - add SpawnReason - entitysilverfish.s(); - } - } - - public int getDropData(World world, int i, int j, int k) { - return world.getData(i, j, k); - } -} diff --git a/src/main/java/net/minecraft/server/BlockMushroom.java b/src/main/java/net/minecraft/server/BlockMushroom.java deleted file mode 100644 index 6671a84b..00000000 --- a/src/main/java/net/minecraft/server/BlockMushroom.java +++ /dev/null @@ -1,126 +0,0 @@ -package net.minecraft.server; - -import java.util.Random; - -// CraftBukkit start -import org.bukkit.TreeType; -import org.bukkit.block.BlockState; -import org.bukkit.event.block.BlockSpreadEvent; -// CraftBukkit end - -public class BlockMushroom extends BlockPlant implements IBlockFragilePlantElement { - - protected BlockMushroom() { - float f = 0.2F; - - this.a(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f * 2.0F, 0.5F + f); - this.a(true); - } - - public void a(World world, int i, int j, int k, Random random) { - final int sourceX = i, sourceY = j, sourceZ = k; // CraftBukkit - if (random.nextInt(25) == 0) { - byte b0 = 4; - int l = 5; - - int i1; - int j1; - int k1; - - for (i1 = i - b0; i1 <= i + b0; ++i1) { - for (j1 = k - b0; j1 <= k + b0; ++j1) { - for (k1 = j - 1; k1 <= j + 1; ++k1) { - if (world.getType(i1, k1, j1) == this) { - --l; - if (l <= 0) { - return; - } - } - } - } - } - - i1 = i + random.nextInt(3) - 1; - j1 = j + random.nextInt(2) - random.nextInt(2); - k1 = k + random.nextInt(3) - 1; - - for (int l1 = 0; l1 < 4; ++l1) { - if (world.isEmpty(i1, j1, k1) && this.j(world, i1, j1, k1)) { - i = i1; - j = j1; - k = k1; - } - - i1 = i + random.nextInt(3) - 1; - j1 = j + random.nextInt(2) - random.nextInt(2); - k1 = k + random.nextInt(3) - 1; - } - - if (world.isEmpty(i1, j1, k1) && this.j(world, i1, j1, k1)) { - // CraftBukkit start - org.bukkit.World bworld = world.getWorld(); - BlockState blockState = bworld.getBlockAt(i1, j1, k1).getState(); - blockState.setType(org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(this)); // nms: this.id, 0, 2 - - BlockSpreadEvent event = new BlockSpreadEvent(blockState.getBlock(), bworld.getBlockAt(sourceX, sourceY, sourceZ), blockState); - world.getServer().getPluginManager().callEvent(event); - - if (!event.isCancelled()) { - blockState.update(true); - } - // CraftBukkit end - } - } - } - - public boolean canPlace(World world, int i, int j, int k) { - return super.canPlace(world, i, j, k) && this.j(world, i, j, k); - } - - protected boolean a(Block block) { - return block.j(); - } - - public boolean j(World world, int i, int j, int k) { - if (j >= 0 && j < 256) { - Block block = world.getType(i, j - 1, k); - - return block == Blocks.MYCEL || block == Blocks.DIRT && world.getData(i, j - 1, k) == 2 || world.j(i, j, k) < 13 && this.a(block); - } else { - return false; - } - } - - public boolean grow(World world, int i, int j, int k, Random random) { - int l = world.getData(i, j, k); - world.setAir(i, j, k); - WorldGenHugeMushroom worldgenhugemushroom = null; - - if (this == Blocks.BROWN_MUSHROOM) { - BlockSapling.treeType = TreeType.BROWN_MUSHROOM; // CraftBukkit - worldgenhugemushroom = new WorldGenHugeMushroom(0); - } else if (this == Blocks.RED_MUSHROOM) { - BlockSapling.treeType = TreeType.RED_MUSHROOM; // CraftBukkit - worldgenhugemushroom = new WorldGenHugeMushroom(1); - } - - if (worldgenhugemushroom != null && worldgenhugemushroom.generate(world, random, i, j, k)) { - return true; - } else { - world.setTypeAndData(i, j, k, this, l, 3); - return false; - } - } - - public boolean a(World world, int i, int j, int k, boolean flag) { - return true; - } - - public boolean a(World world, Random random, int i, int j, int k) { - return (double) random.nextFloat() < 0.4D; - } - - public void b(World world, Random random, int i, int j, int k) { - this.grow(world, i, j, k, random); - } -} diff --git a/src/main/java/net/minecraft/server/BlockMycel.java b/src/main/java/net/minecraft/server/BlockMycel.java deleted file mode 100644 index a01a6e62..00000000 --- a/src/main/java/net/minecraft/server/BlockMycel.java +++ /dev/null @@ -1,64 +0,0 @@ -package net.minecraft.server; - -import java.util.Random; - -// CraftBukkit start -import org.bukkit.block.BlockState; -import org.bukkit.craftbukkit.util.CraftMagicNumbers; -import org.bukkit.event.block.BlockFadeEvent; -import org.bukkit.event.block.BlockSpreadEvent; -// CraftBukkit end - -public class BlockMycel extends Block { - - protected BlockMycel() { - super(Material.GRASS); - this.a(true); - this.a(CreativeModeTab.b); - } - - public void a(World world, int i, int j, int k, Random random) { - if (!world.isStatic) { - if (world.getLightLevel(i, j + 1, k) < 4 && world.getType(i, j + 1, k).k() > 2) { - // CraftBukkit start - org.bukkit.World bworld = world.getWorld(); - BlockState blockState = bworld.getBlockAt(i, j, k).getState(); - blockState.setType(CraftMagicNumbers.getMaterial(Blocks.DIRT)); - - BlockFadeEvent event = new BlockFadeEvent(blockState.getBlock(), blockState); - world.getServer().getPluginManager().callEvent(event); - - if (!event.isCancelled()) { - blockState.update(true); - } - // CraftBukkit end - } else if (world.getLightLevel(i, j + 1, k) >= 9) { - for (int l = 0; l < 4; ++l) { - int i1 = i + random.nextInt(3) - 1; - int j1 = j + random.nextInt(5) - 3; - int k1 = k + random.nextInt(3) - 1; - Block block = world.getType(i1, j1 + 1, k1); - - if (world.getType(i1, j1, k1) == Blocks.DIRT && world.getData(i1, j1, k1) == 0 && world.getLightLevel(i1, j1 + 1, k1) >= 4 && block.k() <= 2) { - // CraftBukkit start - org.bukkit.World bworld = world.getWorld(); - BlockState blockState = bworld.getBlockAt(i1, j1, k1).getState(); - blockState.setType(CraftMagicNumbers.getMaterial(this)); - - BlockSpreadEvent event = new BlockSpreadEvent(blockState.getBlock(), bworld.getBlockAt(i, j, k), blockState); - world.getServer().getPluginManager().callEvent(event); - - if (!event.isCancelled()) { - blockState.update(true); - } - // CraftBukkit end - } - } - } - } - } - - public Item getDropType(int i, Random random, int j) { - return Blocks.DIRT.getDropType(0, random, j); - } -} diff --git a/src/main/java/net/minecraft/server/BlockNetherWart.java b/src/main/java/net/minecraft/server/BlockNetherWart.java deleted file mode 100644 index ea12b917..00000000 --- a/src/main/java/net/minecraft/server/BlockNetherWart.java +++ /dev/null @@ -1,62 +0,0 @@ -package net.minecraft.server; - -import java.util.Random; - -public class BlockNetherWart extends BlockPlant { - - protected BlockNetherWart() { - this.a(true); - float f = 0.5F; - - this.a(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.25F, 0.5F + f); - this.a((CreativeModeTab) null); - } - - protected boolean a(Block block) { - return block == Blocks.SOUL_SAND; - } - - public boolean j(World world, int i, int j, int k) { - return this.a(world.getType(i, j - 1, k)); - } - - public void a(World world, int i, int j, int k, Random random) { - int l = world.getData(i, j, k); - - if (l < 3 && random.nextInt(10) == 0) { - ++l; - org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(world, i, j, k, this, l); // CraftBukkit - } - - super.a(world, i, j, k, random); - } - - public int b() { - return 6; - } - - public void dropNaturally(World world, int i, int j, int k, int l, float f, int i1) { - if (!world.isStatic) { - int j1 = 1; - - if (l >= 3) { - j1 = 2 + world.random.nextInt(3); - if (i1 > 0) { - j1 += world.random.nextInt(i1 + 1); - } - } - - for (int k1 = 0; k1 < j1; ++k1) { - this.a(world, i, j, k, new ItemStack(Items.NETHER_STALK)); - } - } - } - - public Item getDropType(int i, Random random, int j) { - return null; - } - - public int a(Random random) { - return 0; - } -} diff --git a/src/main/java/net/minecraft/server/BlockOre.java b/src/main/java/net/minecraft/server/BlockOre.java deleted file mode 100644 index 42f44006..00000000 --- a/src/main/java/net/minecraft/server/BlockOre.java +++ /dev/null @@ -1,83 +0,0 @@ -package net.minecraft.server; - -import java.util.Random; - -public class BlockOre extends Block { - - public BlockOre() { - super(Material.STONE); - this.a(CreativeModeTab.b); - } - - public Item getDropType(int i, Random random, int j) { - return this == Blocks.COAL_ORE ? Items.COAL : (this == Blocks.DIAMOND_ORE ? Items.DIAMOND : (this == Blocks.LAPIS_ORE ? Items.INK_SACK : (this == Blocks.EMERALD_ORE ? Items.EMERALD : (this == Blocks.QUARTZ_ORE ? Items.QUARTZ : Item.getItemOf(this))))); - } - - public int a(Random random) { - return this == Blocks.LAPIS_ORE ? 4 + random.nextInt(5) : 1; - } - - public int getDropCount(int i, Random random) { - if (i > 0 && Item.getItemOf(this) != this.getDropType(0, random, i)) { - int j = random.nextInt(i + 2) - 1; - - if (j < 0) { - j = 0; - } - - return this.a(random) * (j + 1); - } else { - return this.a(random); - } - } - - 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, i1); - /* CraftBukkit start - Delegated to getExpDrop - if (this.getDropType(l, world.random, i1) != Item.getItemOf(this)) { - int j1 = 0; - - if (this == Blocks.COAL_ORE) { - j1 = MathHelper.nextInt(world.random, 0, 2); - } else if (this == Blocks.DIAMOND_ORE) { - j1 = MathHelper.nextInt(world.random, 3, 7); - } else if (this == Blocks.EMERALD_ORE) { - j1 = MathHelper.nextInt(world.random, 3, 7); - } else if (this == Blocks.LAPIS_ORE) { - j1 = MathHelper.nextInt(world.random, 2, 5); - } else if (this == Blocks.QUARTZ_ORE) { - j1 = MathHelper.nextInt(world.random, 2, 5); - } - - this.dropExperience(world, i, j, k, j1); - } - // */ - } - - public int getExpDrop(World world, int l, int i1) { - if (this.getDropType(l, world.random, i1) != Item.getItemOf(this)) { - int j1 = 0; - - if (this == Blocks.COAL_ORE) { - j1 = MathHelper.nextInt(world.random, 0, 2); - } else if (this == Blocks.DIAMOND_ORE) { - j1 = MathHelper.nextInt(world.random, 3, 7); - } else if (this == Blocks.EMERALD_ORE) { - j1 = MathHelper.nextInt(world.random, 3, 7); - } else if (this == Blocks.LAPIS_ORE) { - j1 = MathHelper.nextInt(world.random, 2, 5); - } else if (this == Blocks.QUARTZ_ORE) { - j1 = MathHelper.nextInt(world.random, 2, 5); - } - - return j1; - } - - return 0; - // CraftBukkit end - } - - public int getDropData(int i) { - return this == Blocks.LAPIS_ORE ? 4 : 0; - } -} diff --git a/src/main/java/net/minecraft/server/BlockPiston.java b/src/main/java/net/minecraft/server/BlockPiston.java deleted file mode 100644 index 8d8963cc..00000000 --- a/src/main/java/net/minecraft/server/BlockPiston.java +++ /dev/null @@ -1,400 +0,0 @@ -package net.minecraft.server; - -import java.util.List; - -// CraftBukkit start -import org.bukkit.craftbukkit.block.CraftBlock; -import org.bukkit.event.block.BlockPistonRetractEvent; -import org.bukkit.event.block.BlockPistonExtendEvent; -// CraftBukkit end - -public class BlockPiston extends Block { - - private final boolean a; - - public BlockPiston(boolean flag) { - super(Material.PISTON); - this.a = flag; - this.a(i); - this.c(0.5F); - this.a(CreativeModeTab.d); - } - - public int b() { - return 16; - } - - public boolean c() { - return false; - } - - public boolean interact(World world, int i, int j, int k, EntityHuman entityhuman, int l, float f, float f1, float f2) { - return false; - } - - public void postPlace(World world, int i, int j, int k, EntityLiving entityliving, ItemStack itemstack) { - int l = a(world, i, j, k, entityliving); - - world.setData(i, j, k, l, 2); - if (!world.isStatic) { - this.e(world, i, j, k); - } - } - - public void doPhysics(World world, int i, int j, int k, Block block) { - if (!world.isStatic) { - this.e(world, i, j, k); - } - } - - public void onPlace(World world, int i, int j, int k) { - if (!world.isStatic && world.getTileEntity(i, j, k) == null) { - this.e(world, i, j, k); - } - } - - private void e(World world, int i, int j, int k) { - int l = world.getData(i, j, k); - int i1 = b(l); - - if (i1 != 7) { - boolean flag = this.a(world, i, j, k, i1); - - if (flag && !c(l)) { - // CraftBukkit start - 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); - - if (event.isCancelled()) { - return; - } - // CraftBukkit end - - world.playBlockAction(i, j, k, this, 0, i1); - } - } else if (!flag && c(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); - - if (event.isCancelled()) { - return; - } - // CraftBukkit end - - world.setData(i, j, k, i1, 2); - world.playBlockAction(i, j, k, this, 1, i1); - } - } - } - - private boolean a(World world, int i, int j, int k, int l) { - return l != 0 && world.isBlockFacePowered(i, j - 1, k, 0) ? true : (l != 1 && world.isBlockFacePowered(i, j + 1, k, 1) ? true : (l != 2 && world.isBlockFacePowered(i, j, k - 1, 2) ? true : (l != 3 && world.isBlockFacePowered(i, j, k + 1, 3) ? true : (l != 5 && world.isBlockFacePowered(i + 1, j, k, 5) ? true : (l != 4 && world.isBlockFacePowered(i - 1, j, k, 4) ? true : (world.isBlockFacePowered(i, j, k, 0) ? true : (world.isBlockFacePowered(i, j + 2, k, 1) ? true : (world.isBlockFacePowered(i, j + 1, k - 1, 2) ? true : (world.isBlockFacePowered(i, j + 1, k + 1, 3) ? true : (world.isBlockFacePowered(i - 1, j + 1, k, 4) ? true : world.isBlockFacePowered(i + 1, j + 1, k, 5))))))))))); - } - - public boolean a(World world, int i, int j, int k, int l, int i1) { - if (!world.isStatic) { - boolean flag = this.a(world, i, j, k, i1); - - if (flag && l == 1) { - world.setData(i, j, k, i1 | 8, 2); - return false; - } - - if (!flag && l == 0) { - return false; - } - } - - if (l == 0) { - if (!this.i(world, i, j, k, i1)) { - return false; - } - - world.setData(i, j, k, i1 | 8, 2); - 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 if (l == 1) { - TileEntity tileentity = world.getTileEntity(i + Facing.b[i1], j + Facing.c[i1], k + Facing.d[i1]); - - if (tileentity instanceof TileEntityPiston) { - ((TileEntityPiston) tileentity).f(); - } - - world.setTypeAndData(i, j, k, Blocks.PISTON_MOVING, i1, 3); - world.setTileEntity(i, j, k, BlockPistonMoving.a(this, i1, i1, false, true)); - if (this.a) { - int j1 = i + Facing.b[i1] * 2; - int k1 = j + Facing.c[i1] * 2; - int l1 = k + Facing.d[i1] * 2; - Block block = world.getType(j1, k1, l1); - int i2 = world.getData(j1, k1, l1); - boolean flag1 = false; - - if (block == Blocks.PISTON_MOVING) { - TileEntity tileentity1 = world.getTileEntity(j1, k1, l1); - - if (tileentity1 instanceof TileEntityPiston) { - TileEntityPiston tileentitypiston = (TileEntityPiston) tileentity1; - - if (tileentitypiston.c() == i1 && tileentitypiston.b()) { - tileentitypiston.f(); - block = tileentitypiston.a(); - i2 = tileentitypiston.p(); - flag1 = true; - } - } - } - - if (!flag1 && block.getMaterial() != Material.AIR && a(block, world, j1, k1, l1, false) && (block.h() == 0 || block == Blocks.PISTON || block == Blocks.PISTON_STICKY)) { - i += Facing.b[i1]; - j += Facing.c[i1]; - k += Facing.d[i1]; - world.setTypeAndData(i, j, k, Blocks.PISTON_MOVING, i2, 3); - world.setTileEntity(i, j, k, BlockPistonMoving.a(block, i2, i1, false, false)); - world.setAir(j1, k1, l1); - } else if (!flag1) { - world.setAir(i + Facing.b[i1], j + Facing.c[i1], k + Facing.d[i1]); - } - } else { - world.setAir(i + Facing.b[i1], j + Facing.c[i1], k + Facing.d[i1]); - } - - world.makeSound((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "tile.piston.in", 0.5F, world.random.nextFloat() * 0.15F + 0.6F); - } - - return true; - } - - public void updateShape(IBlockAccess iblockaccess, int i, int j, int k) { - int l = iblockaccess.getData(i, j, k); - - if (c(l)) { - float f = 0.25F; - - switch (b(l)) { - case 0: - this.a(0.0F, 0.25F, 0.0F, 1.0F, 1.0F, 1.0F); - break; - - case 1: - this.a(0.0F, 0.0F, 0.0F, 1.0F, 0.75F, 1.0F); - break; - - case 2: - this.a(0.0F, 0.0F, 0.25F, 1.0F, 1.0F, 1.0F); - break; - - case 3: - this.a(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.75F); - break; - - case 4: - this.a(0.25F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); - break; - - case 5: - this.a(0.0F, 0.0F, 0.0F, 0.75F, 1.0F, 1.0F); - } - } else { - this.a(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); - } - } - - public void g() { - this.a(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); - } - - public void a(World world, int i, int j, int k, AxisAlignedBB axisalignedbb, List list, Entity entity) { - this.a(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); - super.a(world, i, j, k, axisalignedbb, list, entity); - } - - public AxisAlignedBB a(World world, int i, int j, int k) { - this.updateShape(world, i, j, k); - return super.a(world, i, j, k); - } - - public boolean d() { - return false; - } - - public static int b(int i) { - if ((i & 7) >= Facing.OPPOSITE_FACING.length) return 7; // CraftBukkit - check for AIOOB on piston data - return i & 7; - } - - public static boolean c(int i) { - return (i & 8) != 0; - } - - public static int a(World world, int i, int j, int k, EntityLiving entityliving) { - if (MathHelper.abs((float) entityliving.locX - (float) i) < 2.0F && MathHelper.abs((float) entityliving.locZ - (float) k) < 2.0F) { - double d0 = entityliving.locY + 1.82D - (double) entityliving.height; - - if (d0 - (double) j > 2.0D) { - return 1; - } - - if ((double) j - d0 > 0.0D) { - return 0; - } - } - - int l = MathHelper.floor((double) (entityliving.yaw * 4.0F / 360.0F) + 0.5D) & 3; - - return l == 0 ? 2 : (l == 1 ? 5 : (l == 2 ? 3 : (l == 3 ? 4 : 0))); - } - - private static boolean a(Block block, World world, int i, int j, int k, boolean flag) { - if (block == Blocks.OBSIDIAN) { - return false; - } else { - if (block != Blocks.PISTON && block != Blocks.PISTON_STICKY) { - if (block.f(world, i, j, k) == -1.0F) { - return false; - } - - if (block.h() == 2) { - return false; - } - - if (block.h() == 1) { - if (!flag) { - return false; - } - - return true; - } - } else if (c(world.getData(i, j, k))) { - return false; - } - - return !(block instanceof IContainer); - } - } - - // 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]; - int l1 = 0; - - while (true) { - if (l1 < 13) { - if (j1 <= 0 || j1 >= 255) { - return -1; // CraftBukkit - } - - Block block = world.getType(i1, j1, k1); - - if (block.getMaterial() != Material.AIR) { - if (!a(block, world, i1, j1, k1, true)) { - return -1; // CraftBukkit - } - - if (block.h() != 1) { - if (l1 == 12) { - return -1; // CraftBukkit - } - - i1 += Facing.b[l]; - j1 += Facing.c[l]; - k1 += Facing.d[l]; - ++l1; - continue; - } - } - } - - return l1; // CraftBukkit - } - } - - 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]; - int l1 = 0; - - while (true) { - if (l1 < 13) { - if (j1 <= 0 || j1 >= 255) { - return false; - } - - Block block = world.getType(i1, j1, k1); - - if (block.getMaterial() != Material.AIR) { - if (!a(block, world, i1, j1, k1, true)) { - return false; - } - - if (block.h() != 1) { - if (l1 == 12) { - return false; - } - - i1 += Facing.b[l]; - j1 += Facing.c[l]; - k1 += Facing.d[l]; - ++l1; - continue; - } - - block.b(world, i1, j1, k1, world.getData(i1, j1, k1), 0); - world.setAir(i1, j1, k1); - } - } - - l1 = i1; - int i2 = j1; - int j2 = k1; - int k2 = 0; - - Block[] ablock; - int l2; - int i3; - int j3; - - for (ablock = new Block[13]; i1 != i || j1 != j || k1 != k; k1 = j3) { - l2 = i1 - Facing.b[l]; - i3 = j1 - Facing.c[l]; - j3 = k1 - Facing.d[l]; - Block block1 = world.getType(l2, i3, j3); - int k3 = world.getData(l2, i3, j3); - - if (block1 == this && l2 == i && i3 == j && j3 == k) { - world.setTypeAndData(i1, j1, k1, Blocks.PISTON_MOVING, l | (this.a ? 8 : 0), 4); - world.setTileEntity(i1, j1, k1, BlockPistonMoving.a(Blocks.PISTON_EXTENSION, l | (this.a ? 8 : 0), l, true, false)); - } else { - world.setTypeAndData(i1, j1, k1, Blocks.PISTON_MOVING, k3, 4); - world.setTileEntity(i1, j1, k1, BlockPistonMoving.a(block1, k3, l, true, false)); - } - - ablock[k2++] = block1; - i1 = l2; - j1 = i3; - } - - i1 = l1; - j1 = i2; - k1 = j2; - - for (k2 = 0; i1 != i || j1 != j || k1 != k; k1 = j3) { - l2 = i1 - Facing.b[l]; - i3 = j1 - Facing.c[l]; - j3 = k1 - Facing.d[l]; - world.applyPhysics(l2, i3, j3, ablock[k2++]); - i1 = l2; - j1 = i3; - } - - return true; - } - } -} diff --git a/src/main/java/net/minecraft/server/BlockPistonExtension.java b/src/main/java/net/minecraft/server/BlockPistonExtension.java deleted file mode 100644 index cb7455da..00000000 --- a/src/main/java/net/minecraft/server/BlockPistonExtension.java +++ /dev/null @@ -1,169 +0,0 @@ -package net.minecraft.server; - -import java.util.List; -import java.util.Random; - -public class BlockPistonExtension extends Block { - - public BlockPistonExtension() { - super(Material.PISTON); - this.a(i); - this.c(0.5F); - } - - public void a(World world, int i, int j, int k, int l, EntityHuman entityhuman) { - if (entityhuman.abilities.canInstantlyBuild) { - int i1 = b(l); - Block block = world.getType(i - Facing.b[i1], j - Facing.c[i1], k - Facing.d[i1]); - - if (block == Blocks.PISTON || block == Blocks.PISTON_STICKY) { - world.setAir(i - Facing.b[i1], j - Facing.c[i1], k - Facing.d[i1]); - } - } - - super.a(world, i, j, k, l, entityhuman); - } - - public void remove(World world, int i, int j, int k, Block block, int l) { - super.remove(world, i, j, k, block, l); - if ((l & 7) >= Facing.OPPOSITE_FACING.length) return; // CraftBukkit - fix a piston AIOOBE issue - int i1 = Facing.OPPOSITE_FACING[b(l)]; - - i += Facing.b[i1]; - j += Facing.c[i1]; - k += Facing.d[i1]; - Block block1 = world.getType(i, j, k); - - if (block1 == Blocks.PISTON || block1 == Blocks.PISTON_STICKY) { - l = world.getData(i, j, k); - if (BlockPiston.c(l)) { - block1.b(world, i, j, k, l, 0); - world.setAir(i, j, k); - } - } - } - - public int b() { - return 17; - } - - public boolean c() { - return false; - } - - public boolean d() { - return false; - } - - public boolean canPlace(World world, int i, int j, int k) { - return false; - } - - public boolean canPlace(World world, int i, int j, int k, int l) { - return false; - } - - public int a(Random random) { - return 0; - } - - public void a(World world, int i, int j, int k, AxisAlignedBB axisalignedbb, List list, Entity entity) { - int l = world.getData(i, j, k); - float f = 0.25F; - float f1 = 0.375F; - float f2 = 0.625F; - float f3 = 0.25F; - float f4 = 0.75F; - - switch (b(l)) { - case 0: - this.a(0.0F, 0.0F, 0.0F, 1.0F, 0.25F, 1.0F); - super.a(world, i, j, k, axisalignedbb, list, entity); - this.a(0.375F, 0.25F, 0.375F, 0.625F, 1.0F, 0.625F); - super.a(world, i, j, k, axisalignedbb, list, entity); - break; - - case 1: - this.a(0.0F, 0.75F, 0.0F, 1.0F, 1.0F, 1.0F); - super.a(world, i, j, k, axisalignedbb, list, entity); - this.a(0.375F, 0.0F, 0.375F, 0.625F, 0.75F, 0.625F); - super.a(world, i, j, k, axisalignedbb, list, entity); - break; - - case 2: - this.a(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.25F); - super.a(world, i, j, k, axisalignedbb, list, entity); - this.a(0.25F, 0.375F, 0.25F, 0.75F, 0.625F, 1.0F); - super.a(world, i, j, k, axisalignedbb, list, entity); - break; - - case 3: - this.a(0.0F, 0.0F, 0.75F, 1.0F, 1.0F, 1.0F); - super.a(world, i, j, k, axisalignedbb, list, entity); - this.a(0.25F, 0.375F, 0.0F, 0.75F, 0.625F, 0.75F); - super.a(world, i, j, k, axisalignedbb, list, entity); - break; - - case 4: - this.a(0.0F, 0.0F, 0.0F, 0.25F, 1.0F, 1.0F); - super.a(world, i, j, k, axisalignedbb, list, entity); - this.a(0.375F, 0.25F, 0.25F, 0.625F, 0.75F, 1.0F); - super.a(world, i, j, k, axisalignedbb, list, entity); - break; - - case 5: - this.a(0.75F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); - super.a(world, i, j, k, axisalignedbb, list, entity); - this.a(0.0F, 0.375F, 0.25F, 0.75F, 0.625F, 0.75F); - super.a(world, i, j, k, axisalignedbb, list, entity); - } - - this.a(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); - } - - public void updateShape(IBlockAccess iblockaccess, int i, int j, int k) { - int l = iblockaccess.getData(i, j, k); - float f = 0.25F; - - switch (b(l)) { - case 0: - this.a(0.0F, 0.0F, 0.0F, 1.0F, 0.25F, 1.0F); - break; - - case 1: - this.a(0.0F, 0.75F, 0.0F, 1.0F, 1.0F, 1.0F); - break; - - case 2: - this.a(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.25F); - break; - - case 3: - this.a(0.0F, 0.0F, 0.75F, 1.0F, 1.0F, 1.0F); - break; - - case 4: - this.a(0.0F, 0.0F, 0.0F, 0.25F, 1.0F, 1.0F); - break; - - case 5: - this.a(0.75F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); - } - } - - public void doPhysics(World world, int i, int j, int k, Block block) { - int l = b(world.getData(i, j, k)); - if ((l & 7) >= Facing.OPPOSITE_FACING.length) return; // CraftBukkit - fix a piston AIOOBE issue - Block block1 = world.getType(i - Facing.b[l], j - Facing.c[l], k - Facing.d[l]); - - if (block1 != Blocks.PISTON && block1 != Blocks.PISTON_STICKY) { - world.setAir(i, j, k); - } else { - block1.doPhysics(world, i - Facing.b[l], j - Facing.c[l], k - Facing.d[l], block); - } - } - - public static int b(int i) { - return MathHelper.a(i & 7, 0, Facing.b.length - 1); - } -} diff --git a/src/main/java/net/minecraft/server/BlockPortal.java b/src/main/java/net/minecraft/server/BlockPortal.java deleted file mode 100644 index bec5aa8a..00000000 --- a/src/main/java/net/minecraft/server/BlockPortal.java +++ /dev/null @@ -1,122 +0,0 @@ -package net.minecraft.server; - -import java.util.Random; - -import org.bukkit.event.entity.EntityPortalEnterEvent; // CraftBukkit - -public class BlockPortal extends BlockHalfTransparent { - - public static final int[][] a = new int[][] { new int[0], { 3, 1}, { 2, 0}}; - - public BlockPortal() { - super("portal", Material.PORTAL, false); - this.a(true); - } - - public void a(World world, int i, int j, int k, Random random) { - super.a(world, i, j, k, random); - if (world.worldProvider.d() && world.getGameRules().getBoolean("doMobSpawning") && random.nextInt(2000) < world.difficulty.a()) { - int l; - - for (l = j; !World.a((IBlockAccess) world, i, l, k) && l > 0; --l) { - ; - } - - if (l > 0 && !world.getType(i, l + 1, k).r()) { - // CraftBukkit - set spawn reason to NETHER_PORTAL - Entity entity = ItemMonsterEgg.spawnCreature(world, 57, (double) i + 0.5D, (double) l + 1.1D, (double) k + 0.5D, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NETHER_PORTAL); - - if (entity != null) { - entity.portalCooldown = entity.ai(); - } - } - } - } - - public AxisAlignedBB a(World world, int i, int j, int k) { - return null; - } - - public void updateShape(IBlockAccess iblockaccess, int i, int j, int k) { - int l = b(iblockaccess.getData(i, j, k)); - - if (l == 0) { - if (iblockaccess.getType(i - 1, j, k) != this && iblockaccess.getType(i + 1, j, k) != this) { - l = 2; - } else { - l = 1; - } - - if (iblockaccess instanceof World && !((World) iblockaccess).isStatic) { - ((World) iblockaccess).setData(i, j, k, l, 2); - } - } - - float f = 0.125F; - float f1 = 0.125F; - - if (l == 1) { - f = 0.5F; - } - - if (l == 2) { - f1 = 0.5F; - } - - this.a(0.5F - f, 0.0F, 0.5F - f1, 0.5F + f, 1.0F, 0.5F + f1); - } - - public boolean d() { - return false; - } - - public boolean e(World world, int i, int j, int k) { - PortalCreator portalcreator = new PortalCreator(world, i, j, k, 1); - PortalCreator portalcreator1 = new PortalCreator(world, i, j, k, 2); - - if (portalcreator.b() && PortalCreator.a(portalcreator) == 0) { - // CraftBukkit start - return portalcreator - return portalcreator.c(); - // return true; - } else if (portalcreator1.b() && PortalCreator.a(portalcreator1) == 0) { - return portalcreator1.c(); - // return true; - // CraftBukkit end - } else { - return false; - } - } - - public void doPhysics(World world, int i, int j, int k, Block block) { - int l = b(world.getData(i, j, k)); - PortalCreator portalcreator = new PortalCreator(world, i, j, k, 1); - PortalCreator portalcreator1 = new PortalCreator(world, i, j, k, 2); - - if (l == 1 && (!portalcreator.b() || PortalCreator.a(portalcreator) < PortalCreator.b(portalcreator) * PortalCreator.c(portalcreator))) { - world.setTypeUpdate(i, j, k, Blocks.AIR); - } else if (l == 2 && (!portalcreator1.b() || PortalCreator.a(portalcreator1) < PortalCreator.b(portalcreator1) * PortalCreator.c(portalcreator1))) { - world.setTypeUpdate(i, j, k, Blocks.AIR); - } else if (l == 0 && !portalcreator.b() && !portalcreator1.b()) { - world.setTypeUpdate(i, j, k, Blocks.AIR); - } - } - - public int a(Random random) { - return 0; - } - - public void a(World world, int i, int j, int k, Entity entity) { - if (entity.vehicle == null && entity.passenger == null) { - // CraftBukkit start - Entity in portal - EntityPortalEnterEvent event = new EntityPortalEnterEvent(entity.getBukkitEntity(), new org.bukkit.Location(world.getWorld(), i, j, k)); - world.getServer().getPluginManager().callEvent(event); - // CraftBukkit end - - entity.ah(); - } - } - - public static int b(int i) { - return i & 3; - } -} diff --git a/src/main/java/net/minecraft/server/BlockPoweredRail.java b/src/main/java/net/minecraft/server/BlockPoweredRail.java deleted file mode 100644 index cd209058..00000000 --- a/src/main/java/net/minecraft/server/BlockPoweredRail.java +++ /dev/null @@ -1,146 +0,0 @@ -package net.minecraft.server; - -import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit - -public class BlockPoweredRail extends BlockMinecartTrackAbstract { - protected BlockPoweredRail() { - super(true); - } - - protected boolean a(World world, int i, int j, int k, int l, boolean flag, int i1) { - if (i1 >= 8) { - return false; - } else { - int j1 = l & 0x7; - boolean flag1 = true; - - switch (j1) { - case 0: - if (flag) { - ++k; - } else { - --k; - } - break; - - case 1: - if (flag) { - --i; - } else { - ++i; - } - break; - - case 2: - if (flag) { - i--; - } else { - ++i; - ++j; - flag1 = false; - } - - j1 = 1; - break; - - case 3: - if (flag) { - --i; - ++j; - flag1 = false; - } else { - ++i; - } - - j1 = 1; - break; - - case 4: - if (flag) { - ++k; - } else { - --k; - ++j; - flag1 = false; - } - - j1 = 0; - break; - - case 5: - if (flag) { - ++k; - ++j; - flag1 = false; - } else { - --k; - } - - j1 = 0; - } - - return this.a(world, i, j, k, flag, i1, j1) ? true : flag1 && this.a(world, i, j - 1, k, flag, i1, j1); - } - } - - protected boolean a(World world, int i, int j, int k, boolean flag, int l, int i1) { - Block block = world.getType(i, j, k); - - if (block == this) { - int j1 = world.getData(i, j, k); - int k1 = j1 & 0x7; - - if (i1 == 1 && (k1 == 0 || k1 == 4 || k1 == 5)) { - return false; - } - - if (i1 == 0 && (k1 == 1 || k1 == 2 || k1 == 3)) { - return false; - } - - if ((j1 & 0x8) != 0) { - if (world.isBlockIndirectlyPowered(i, j, k)) { - return true; - } - - return this.a(world, i, j, k, j1, flag, l + 1); - } - } - - return false; - } - - protected void a(World world, int i, int j, int k, int l, int i1, Block block) { - boolean flag = world.isBlockIndirectlyPowered(i, j, k); - - flag = flag || this.a(world, i, j, k, l, true, 0) || this.a(world, i, j, k, l, false, 0); - boolean flag1 = false; - - if (flag && (l & 0x8) == 0) { - // CraftBukkit start - if (CraftEventFactory.callRedstoneChange(world, i, j, k, 0, 15).getNewCurrent() <= 0) { - return; - } - // CraftBukkit end - - world.setData(i, j, k, i1 | 0x8, 3); - flag1 = true; - } else if (!flag && (l & 0x8) != 0) { - // CraftBukkit start - if (CraftEventFactory.callRedstoneChange(world, i, j, k, 15, 0).getNewCurrent() > 0) { - return; - } - // CraftBukkit end - - world.setData(i, j, k, i1, 3); - flag1 = true; - } - - if (flag1) { - world.applyPhysics(i, j - 1, k, this); - if (i1 == 2 || i1 == 3 || i1 == 4 || i1 == 5) { - world.applyPhysics(i, j + 1, k, this); - } - } - } -} diff --git a/src/main/java/net/minecraft/server/BlockPressurePlateAbstract.java b/src/main/java/net/minecraft/server/BlockPressurePlateAbstract.java deleted file mode 100644 index c2dfc861..00000000 --- a/src/main/java/net/minecraft/server/BlockPressurePlateAbstract.java +++ /dev/null @@ -1,174 +0,0 @@ -package net.minecraft.server; - -import java.util.Random; - -import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit - -public abstract class BlockPressurePlateAbstract extends Block { - - private String a; - - protected BlockPressurePlateAbstract(String s, Material material) { - super(material); - this.a = s; - this.a(CreativeModeTab.d); - this.a(true); - this.b(this.d(15)); - } - - public void updateShape(IBlockAccess iblockaccess, int i, int j, int k) { - this.b(iblockaccess.getData(i, j, k)); - } - - protected void b(int i) { - boolean flag = this.c(i) > 0; - float f = 0.0625F; - - if (flag) { - this.a(f, 0.0F, f, 1.0F - f, 0.03125F, 1.0F - f); - } else { - this.a(f, 0.0F, f, 1.0F - f, 0.0625F, 1.0F - f); - } - } - - public int a(World world) { - return 20; - } - - public AxisAlignedBB a(World world, int i, int j, int k) { - return null; - } - - public boolean c() { - return false; - } - - public boolean d() { - return false; - } - - public boolean b(IBlockAccess iblockaccess, int i, int j, int k) { - return true; - } - - public boolean canPlace(World world, int i, int j, int k) { - return World.a((IBlockAccess) world, i, j - 1, k) || BlockFence.a(world.getType(i, j - 1, k)); - } - - public void doPhysics(World world, int i, int j, int k, Block block) { - boolean flag = false; - - if (!World.a((IBlockAccess) world, i, j - 1, k) && !BlockFence.a(world.getType(i, j - 1, k))) { - flag = true; - } - - if (flag) { - this.b(world, i, j, k, world.getData(i, j, k), 0); - world.setAir(i, j, k); - } - } - - public void a(World world, int i, int j, int k, Random random) { - if (!world.isStatic) { - int l = this.c(world.getData(i, j, k)); - - if (l > 0) { - this.a(world, i, j, k, l); - } - } - } - - public void a(World world, int i, int j, int k, Entity entity) { - if (!world.isStatic) { - int l = this.c(world.getData(i, j, k)); - - if (l == 0) { - this.a(world, i, j, k, l); - } - } - } - - protected void a(World world, int i, int j, int k, int l) { - int i1 = this.e(world, i, j, k); - boolean flag = l > 0; - boolean flag1 = i1 > 0; - - // CraftBukkit start - Interact Pressure Plate - org.bukkit.World bworld = world.getWorld(); - org.bukkit.plugin.PluginManager manager = world.getServer().getPluginManager(); - - if (flag != flag1) { - BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bworld.getBlockAt(i, j, k), l, i1); - manager.callEvent(eventRedstone); - - flag1 = eventRedstone.getNewCurrent() > 0; - i1 = eventRedstone.getNewCurrent(); - } - // CraftBukkit end - - if (l != i1) { - world.setData(i, j, k, this.d(i1), 2); - this.a_(world, i, j, k); - world.c(i, j, k, i, j, k); - } - - if (!flag1 && flag) { - world.makeSound((double) i + 0.5D, (double) j + 0.1D, (double) k + 0.5D, "random.click", 0.3F, 0.5F); - } else if (flag1 && !flag) { - world.makeSound((double) i + 0.5D, (double) j + 0.1D, (double) k + 0.5D, "random.click", 0.3F, 0.6F); - } - - if (flag1) { - world.a(i, j, k, this, this.a(world)); - } - } - - protected AxisAlignedBB a(int i, int j, int k) { - float f = 0.125F; - - return AxisAlignedBB.a((double) ((float) i + f), (double) j, (double) ((float) k + f), (double) ((float) (i + 1) - f), (double) j + 0.25D, (double) ((float) (k + 1) - f)); - } - - public void remove(World world, int i, int j, int k, Block block, int l) { - if (this.c(l) > 0) { - this.a_(world, i, j, k); - } - - super.remove(world, i, j, k, block, l); - } - - protected void a_(World world, int i, int j, int k) { - world.applyPhysics(i, j, k, this); - world.applyPhysics(i, j - 1, k, this); - } - - public int b(IBlockAccess iblockaccess, int i, int j, int k, int l) { - return this.c(iblockaccess.getData(i, j, k)); - } - - public int c(IBlockAccess iblockaccess, int i, int j, int k, int l) { - return l == 1 ? this.c(iblockaccess.getData(i, j, k)) : 0; - } - - public boolean isPowerSource() { - return true; - } - - public void g() { - float f = 0.5F; - float f1 = 0.125F; - float f2 = 0.5F; - - this.a(0.5F - f, 0.5F - f1, 0.5F - f2, 0.5F + f, 0.5F + f1, 0.5F + f2); - } - - public int h() { - return 1; - } - - protected abstract int e(World world, int i, int j, int k); - - protected abstract int c(int i); - - protected abstract int d(int i); -} diff --git a/src/main/java/net/minecraft/server/BlockPressurePlateBinary.java b/src/main/java/net/minecraft/server/BlockPressurePlateBinary.java deleted file mode 100644 index 25ef883d..00000000 --- a/src/main/java/net/minecraft/server/BlockPressurePlateBinary.java +++ /dev/null @@ -1,74 +0,0 @@ -package net.minecraft.server; - -import java.util.Iterator; -import java.util.List; - -import org.bukkit.event.entity.EntityInteractEvent; // CraftBukkit - -public class BlockPressurePlateBinary extends BlockPressurePlateAbstract { - - private EnumMobType a; - - protected BlockPressurePlateBinary(String s, Material material, EnumMobType enummobtype) { - super(s, material); - this.a = enummobtype; - } - - protected int d(int i) { - return i > 0 ? 1 : 0; - } - - protected int c(int i) { - return i == 1 ? 15 : 0; - } - - protected int e(World world, int i, int j, int k) { - List list = null; - - if (this.a == EnumMobType.EVERYTHING) { - list = world.getEntities((Entity) null, this.a(i, j, k)); - } - - if (this.a == EnumMobType.MOBS) { - list = world.a(EntityLiving.class, this.a(i, j, k)); - } - - if (this.a == EnumMobType.PLAYERS) { - list = world.a(EntityHuman.class, this.a(i, j, k)); - } - - if (list != null && !list.isEmpty()) { - Iterator iterator = list.iterator(); - - while (iterator.hasNext()) { - Entity entity = (Entity) iterator.next(); - - // CraftBukkit start - Call interact event when turning on a pressure plate - if (this.c(world.getData(i, j, k)) == 0) { - org.bukkit.World bworld = world.getWorld(); - org.bukkit.plugin.PluginManager manager = world.getServer().getPluginManager(); - org.bukkit.event.Cancellable cancellable; - - if (entity instanceof EntityHuman) { - cancellable = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent((EntityHuman) entity, org.bukkit.event.block.Action.PHYSICAL, i, j, k, -1, null); - } else { - cancellable = new EntityInteractEvent(entity.getBukkitEntity(), bworld.getBlockAt(i, j, k)); - manager.callEvent((EntityInteractEvent) cancellable); - } - - // We only want to block turning the plate on if all events are cancelled - if (cancellable.isCancelled()) { - continue; - } - } - // CraftBukkit end - - if (!entity.az()) { - return 15; - } - } - } - - return 0; - } -} diff --git a/src/main/java/net/minecraft/server/BlockPressurePlateWeighted.java b/src/main/java/net/minecraft/server/BlockPressurePlateWeighted.java deleted file mode 100644 index b6f22f02..00000000 --- a/src/main/java/net/minecraft/server/BlockPressurePlateWeighted.java +++ /dev/null @@ -1,58 +0,0 @@ -package net.minecraft.server; - -import org.bukkit.event.entity.EntityInteractEvent; // CraftBukkit - -public class BlockPressurePlateWeighted extends BlockPressurePlateAbstract { - private final int a; - - protected BlockPressurePlateWeighted(String s, Material material, int i) { - super(s, material); - this.a = i; - } - - protected int e(World world, int i, int j, int k) { - // CraftBukkit start - int l = 0; - java.util.Iterator iterator = world.a(Entity.class, this.a(i, j, k)).iterator(); - - while (iterator.hasNext()) { - Entity entity = (Entity) iterator.next(); - - org.bukkit.event.Cancellable cancellable; - - if (entity instanceof EntityHuman) { - cancellable = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent((EntityHuman) entity, org.bukkit.event.block.Action.PHYSICAL, i, j, k, -1, null); - } else { - cancellable = new EntityInteractEvent(entity.getBukkitEntity(), world.getWorld().getBlockAt(i, j, k)); - world.getServer().getPluginManager().callEvent((EntityInteractEvent) cancellable); - } - - // We only want to block turning the plate on if all events are cancelled - if (!cancellable.isCancelled()) { - l++; - } - } - - l = Math.min(l, this.a); - // CraftBukkit end - - if (l <= 0) { - return 0; - } - - float f = (float) Math.min(this.a, l) / (float) this.a; - return MathHelper.f(f * 15.0F); - } - - protected int c(int i) { - return i; - } - - protected int d(int i) { - return i; - } - - public int a(World world) { - return 10; - } -} diff --git a/src/main/java/net/minecraft/server/BlockPumpkin.java b/src/main/java/net/minecraft/server/BlockPumpkin.java deleted file mode 100644 index a8632a77..00000000 --- a/src/main/java/net/minecraft/server/BlockPumpkin.java +++ /dev/null @@ -1,98 +0,0 @@ -package net.minecraft.server; - -// CraftBukkit start -import org.bukkit.craftbukkit.util.BlockStateListPopulator; -import org.bukkit.event.block.BlockRedstoneEvent; -import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; -// CraftBukkit end - -public class BlockPumpkin extends BlockDirectional { - - private boolean a; - - protected BlockPumpkin(boolean flag) { - super(Material.PUMPKIN); - this.a(true); - this.a = flag; - this.a(CreativeModeTab.b); - } - - public void onPlace(World world, int i, int j, int k) { - super.onPlace(world, i, j, k); - if (world.getType(i, j - 1, k) == Blocks.SNOW_BLOCK && world.getType(i, j - 2, k) == Blocks.SNOW_BLOCK) { - if (!world.isStatic) { - // CraftBukkit start - Use BlockStateListPopulator - BlockStateListPopulator blockList = new BlockStateListPopulator(world.getWorld()); - - blockList.setTypeId(i, j, k, 0); - blockList.setTypeId(i, j - 1, k, 0); - blockList.setTypeId(i, j - 2, k, 0); - EntitySnowman entitysnowman = new EntitySnowman(world); - - entitysnowman.setPositionRotation((double) i + 0.5D, (double) j - 1.95D, (double) k + 0.5D, 0.0F, 0.0F); - if (world.addEntity(entitysnowman, SpawnReason.BUILD_SNOWMAN)) { - blockList.updateList(); - } - // CraftBukkit end - } - - for (int l = 0; l < 120; ++l) { - 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.getType(i, j - 1, k) == Blocks.IRON_BLOCK && world.getType(i, j - 2, k) == Blocks.IRON_BLOCK) { - boolean flag = world.getType(i - 1, j - 1, k) == Blocks.IRON_BLOCK && world.getType(i + 1, j - 1, k) == Blocks.IRON_BLOCK; - boolean flag1 = world.getType(i, j - 1, k - 1) == Blocks.IRON_BLOCK && world.getType(i, j - 1, k + 1) == Blocks.IRON_BLOCK; - - if (flag || flag1) { - // CraftBukkit start - Use BlockStateListPopulator - BlockStateListPopulator blockList = new BlockStateListPopulator(world.getWorld()); - - blockList.setTypeId(i, j, k, 0); - blockList.setTypeId(i, j - 1, k, 0); - blockList.setTypeId(i, j - 2, k, 0); - if (flag) { - blockList.setTypeId(i - 1, j - 1, k, 0); - blockList.setTypeId(i + 1, j - 1, k, 0); - } else { - blockList.setTypeId(i, j - 1, k - 1, 0); - blockList.setTypeId(i, j - 1, k + 1, 0); - } - - EntityIronGolem entityirongolem = new EntityIronGolem(world); - - 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.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(); - } - // CraftBukkit end - } - } - } - - public boolean canPlace(World world, int i, int j, int k) { - return world.getType(i, j, k).material.isReplaceable() && World.a((IBlockAccess) world, i, j - 1, k); - } - - public void postPlace(World world, int i, int j, int k, EntityLiving entityliving, ItemStack itemstack) { - int l = MathHelper.floor((double) (entityliving.yaw * 4.0F / 360.0F) + 2.5D) & 3; - - world.setData(i, j, k, l, 2); - } - - // CraftBukkit start - public void doPhysics(World world, int i, int j, int k, Block block) { - if (block != null && block.isPowerSource()) { - org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(i, j, k); - int power = bukkitBlock.getBlockPower(); - - BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bukkitBlock, power, power); - world.getServer().getPluginManager().callEvent(eventRedstone); - } - } - // CraftBukkit end -} diff --git a/src/main/java/net/minecraft/server/BlockRedstoneLamp.java b/src/main/java/net/minecraft/server/BlockRedstoneLamp.java deleted file mode 100644 index cb802e80..00000000 --- a/src/main/java/net/minecraft/server/BlockRedstoneLamp.java +++ /dev/null @@ -1,70 +0,0 @@ -package net.minecraft.server; - -import java.util.Random; - -import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit - -public class BlockRedstoneLamp extends Block { - - private final boolean a; - - public BlockRedstoneLamp(boolean flag) { - super(Material.BUILDABLE_GLASS); - this.a = flag; - if (flag) { - this.a(1.0F); - } - } - - public void onPlace(World world, int i, int j, int k) { - if (!world.isStatic) { - if (this.a && !world.isBlockIndirectlyPowered(i, j, k)) { - world.a(i, j, k, this, 4); - } else if (!this.a && world.isBlockIndirectlyPowered(i, j, k)) { - // CraftBukkit start - if (CraftEventFactory.callRedstoneChange(world, i, j, k, 0, 15).getNewCurrent() != 15) { - return; - } - // CraftBukkit end - - world.setTypeAndData(i, j, k, Blocks.REDSTONE_LAMP_ON, 0, 2); - } - } - } - - public void doPhysics(World world, int i, int j, int k, Block block) { - if (!world.isStatic) { - if (this.a && !world.isBlockIndirectlyPowered(i, j, k)) { - world.a(i, j, k, this, 4); - } else if (!this.a && world.isBlockIndirectlyPowered(i, j, k)) { - // CraftBukkit start - if (CraftEventFactory.callRedstoneChange(world, i, j, k, 0, 15).getNewCurrent() != 15) { - return; - } - // CraftBukkit end - - world.setTypeAndData(i, j, k, Blocks.REDSTONE_LAMP_ON, 0, 2); - } - } - } - - public void a(World world, int i, int j, int k, Random random) { - if (!world.isStatic && this.a && !world.isBlockIndirectlyPowered(i, j, k)) { - // CraftBukkit start - if (CraftEventFactory.callRedstoneChange(world, i, j, k, 15, 0).getNewCurrent() != 0) { - return; - } - // CraftBukkit end - - world.setTypeAndData(i, j, k, Blocks.REDSTONE_LAMP_OFF, 0, 2); - } - } - - public Item getDropType(int i, Random random, int j) { - return Item.getItemOf(Blocks.REDSTONE_LAMP_OFF); - } - - protected ItemStack j(int i) { - return new ItemStack(Blocks.REDSTONE_LAMP_OFF); - } -} diff --git a/src/main/java/net/minecraft/server/BlockRedstoneOre.java b/src/main/java/net/minecraft/server/BlockRedstoneOre.java deleted file mode 100644 index 0cd2e04e..00000000 --- a/src/main/java/net/minecraft/server/BlockRedstoneOre.java +++ /dev/null @@ -1,155 +0,0 @@ -package net.minecraft.server; - -import java.util.Random; - -// CraftBukkit start -import org.bukkit.craftbukkit.event.CraftEventFactory; -import org.bukkit.event.entity.EntityInteractEvent; -// CraftBukkit end - -public class BlockRedstoneOre extends Block { - - private boolean a; - - public BlockRedstoneOre(boolean flag) { - super(Material.STONE); - if (flag) { - this.a(true); - } - - this.a = flag; - } - - public int a(World world) { - return 30; - } - - public void attack(World world, int i, int j, int k, EntityHuman entityhuman) { - this.e(world, i, j, k, entityhuman); // CraftBukkit - add entityhuman - super.attack(world, i, j, k, entityhuman); - } - - public void b(World world, int i, int j, int k, Entity entity) { - // CraftBukkit start - if (entity instanceof EntityHuman) { - org.bukkit.event.player.PlayerInteractEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent((EntityHuman) entity, org.bukkit.event.block.Action.PHYSICAL, i, j, k, -1, null); - if (!event.isCancelled()) { - this.e(world, i, j, k, entity); // add entity - super.b(world, i, j, k, entity); - } - } else { - EntityInteractEvent event = new EntityInteractEvent(entity.getBukkitEntity(), world.getWorld().getBlockAt(i, j, k)); - world.getServer().getPluginManager().callEvent(event); - if (!event.isCancelled()) { - this.e(world, i, j, k, entity); // add entity - super.b(world, i, j, k, entity); - } - } - // CraftBukkit end - } - - public boolean interact(World world, int i, int j, int k, EntityHuman entityhuman, int l, float f, float f1, float f2) { - this.e(world, i, j, k, entityhuman); // CraftBukkit - add entityhuman - return super.interact(world, i, j, k, entityhuman, l, f, f1, f2); - } - - private void e(World world, int i, int j, int k, Entity entity) { // CraftBukkit - add Entity - this.m(world, i, j, k); - if (this == Blocks.REDSTONE_ORE) { - // CraftBukkit start - if (CraftEventFactory.callEntityChangeBlockEvent(entity, i, j, k, Blocks.GLOWING_REDSTONE_ORE, 0).isCancelled()) { - return; - } - // CraftBukkit end - world.setTypeUpdate(i, j, k, Blocks.GLOWING_REDSTONE_ORE); - } - } - - public void a(World world, int i, int j, int k, Random random) { - if (this == Blocks.GLOWING_REDSTONE_ORE) { - // CraftBukkit start - if (CraftEventFactory.callBlockFadeEvent(world.getWorld().getBlockAt(i, j, k), Blocks.REDSTONE_ORE).isCancelled()) { - return; - } - // CraftBukkit end - world.setTypeUpdate(i, j, k, Blocks.REDSTONE_ORE); - } - } - - public Item getDropType(int i, Random random, int j) { - return Items.REDSTONE; - } - - public int getDropCount(int i, Random random) { - return this.a(random) + random.nextInt(i + 1); - } - - public int a(Random random) { - return 4 + random.nextInt(2); - } - - 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, i1); - /* CraftBukkit start - Delegated to getExpDrop - if (this.getDropType(l, world.random, i1) != Item.getItemOf(this)) { - int j1 = 1 + world.random.nextInt(5); - - this.dropExperience(world, i, j, k, j1); - } - // */ - } - - public int getExpDrop(World world, int l, int i1) { - if (this.getDropType(l, world.random, i1) != Item.getItemOf(this)) { - int j1 = 1 + world.random.nextInt(5); - - return j1; - } - - return 0; - // CraftBukkit end - } - - private void m(World world, int i, int j, int k) { - Random random = world.random; - double d0 = 0.0625D; - - for (int l = 0; l < 6; ++l) { - double d1 = (double) ((float) i + random.nextFloat()); - double d2 = (double) ((float) j + random.nextFloat()); - double d3 = (double) ((float) k + random.nextFloat()); - - if (l == 0 && !world.getType(i, j + 1, k).c()) { - d2 = (double) (j + 1) + d0; - } - - if (l == 1 && !world.getType(i, j - 1, k).c()) { - d2 = (double) (j + 0) - d0; - } - - if (l == 2 && !world.getType(i, j, k + 1).c()) { - d3 = (double) (k + 1) + d0; - } - - if (l == 3 && !world.getType(i, j, k - 1).c()) { - d3 = (double) (k + 0) - d0; - } - - if (l == 4 && !world.getType(i + 1, j, k).c()) { - d1 = (double) (i + 1) + d0; - } - - if (l == 5 && !world.getType(i - 1, j, k).c()) { - d1 = (double) (i + 0) - d0; - } - - if (d1 < (double) i || d1 > (double) (i + 1) || d2 < 0.0D || d2 > (double) (j + 1) || d3 < (double) k || d3 > (double) (k + 1)) { - world.addParticle("reddust", d1, d2, d3, 0.0D, 0.0D, 0.0D); - } - } - } - - protected ItemStack j(int i) { - return new ItemStack(Blocks.REDSTONE_ORE); - } -} diff --git a/src/main/java/net/minecraft/server/BlockRedstoneTorch.java b/src/main/java/net/minecraft/server/BlockRedstoneTorch.java deleted file mode 100644 index 8e014149..00000000 --- a/src/main/java/net/minecraft/server/BlockRedstoneTorch.java +++ /dev/null @@ -1,176 +0,0 @@ -package net.minecraft.server; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Random; - -import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit - -public class BlockRedstoneTorch extends BlockTorch { - - private boolean isOn; - private static Map b = new HashMap(); - - private boolean a(World world, int i, int j, int k, boolean flag) { - if (!b.containsKey(world)) { - b.put(world, new ArrayList()); - } - - List list = (List) b.get(world); - - if (flag) { - list.add(new RedstoneUpdateInfo(i, j, k, world.getTime())); - } - - int l = 0; - - for (int i1 = 0; i1 < list.size(); ++i1) { - RedstoneUpdateInfo redstoneupdateinfo = (RedstoneUpdateInfo) list.get(i1); - - if (redstoneupdateinfo.a == i && redstoneupdateinfo.b == j && redstoneupdateinfo.c == k) { - ++l; - if (l >= 8) { - return true; - } - } - } - - return false; - } - - protected BlockRedstoneTorch(boolean flag) { - this.isOn = flag; - this.a(true); - this.a((CreativeModeTab) null); - } - - public int a(World world) { - return 2; - } - - public void onPlace(World world, int i, int j, int k) { - if (world.getData(i, j, k) == 0) { - super.onPlace(world, i, j, k); - } - - if (this.isOn) { - world.applyPhysics(i, j - 1, k, this); - world.applyPhysics(i, j + 1, k, this); - world.applyPhysics(i - 1, j, k, this); - world.applyPhysics(i + 1, j, k, this); - world.applyPhysics(i, j, k - 1, this); - world.applyPhysics(i, j, k + 1, this); - } - } - - public void remove(World world, int i, int j, int k, Block block, int l) { - if (this.isOn) { - world.applyPhysics(i, j - 1, k, this); - world.applyPhysics(i, j + 1, k, this); - world.applyPhysics(i - 1, j, k, this); - world.applyPhysics(i + 1, j, k, this); - world.applyPhysics(i, j, k - 1, this); - world.applyPhysics(i, j, k + 1, this); - } - } - - public int b(IBlockAccess iblockaccess, int i, int j, int k, int l) { - if (!this.isOn) { - return 0; - } else { - int i1 = iblockaccess.getData(i, j, k); - - return i1 == 5 && l == 1 ? 0 : (i1 == 3 && l == 3 ? 0 : (i1 == 4 && l == 2 ? 0 : (i1 == 1 && l == 5 ? 0 : (i1 == 2 && l == 4 ? 0 : 15)))); - } - } - - private boolean m(World world, int i, int j, int k) { - int l = world.getData(i, j, k); - - return l == 5 && world.isBlockFacePowered(i, j - 1, k, 0) ? true : (l == 3 && world.isBlockFacePowered(i, j, k - 1, 2) ? true : (l == 4 && world.isBlockFacePowered(i, j, k + 1, 3) ? true : (l == 1 && world.isBlockFacePowered(i - 1, j, k, 4) ? true : l == 2 && world.isBlockFacePowered(i + 1, j, k, 5)))); - } - - public void a(World world, int i, int j, int k, Random random) { - boolean flag = this.m(world, i, j, k); - List list = (List) b.get(world); - - while (list != null && !list.isEmpty() && world.getTime() - ((RedstoneUpdateInfo) list.get(0)).d > 60L) { - list.remove(0); - } - - // CraftBukkit start - org.bukkit.plugin.PluginManager manager = world.getServer().getPluginManager(); - org.bukkit.block.Block block = world.getWorld().getBlockAt(i, j, k); - int oldCurrent = this.isOn ? 15 : 0; - - BlockRedstoneEvent event = new BlockRedstoneEvent(block, oldCurrent, oldCurrent); - // CraftBukkit end - - if (this.isOn) { - if (flag) { - // CraftBukkit start - if (oldCurrent != 0) { - event.setNewCurrent(0); - manager.callEvent(event); - if (event.getNewCurrent() != 0) { - return; - } - } - // CraftBukkit end - - world.setTypeAndData(i, j, k, Blocks.REDSTONE_TORCH_OFF, world.getData(i, j, k), 3); - if (this.a(world, i, j, k, true)) { - world.makeSound((double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), "random.fizz", 0.5F, 2.6F + (world.random.nextFloat() - world.random.nextFloat()) * 0.8F); - - for (int l = 0; l < 5; ++l) { - double d0 = (double) i + random.nextDouble() * 0.6D + 0.2D; - double d1 = (double) j + random.nextDouble() * 0.6D + 0.2D; - double d2 = (double) k + random.nextDouble() * 0.6D + 0.2D; - - world.addParticle("smoke", d0, d1, d2, 0.0D, 0.0D, 0.0D); - } - } - } - } else if (!flag && !this.a(world, i, j, k, false)) { - // CraftBukkit start - if (oldCurrent != 15) { - event.setNewCurrent(15); - manager.callEvent(event); - if (event.getNewCurrent() != 15) { - return; - } - } - // CraftBukkit end - - world.setTypeAndData(i, j, k, Blocks.REDSTONE_TORCH_ON, world.getData(i, j, k), 3); - } - } - - public void doPhysics(World world, int i, int j, int k, Block block) { - if (!this.b(world, i, j, k, block)) { - boolean flag = this.m(world, i, j, k); - - if (this.isOn && flag || !this.isOn && !flag) { - world.a(i, j, k, this, this.a(world)); - } - } - } - - public int c(IBlockAccess iblockaccess, int i, int j, int k, int l) { - return l == 0 ? this.b(iblockaccess, i, j, k, l) : 0; - } - - public Item getDropType(int i, Random random, int j) { - return Item.getItemOf(Blocks.REDSTONE_TORCH_ON); - } - - public boolean isPowerSource() { - return true; - } - - public boolean c(Block block) { - return block == Blocks.REDSTONE_TORCH_OFF || block == Blocks.REDSTONE_TORCH_ON; - } -} diff --git a/src/main/java/net/minecraft/server/BlockRedstoneWire.java b/src/main/java/net/minecraft/server/BlockRedstoneWire.java deleted file mode 100644 index 3cec3789..00000000 --- a/src/main/java/net/minecraft/server/BlockRedstoneWire.java +++ /dev/null @@ -1,323 +0,0 @@ -package net.minecraft.server; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Random; -import java.util.Set; - -import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit - -public class BlockRedstoneWire extends Block { - - private boolean a = true; - private Set b = new HashSet(); - - public BlockRedstoneWire() { - super(Material.ORIENTABLE); - this.a(0.0F, 0.0F, 0.0F, 1.0F, 0.0625F, 1.0F); - } - - public AxisAlignedBB a(World world, int i, int j, int k) { - return null; - } - - public boolean c() { - return false; - } - - public boolean d() { - return false; - } - - public int b() { - return 5; - } - - public boolean canPlace(World world, int i, int j, int k) { - return World.a((IBlockAccess) world, i, j - 1, k) || world.getType(i, j - 1, k) == Blocks.GLOWSTONE; - } - - private void e(World world, int i, int j, int k) { - this.a(world, i, j, k, i, j, k); - ArrayList arraylist = new ArrayList(this.b); - - this.b.clear(); - - for (int l = 0; l < arraylist.size(); ++l) { - ChunkPosition chunkposition = (ChunkPosition) arraylist.get(l); - - world.applyPhysics(chunkposition.x, chunkposition.y, chunkposition.z, this); - } - } - - private void a(World world, int i, int j, int k, int l, int i1, int j1) { - int k1 = world.getData(i, j, k); - byte b0 = 0; - int l1 = this.getPower(world, l, i1, j1, b0); - - this.a = false; - int i2 = world.getHighestNeighborSignal(i, j, k); - - this.a = true; - if (i2 > 0 && i2 > l1 - 1) { - l1 = i2; - } - - int j2 = 0; - - for (int k2 = 0; k2 < 4; ++k2) { - int l2 = i; - int i3 = k; - - if (k2 == 0) { - l2 = i - 1; - } - - if (k2 == 1) { - ++l2; - } - - if (k2 == 2) { - i3 = k - 1; - } - - if (k2 == 3) { - ++i3; - } - - if (l2 != l || i3 != j1) { - j2 = this.getPower(world, l2, j, i3, j2); - } - - if (world.getType(l2, j, i3).r() && !world.getType(i, j + 1, k).r()) { - if ((l2 != l || i3 != j1) && j >= i1) { - j2 = this.getPower(world, l2, j + 1, i3, j2); - } - } else if (!world.getType(l2, j, i3).r() && (l2 != l || i3 != j1) && j <= i1) { - j2 = this.getPower(world, l2, j - 1, i3, j2); - } - } - - if (j2 > l1) { - l1 = j2 - 1; - } else if (l1 > 0) { - --l1; - } else { - l1 = 0; - } - - if (i2 > l1 - 1) { - l1 = i2; - } - - // CraftBukkit start - if (k1 != l1) { - BlockRedstoneEvent event = new BlockRedstoneEvent(world.getWorld().getBlockAt(i, j, k), k1, l1); - world.getServer().getPluginManager().callEvent(event); - - l1 = event.getNewCurrent(); - } - // CraftBukkit end - if (k1 != l1) { - world.setData(i, j, k, l1, 2); - this.b.add(new ChunkPosition(i, j, k)); - this.b.add(new ChunkPosition(i - 1, j, k)); - this.b.add(new ChunkPosition(i + 1, j, k)); - this.b.add(new ChunkPosition(i, j - 1, k)); - this.b.add(new ChunkPosition(i, j + 1, k)); - this.b.add(new ChunkPosition(i, j, k - 1)); - this.b.add(new ChunkPosition(i, j, k + 1)); - } - } - - private void m(World world, int i, int j, int k) { - if (world.getType(i, j, k) == this) { - world.applyPhysics(i, j, k, this); - world.applyPhysics(i - 1, j, k, this); - world.applyPhysics(i + 1, j, k, this); - world.applyPhysics(i, j, k - 1, this); - world.applyPhysics(i, j, k + 1, this); - world.applyPhysics(i, j - 1, k, this); - world.applyPhysics(i, j + 1, k, this); - } - } - - public void onPlace(World world, int i, int j, int k) { - super.onPlace(world, i, j, k); - if (!world.isStatic) { - this.e(world, i, j, k); - world.applyPhysics(i, j + 1, k, this); - world.applyPhysics(i, j - 1, k, this); - this.m(world, i - 1, j, k); - this.m(world, i + 1, j, k); - this.m(world, i, j, k - 1); - this.m(world, i, j, k + 1); - if (world.getType(i - 1, j, k).r()) { - this.m(world, i - 1, j + 1, k); - } else { - this.m(world, i - 1, j - 1, k); - } - - if (world.getType(i + 1, j, k).r()) { - this.m(world, i + 1, j + 1, k); - } else { - this.m(world, i + 1, j - 1, k); - } - - if (world.getType(i, j, k - 1).r()) { - this.m(world, i, j + 1, k - 1); - } else { - this.m(world, i, j - 1, k - 1); - } - - if (world.getType(i, j, k + 1).r()) { - this.m(world, i, j + 1, k + 1); - } else { - this.m(world, i, j - 1, k + 1); - } - } - } - - public void remove(World world, int i, int j, int k, Block block, int l) { - super.remove(world, i, j, k, block, l); - if (!world.isStatic) { - world.applyPhysics(i, j + 1, k, this); - world.applyPhysics(i, j - 1, k, this); - world.applyPhysics(i + 1, j, k, this); - world.applyPhysics(i - 1, j, k, this); - world.applyPhysics(i, j, k + 1, this); - world.applyPhysics(i, j, k - 1, this); - this.e(world, i, j, k); - this.m(world, i - 1, j, k); - this.m(world, i + 1, j, k); - this.m(world, i, j, k - 1); - this.m(world, i, j, k + 1); - if (world.getType(i - 1, j, k).r()) { - this.m(world, i - 1, j + 1, k); - } else { - this.m(world, i - 1, j - 1, k); - } - - if (world.getType(i + 1, j, k).r()) { - this.m(world, i + 1, j + 1, k); - } else { - this.m(world, i + 1, j - 1, k); - } - - if (world.getType(i, j, k - 1).r()) { - this.m(world, i, j + 1, k - 1); - } else { - this.m(world, i, j - 1, k - 1); - } - - if (world.getType(i, j, k + 1).r()) { - this.m(world, i, j + 1, k + 1); - } else { - this.m(world, i, j - 1, k + 1); - } - } - } - - // CraftBukkit - private -> public - public int getPower(World world, int i, int j, int k, int l) { - if (world.getType(i, j, k) != this) { - return l; - } else { - int i1 = world.getData(i, j, k); - - return i1 > l ? i1 : l; - } - } - - public void doPhysics(World world, int i, int j, int k, Block block) { - if (!world.isStatic) { - boolean flag = this.canPlace(world, i, j, k); - - if (flag) { - this.e(world, i, j, k); - } else { - this.b(world, i, j, k, 0, 0); - world.setAir(i, j, k); - } - - super.doPhysics(world, i, j, k, block); - } - } - - public Item getDropType(int i, Random random, int j) { - return Items.REDSTONE; - } - - public int c(IBlockAccess iblockaccess, int i, int j, int k, int l) { - return !this.a ? 0 : this.b(iblockaccess, i, j, k, l); - } - - public int b(IBlockAccess iblockaccess, int i, int j, int k, int l) { - if (!this.a) { - return 0; - } else { - int i1 = iblockaccess.getData(i, j, k); - - if (i1 == 0) { - return 0; - } else if (l == 1) { - return i1; - } else { - boolean flag = g(iblockaccess, i - 1, j, k, 1) || !iblockaccess.getType(i - 1, j, k).r() && g(iblockaccess, i - 1, j - 1, k, -1); - boolean flag1 = g(iblockaccess, i + 1, j, k, 3) || !iblockaccess.getType(i + 1, j, k).r() && g(iblockaccess, i + 1, j - 1, k, -1); - boolean flag2 = g(iblockaccess, i, j, k - 1, 2) || !iblockaccess.getType(i, j, k - 1).r() && g(iblockaccess, i, j - 1, k - 1, -1); - boolean flag3 = g(iblockaccess, i, j, k + 1, 0) || !iblockaccess.getType(i, j, k + 1).r() && g(iblockaccess, i, j - 1, k + 1, -1); - - if (!iblockaccess.getType(i, j + 1, k).r()) { - if (iblockaccess.getType(i - 1, j, k).r() && g(iblockaccess, i - 1, j + 1, k, -1)) { - flag = true; - } - - if (iblockaccess.getType(i + 1, j, k).r() && g(iblockaccess, i + 1, j + 1, k, -1)) { - flag1 = true; - } - - if (iblockaccess.getType(i, j, k - 1).r() && g(iblockaccess, i, j + 1, k - 1, -1)) { - flag2 = true; - } - - if (iblockaccess.getType(i, j, k + 1).r() && g(iblockaccess, i, j + 1, k + 1, -1)) { - flag3 = true; - } - } - - return !flag2 && !flag1 && !flag && !flag3 && l >= 2 && l <= 5 ? i1 : (l == 2 && flag2 && !flag && !flag1 ? i1 : (l == 3 && flag3 && !flag && !flag1 ? i1 : (l == 4 && flag && !flag2 && !flag3 ? i1 : (l == 5 && flag1 && !flag2 && !flag3 ? i1 : 0)))); - } - } - } - - public boolean isPowerSource() { - return this.a; - } - - public static boolean f(IBlockAccess iblockaccess, int i, int j, int k, int l) { - Block block = iblockaccess.getType(i, j, k); - - if (block == Blocks.REDSTONE_WIRE) { - return true; - } else if (!Blocks.DIODE_OFF.e(block)) { - return block.isPowerSource() && l != -1; - } else { - int i1 = iblockaccess.getData(i, j, k); - - return l == (i1 & 3) || l == Direction.f[i1 & 3]; - } - } - - public static boolean g(IBlockAccess iblockaccess, int i, int j, int k, int l) { - if (f(iblockaccess, i, j, k, l)) { - return true; - } else if (iblockaccess.getType(i, j, k) == Blocks.DIODE_ON) { - int i1 = iblockaccess.getData(i, j, k); - - return l == (i1 & 3); - } else { - return false; - } - } -} diff --git a/src/main/java/net/minecraft/server/BlockReed.java b/src/main/java/net/minecraft/server/BlockReed.java deleted file mode 100644 index a1350f62..00000000 --- a/src/main/java/net/minecraft/server/BlockReed.java +++ /dev/null @@ -1,81 +0,0 @@ -package net.minecraft.server; - -import java.util.Random; - -public class BlockReed extends Block { - - protected BlockReed() { - super(Material.PLANT); - float f = 0.375F; - - this.a(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 1.0F, 0.5F + f); - this.a(true); - } - - public void a(World world, int i, int j, int k, Random random) { - if (world.getType(i, j - 1, k) == Blocks.SUGAR_CANE_BLOCK || this.e(world, i, j, k)) { - if (world.isEmpty(i, j + 1, k)) { - int l; - - for (l = 1; world.getType(i, j - l, k) == this; ++l) { - ; - } - - if (l < 3) { - int i1 = world.getData(i, j, k); - - if (i1 == 15) { - org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(world, i, j + 1, k, this, 0); // CraftBukkit - world.setData(i, j, k, 0, 4); - } else { - world.setData(i, j, k, i1 + 1, 4); - } - } - } - } - } - - public boolean canPlace(World world, int i, int j, int k) { - Block block = world.getType(i, j - 1, k); - - return block == this ? true : (block != Blocks.GRASS && block != Blocks.DIRT && block != Blocks.SAND ? false : (world.getType(i - 1, j - 1, k).getMaterial() == Material.WATER ? true : (world.getType(i + 1, j - 1, k).getMaterial() == Material.WATER ? true : (world.getType(i, j - 1, k - 1).getMaterial() == Material.WATER ? true : world.getType(i, j - 1, k + 1).getMaterial() == Material.WATER)))); - } - - public void doPhysics(World world, int i, int j, int k, Block block) { - this.e(world, i, j, k); - } - - protected final boolean e(World world, int i, int j, int k) { - if (!this.j(world, i, j, k)) { - this.b(world, i, j, k, world.getData(i, j, k), 0); - world.setAir(i, j, k); - return false; - } else { - return true; - } - } - - public boolean j(World world, int i, int j, int k) { - return this.canPlace(world, i, j, k); - } - - public AxisAlignedBB a(World world, int i, int j, int k) { - return null; - } - - public Item getDropType(int i, Random random, int j) { - return Items.SUGAR_CANE; - } - - public boolean c() { - return false; - } - - public boolean d() { - return false; - } - - public int b() { - return 1; - } -} diff --git a/src/main/java/net/minecraft/server/BlockSapling.java b/src/main/java/net/minecraft/server/BlockSapling.java deleted file mode 100644 index 89e60a88..00000000 --- a/src/main/java/net/minecraft/server/BlockSapling.java +++ /dev/null @@ -1,203 +0,0 @@ -package net.minecraft.server; - -import java.util.Random; - -// CraftBukkit start -import java.util.List; - -import org.bukkit.Location; -import org.bukkit.TreeType; -import org.bukkit.block.BlockState; -import org.bukkit.event.world.StructureGrowEvent; -// CraftBukkit end - -public class BlockSapling extends BlockPlant implements IBlockFragilePlantElement { - - public static final String[] a = new String[] { "oak", "spruce", "birch", "jungle", "acacia", "roofed_oak"}; - private static final IIcon[] b = new IIcon[a.length]; - public static TreeType treeType; // CraftBukkit - - protected BlockSapling() { - float f = 0.4F; - - this.a(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f * 2.0F, 0.5F + f); - this.a(CreativeModeTab.c); - } - - public void a(World world, int i, int j, int k, Random random) { - if (!world.isStatic) { - super.a(world, i, j, k, random); - if (world.getLightLevel(i, j + 1, k) >= 9 && random.nextInt(7) == 0) { - // CraftBukkit start - world.captureTreeGeneration = true; - // CraftBukkit end - this.grow(world, i, j, k, random); - // CraftBukkit start - world.captureTreeGeneration = false; - if (world.capturedBlockStates.size() > 0) { - TreeType treeType = BlockSapling.treeType; - BlockSapling.treeType = null; - Location location = new Location(world.getWorld(), i, j, k); - List<BlockState> blocks = (List<BlockState>) world.capturedBlockStates.clone(); - world.capturedBlockStates.clear(); - StructureGrowEvent event = null; - if (treeType != null) { - event = new StructureGrowEvent(location, treeType, false, null, blocks); - org.bukkit.Bukkit.getPluginManager().callEvent(event); - } - if (event == null || !event.isCancelled()) { - for (BlockState blockstate : blocks) { - blockstate.update(true); - } - } - } - // CraftBukkit end - } - } - } - - public void grow(World world, int i, int j, int k, Random random) { - int l = world.getData(i, j, k); - - if ((l & 8) == 0) { - world.setData(i, j, k, l | 8, 4); - } else { - this.d(world, i, j, k, random); - } - } - - public void d(World world, int i, int j, int k, Random random) { - int l = world.getData(i, j, k) & 7; - // CraftBukkit start - Turn ternary operator into if statement to set treeType - // Object object = random.nextInt(10) == 0 ? new WorldGenBigTree(true) : new WorldGenTrees(true); - Object object; - if (random.nextInt(10) == 0) { - treeType = TreeType.BIG_TREE; - object = new WorldGenBigTree(true); - } else { - treeType = TreeType.TREE; - object = new WorldGenTrees(true); - } - // CraftBukkit end - int i1 = 0; - int j1 = 0; - boolean flag = false; - - switch (l) { - case 0: - default: - break; - - case 1: - label78: - for (i1 = 0; i1 >= -1; --i1) { - for (j1 = 0; j1 >= -1; --j1) { - if (this.a(world, i + i1, j, k + j1, 1) && this.a(world, i + i1 + 1, j, k + j1, 1) && this.a(world, i + i1, j, k + j1 + 1, 1) && this.a(world, i + i1 + 1, j, k + j1 + 1, 1)) { - treeType = TreeType.MEGA_REDWOOD; // CraftBukkit - object = new WorldGenMegaTree(false, random.nextBoolean()); - flag = true; - break label78; - } - } - } - - if (!flag) { - j1 = 0; - i1 = 0; - treeType = TreeType.REDWOOD; // CraftBukkit - object = new WorldGenTaiga2(true); - } - break; - - case 2: - treeType = TreeType.BIRCH; // CraftBukkit - object = new WorldGenForest(true, false); - break; - - case 3: - label93: - for (i1 = 0; i1 >= -1; --i1) { - for (j1 = 0; j1 >= -1; --j1) { - if (this.a(world, i + i1, j, k + j1, 3) && this.a(world, i + i1 + 1, j, k + j1, 3) && this.a(world, i + i1, j, k + j1 + 1, 3) && this.a(world, i + i1 + 1, j, k + j1 + 1, 3)) { - treeType = TreeType.JUNGLE; // CraftBukkit - object = new WorldGenJungleTree(true, 10, 20, 3, 3); - flag = true; - break label93; - } - } - } - - if (!flag) { - j1 = 0; - i1 = 0; - treeType = TreeType.SMALL_JUNGLE; // CraftBukkit - object = new WorldGenTrees(true, 4 + random.nextInt(7), 3, 3, false); - } - break; - - case 4: - treeType = TreeType.ACACIA; // CraftBukkit - object = new WorldGenAcaciaTree(true); - break; - - case 5: - label108: - for (i1 = 0; i1 >= -1; --i1) { - for (j1 = 0; j1 >= -1; --j1) { - if (this.a(world, i + i1, j, k + j1, 5) && this.a(world, i + i1 + 1, j, k + j1, 5) && this.a(world, i + i1, j, k + j1 + 1, 5) && this.a(world, i + i1 + 1, j, k + j1 + 1, 5)) { - object = new WorldGenForestTree(true); - treeType = TreeType.DARK_OAK; // CraftBukkit - flag = true; - break label108; - } - } - } - - if (!flag) { - return; - } - } - - Block block = Blocks.AIR; - - if (flag) { - world.setTypeAndData(i + i1, j, k + j1, block, 0, 4); - world.setTypeAndData(i + i1 + 1, j, k + j1, block, 0, 4); - world.setTypeAndData(i + i1, j, k + j1 + 1, block, 0, 4); - world.setTypeAndData(i + i1 + 1, j, k + j1 + 1, block, 0, 4); - } else { - world.setTypeAndData(i, j, k, block, 0, 4); - } - - if (!((WorldGenerator) object).generate(world, random, i + i1, j, k + j1)) { - if (flag) { - world.setTypeAndData(i + i1, j, k + j1, this, l, 4); - world.setTypeAndData(i + i1 + 1, j, k + j1, this, l, 4); - world.setTypeAndData(i + i1, j, k + j1 + 1, this, l, 4); - world.setTypeAndData(i + i1 + 1, j, k + j1 + 1, this, l, 4); - } else { - world.setTypeAndData(i, j, k, this, l, 4); - } - } - } - - public boolean a(World world, int i, int j, int k, int l) { - return world.getType(i, j, k) == this && (world.getData(i, j, k) & 7) == l; - } - - public int getDropData(int i) { - return MathHelper.a(i & 7, 0, 5); - } - - public boolean a(World world, int i, int j, int k, boolean flag) { - return true; - } - - public boolean a(World world, Random random, int i, int j, int k) { - return (double) world.random.nextFloat() < 0.45D; - } - - public void b(World world, Random random, int i, int j, int k) { - this.grow(world, i, j, k, random); - } -} diff --git a/src/main/java/net/minecraft/server/BlockSign.java b/src/main/java/net/minecraft/server/BlockSign.java deleted file mode 100644 index 4ee33197..00000000 --- a/src/main/java/net/minecraft/server/BlockSign.java +++ /dev/null @@ -1,127 +0,0 @@ -package net.minecraft.server; - -import java.util.Random; - -import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit - -public class BlockSign extends BlockContainer { - - private Class a; - private boolean b; - - protected BlockSign(Class oclass, boolean flag) { - super(Material.WOOD); - this.b = flag; - this.a = oclass; - float f = 0.25F; - float f1 = 1.0F; - - this.a(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f1, 0.5F + f); - } - - public AxisAlignedBB a(World world, int i, int j, int k) { - return null; - } - - public void updateShape(IBlockAccess iblockaccess, int i, int j, int k) { - if (!this.b) { - int l = iblockaccess.getData(i, j, k); - float f = 0.28125F; - float f1 = 0.78125F; - float f2 = 0.0F; - float f3 = 1.0F; - float f4 = 0.125F; - - this.a(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); - if (l == 2) { - this.a(f2, f, 1.0F - f4, f3, f1, 1.0F); - } - - if (l == 3) { - this.a(f2, f, 0.0F, f3, f1, f4); - } - - if (l == 4) { - this.a(1.0F - f4, f, f2, 1.0F, f1, f3); - } - - if (l == 5) { - this.a(0.0F, f, f2, f4, f1, f3); - } - } - } - - public int b() { - return -1; - } - - public boolean d() { - return false; - } - - public boolean b(IBlockAccess iblockaccess, int i, int j, int k) { - return true; - } - - public boolean c() { - return false; - } - - public TileEntity a(World world, int i) { - try { - return (TileEntity) this.a.newInstance(); - } catch (Exception exception) { - throw new RuntimeException(exception); - } - } - - public Item getDropType(int i, Random random, int j) { - return Items.SIGN; - } - - public void doPhysics(World world, int i, int j, int k, Block block) { - boolean flag = false; - - if (this.b) { - if (!world.getType(i, j - 1, k).getMaterial().isBuildable()) { - flag = true; - } - } else { - int l = world.getData(i, j, k); - - flag = true; - if (l == 2 && world.getType(i, j, k + 1).getMaterial().isBuildable()) { - flag = false; - } - - if (l == 3 && world.getType(i, j, k - 1).getMaterial().isBuildable()) { - flag = false; - } - - if (l == 4 && world.getType(i + 1, j, k).getMaterial().isBuildable()) { - flag = false; - } - - if (l == 5 && world.getType(i - 1, j, k).getMaterial().isBuildable()) { - flag = false; - } - } - - if (flag) { - this.b(world, i, j, k, world.getData(i, j, k), 0); - world.setAir(i, j, k); - } - - super.doPhysics(world, i, j, k, block); - - // CraftBukkit start - if (block != null && block.isPowerSource()) { - org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(i, j, k); - int power = bukkitBlock.getBlockPower(); - - BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bukkitBlock, power, power); - world.getServer().getPluginManager().callEvent(eventRedstone); - } - // CraftBukkit end - } -} diff --git a/src/main/java/net/minecraft/server/BlockSkull.java b/src/main/java/net/minecraft/server/BlockSkull.java deleted file mode 100644 index 3075dbc8..00000000 --- a/src/main/java/net/minecraft/server/BlockSkull.java +++ /dev/null @@ -1,244 +0,0 @@ -package net.minecraft.server; - -import java.util.Iterator; -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() { - super(Material.ORIENTABLE); - this.a(0.25F, 0.0F, 0.25F, 0.75F, 0.5F, 0.75F); - } - - public int b() { - return -1; - } - - public boolean c() { - return false; - } - - public boolean d() { - 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 a(World world, int i, int j, int k) { - this.updateShape(world, i, j, k); - return super.a(world, i, j, k); - } - - public void postPlace(World world, int i, int j, int k, EntityLiving entityliving, ItemStack itemstack) { - int l = MathHelper.floor((double) (entityliving.yaw * 4.0F / 360.0F) + 2.5D) & 3; - - world.setData(i, j, k, l, 2); - } - - public TileEntity a(World world, int i) { - 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).getSkullType() : super.getDropData(world, i, j, k); - } - - public int getDropData(int i) { - return i; - } - - // CraftBukkit start - Special case dropping so we can get info from the tile entity - public void dropNaturally(World world, int i, int j, int k, int l, float f, int i1) { - if (world.random.nextFloat() < f) { - ItemStack itemstack = new ItemStack(Items.SKULL, 1, this.getDropData(world, i, j, k)); - TileEntitySkull tileentityskull = (TileEntitySkull) world.getTileEntity(i, j, k); - - if (tileentityskull.getSkullType() == 3 && tileentityskull.getGameProfile() != null) { - itemstack.setTag(new NBTTagCompound()); - NBTTagCompound nbttagcompound = new NBTTagCompound(); - - GameProfileSerializer.serialize(nbttagcompound, tileentityskull.getGameProfile()); - itemstack.getTag().set("SkullOwner", nbttagcompound); - } - - this.a(world, i, j, k, itemstack); - } - } - // CraftBukkit end - - 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, 4); - } - - super.a(world, i, j, k, l, entityhuman); - } - - public void remove(World world, int i, int j, int k, Block block, int l) { - if (!world.isStatic) { - // CraftBukkit start - Drop item in code above, not here - // if ((l & 8) == 0) { - if (false) { - // CraftBukkit end - ItemStack itemstack = new ItemStack(Items.SKULL, 1, this.getDropData(world, i, j, k)); - TileEntitySkull tileentityskull = (TileEntitySkull) world.getTileEntity(i, j, k); - - if (tileentityskull.getSkullType() == 3 && tileentityskull.getGameProfile() != null) { - itemstack.setTag(new NBTTagCompound()); - NBTTagCompound nbttagcompound = new NBTTagCompound(); - - GameProfileSerializer.serialize(nbttagcompound, tileentityskull.getGameProfile()); - itemstack.getTag().set("SkullOwner", nbttagcompound); - } - - this.a(world, i, j, k, itemstack); - } - - super.remove(world, i, j, k, block, l); - } - } - - public Item getDropType(int i, Random random, int j) { - return Items.SKULL; - } - - public void a(World world, int i, int j, int k, TileEntitySkull tileentityskull) { - if (tileentityskull.getSkullType() == 1 && j >= 2 && world.difficulty != EnumDifficulty.PEACEFUL && !world.isStatic) { - int l; - EntityWither entitywither; - Iterator iterator; - EntityHuman entityhuman; - int i1; - - for (l = -2; l <= 0; ++l) { - if (world.getType(i, j - 1, k + l) == Blocks.SOUL_SAND && world.getType(i, j - 1, k + l + 1) == Blocks.SOUL_SAND && world.getType(i, j - 2, k + l + 1) == Blocks.SOUL_SAND && world.getType(i, j - 1, k + l + 2) == Blocks.SOUL_SAND && this.a(world, i, j, k + l, 1) && this.a(world, i, j, k + l + 1, 1) && this.a(world, i, j, k + l + 2, 1)) { - // CraftBukkit start - Use BlockStateListPopulator - BlockStateListPopulator blockList = new BlockStateListPopulator(world.getWorld()); - - world.setData(i, j, k + l, 8, 2); - world.setData(i, j, k + l + 1, 8, 2); - world.setData(i, j, k + l + 2, 8, 2); - - blockList.setTypeAndData(i, j, k + l, getById(0), 0, 2); - blockList.setTypeAndData(i, j, k + l + 1, getById(0), 0, 2); - blockList.setTypeAndData(i, j, k + l + 2, getById(0), 0, 2); - blockList.setTypeAndData(i, j - 1, k + l, getById(0), 0, 2); - blockList.setTypeAndData(i, j - 1, k + l + 1, getById(0), 0, 2); - blockList.setTypeAndData(i, j - 1, k + l + 2, getById(0), 0, 2); - blockList.setTypeAndData(i, j - 2, k + l + 1, getById(0), 0, 2); - - if (!world.isStatic) { - entitywither = new EntityWither(world); - entitywither.setPositionRotation((double) i + 0.5D, (double) j - 1.45D, (double) (k + l) + 1.5D, 90.0F, 0.0F); - entitywither.aM = 90.0F; - entitywither.bZ(); - - if (world.addEntity(entitywither, SpawnReason.BUILD_WITHER)) { - if (!world.isStatic) { - iterator = world.a(EntityHuman.class, entitywither.boundingBox.grow(50.0D, 50.0D, 50.0D)).iterator(); - - while (iterator.hasNext()) { - entityhuman = (EntityHuman) iterator.next(); - entityhuman.a((Statistic) AchievementList.I); - } - } - - blockList.updateList(); - } - } - - for (i1 = 0; i1 < 120; ++i1) { - world.addParticle("snowballpoof", (double) i + world.random.nextDouble(), (double) (j - 2) + world.random.nextDouble() * 3.9D, (double) (k + l + 1) + world.random.nextDouble(), 0.0D, 0.0D, 0.0D); - } - // CraftBukkit end - return; - } - } - - for (l = -2; l <= 0; ++l) { - if (world.getType(i + l, j - 1, k) == Blocks.SOUL_SAND && world.getType(i + l + 1, j - 1, k) == Blocks.SOUL_SAND && world.getType(i + l + 1, j - 2, k) == Blocks.SOUL_SAND && world.getType(i + l + 2, j - 1, k) == Blocks.SOUL_SAND && this.a(world, i + l, j, k, 1) && this.a(world, i + l + 1, j, k, 1) && this.a(world, i + l + 2, j, k, 1)) { - // CraftBukkit start - Use BlockStateListPopulator - BlockStateListPopulator blockList = new BlockStateListPopulator(world.getWorld()); - - world.setData(i + l, j, k, 8, 2); - world.setData(i + l + 1, j, k, 8, 2); - world.setData(i + l + 2, j, k, 8, 2); - - blockList.setTypeAndData(i + l, j, k, getById(0), 0, 2); - blockList.setTypeAndData(i + l + 1, j, k, getById(0), 0, 2); - blockList.setTypeAndData(i + l + 2, j, k, getById(0), 0, 2); - blockList.setTypeAndData(i + l, j - 1, k, getById(0), 0, 2); - blockList.setTypeAndData(i + l + 1, j - 1, k, getById(0), 0, 2); - blockList.setTypeAndData(i + l + 2, j - 1, k, getById(0), 0, 2); - blockList.setTypeAndData(i + l + 1, j - 2, k, getById(0), 0, 2); - if (!world.isStatic) { - entitywither = new EntityWither(world); - entitywither.setPositionRotation((double) (i + l) + 1.5D, (double) j - 1.45D, (double) k + 0.5D, 0.0F, 0.0F); - entitywither.bZ(); - - if (world.addEntity(entitywither, SpawnReason.BUILD_WITHER)) { - if (!world.isStatic) { - iterator = world.a(EntityHuman.class, entitywither.boundingBox.grow(50.0D, 50.0D, 50.0D)).iterator(); - - while (iterator.hasNext()) { - entityhuman = (EntityHuman) iterator.next(); - entityhuman.a((Statistic) AchievementList.I); - } - } - blockList.updateList(); - } - } - - for (i1 = 0; i1 < 120; ++i1) { - world.addParticle("snowballpoof", (double) (i + l + 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 a(World world, int i, int j, int k, int l) { - if (world.getType(i, j, k) != this) { - return false; - } else { - TileEntity tileentity = world.getTileEntity(i, j, k); - - return tileentity != null && tileentity instanceof TileEntitySkull ? ((TileEntitySkull) tileentity).getSkullType() == l : false; - } - } -} diff --git a/src/main/java/net/minecraft/server/BlockSnow.java b/src/main/java/net/minecraft/server/BlockSnow.java deleted file mode 100644 index 02f428e5..00000000 --- a/src/main/java/net/minecraft/server/BlockSnow.java +++ /dev/null @@ -1,93 +0,0 @@ -package net.minecraft.server; - -import java.util.Random; - -public class BlockSnow extends Block { - - protected BlockSnow() { - super(Material.PACKED_ICE); - this.a(0.0F, 0.0F, 0.0F, 1.0F, 0.125F, 1.0F); - this.a(true); - this.a(CreativeModeTab.c); - this.b(0); - } - - public AxisAlignedBB a(World world, int i, int j, int k) { - int l = world.getData(i, j, k) & 7; - float f = 0.125F; - - return AxisAlignedBB.a((double) i + this.minX, (double) j + this.minY, (double) k + this.minZ, (double) i + this.maxX, (double) ((float) j + (float) l * f), (double) k + this.maxZ); - } - - public boolean c() { - return false; - } - - public boolean d() { - return false; - } - - public void g() { - this.b(0); - } - - public void updateShape(IBlockAccess iblockaccess, int i, int j, int k) { - this.b(iblockaccess.getData(i, j, k)); - } - - protected void b(int i) { - int j = i & 7; - float f = (float) (2 * (1 + j)) / 16.0F; - - this.a(0.0F, 0.0F, 0.0F, 1.0F, f, 1.0F); - } - - public boolean canPlace(World world, int i, int j, int k) { - Block block = world.getType(i, j - 1, k); - - return block != Blocks.ICE && block != Blocks.PACKED_ICE ? (block.getMaterial() == Material.LEAVES ? true : (block == this && (world.getData(i, j - 1, k) & 7) == 7 ? true : block.c() && block.material.isSolid())) : false; - } - - public void doPhysics(World world, int i, int j, int k, Block block) { - this.m(world, i, j, k); - } - - private boolean m(World world, int i, int j, int k) { - if (!this.canPlace(world, i, j, k)) { - this.b(world, i, j, k, world.getData(i, j, k), 0); - world.setAir(i, j, k); - return false; - } else { - return true; - } - } - - public void a(World world, EntityHuman entityhuman, int i, int j, int k, int l) { - int i1 = l & 7; - - this.a(world, i, j, k, new ItemStack(Items.SNOW_BALL, i1 + 1, 0)); - world.setAir(i, j, k); - entityhuman.a(StatisticList.MINE_BLOCK_COUNT[Block.getId(this)], 1); - } - - public Item getDropType(int i, Random random, int j) { - return Items.SNOW_BALL; - } - - public int a(Random random) { - return 0; - } - - public void a(World world, int i, int j, int k, Random random) { - if (world.b(EnumSkyBlock.BLOCK, i, j, k) > 11) { - // CraftBukkit start - if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world.getWorld().getBlockAt(i, j, k), Blocks.AIR).isCancelled()) { - return; - } - // CraftBukkit end - - this.b(world, i, j, k, world.getData(i, j, k), 0); - world.setAir(i, j, k); - } - } -} diff --git a/src/main/java/net/minecraft/server/BlockSoil.java b/src/main/java/net/minecraft/server/BlockSoil.java deleted file mode 100644 index b234a537..00000000 --- a/src/main/java/net/minecraft/server/BlockSoil.java +++ /dev/null @@ -1,121 +0,0 @@ -package net.minecraft.server; - -import java.util.Random; - -// CraftBukkit start -import org.bukkit.event.entity.EntityInteractEvent; -import org.bukkit.craftbukkit.event.CraftEventFactory; -// CraftBukkit end - -public class BlockSoil extends Block { - - protected BlockSoil() { - super(Material.EARTH); - this.a(true); - this.a(0.0F, 0.0F, 0.0F, 1.0F, 0.9375F, 1.0F); - this.g(255); - } - - public AxisAlignedBB a(World world, int i, int j, int k) { - return AxisAlignedBB.a((double) (i + 0), (double) (j + 0), (double) (k + 0), (double) (i + 1), (double) (j + 1), (double) (k + 1)); - } - - public boolean c() { - return false; - } - - public boolean d() { - return false; - } - - public void a(World world, int i, int j, int k, Random random) { - if (!this.m(world, i, j, k) && !world.isRainingAt(i, j + 1, k)) { - int l = world.getData(i, j, k); - - if (l > 0) { - world.setData(i, j, k, l - 1, 2); - } else if (!this.e(world, i, j, k)) { - // CraftBukkit start - org.bukkit.block.Block block = world.getWorld().getBlockAt(i, j, k); - if (CraftEventFactory.callBlockFadeEvent(block, Blocks.DIRT).isCancelled()) { - return; - } - // CraftBukkit end - - world.setTypeUpdate(i, j, k, Blocks.DIRT); - } - } else { - world.setData(i, j, k, 7, 2); - } - } - - public void a(World world, int i, int j, int k, Entity entity, float f) { - if (!world.isStatic && world.random.nextFloat() < f - 0.5F) { - if (!(entity instanceof EntityHuman) && !world.getGameRules().getBoolean("mobGriefing")) { - return; - } - - // CraftBukkit start - Interact soil - org.bukkit.event.Cancellable cancellable; - if (entity instanceof EntityHuman) { - cancellable = CraftEventFactory.callPlayerInteractEvent((EntityHuman) entity, org.bukkit.event.block.Action.PHYSICAL, i, j, k, -1, null); - } else { - cancellable = new EntityInteractEvent(entity.getBukkitEntity(), world.getWorld().getBlockAt(i, j, k)); - world.getServer().getPluginManager().callEvent((EntityInteractEvent) cancellable); - } - - if (cancellable.isCancelled()) { - return; - } - - if (CraftEventFactory.callEntityChangeBlockEvent(entity, i, j, k, Blocks.DIRT, 0).isCancelled()) { - return; - } - // CraftBukkit end - world.setTypeUpdate(i, j, k, Blocks.DIRT); - } - } - - private boolean e(World world, int i, int j, int k) { - byte b0 = 0; - - for (int l = i - b0; l <= i + b0; ++l) { - for (int i1 = k - b0; i1 <= k + b0; ++i1) { - Block block = world.getType(l, j + 1, i1); - - if (block == Blocks.CROPS || block == Blocks.MELON_STEM || block == Blocks.PUMPKIN_STEM || block == Blocks.POTATOES || block == Blocks.CARROTS) { - return true; - } - } - } - - return false; - } - - private boolean m(World world, int i, int j, int k) { - for (int l = i - 4; l <= i + 4; ++l) { - for (int i1 = j; i1 <= j + 1; ++i1) { - for (int j1 = k - 4; j1 <= k + 4; ++j1) { - if (world.getType(l, i1, j1).getMaterial() == Material.WATER) { - return true; - } - } - } - } - - return false; - } - - public void doPhysics(World world, int i, int j, int k, Block block) { - super.doPhysics(world, i, j, k, block); - Material material = world.getType(i, j + 1, k).getMaterial(); - - if (material.isBuildable()) { - world.setTypeUpdate(i, j, k, Blocks.DIRT); - } - } - - public Item getDropType(int i, Random random, int j) { - return Blocks.DIRT.getDropType(0, random, j); - } -} diff --git a/src/main/java/net/minecraft/server/BlockStationary.java b/src/main/java/net/minecraft/server/BlockStationary.java deleted file mode 100644 index 51b9604a..00000000 --- a/src/main/java/net/minecraft/server/BlockStationary.java +++ /dev/null @@ -1,93 +0,0 @@ -package net.minecraft.server; - -import java.util.Random; - -import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit - -public class BlockStationary extends BlockFluids { - - protected BlockStationary(Material material) { - super(material); - this.a(false); - if (material == Material.LAVA) { - this.a(true); - } - } - - public void doPhysics(World world, int i, int j, int k, Block block) { - super.doPhysics(world, i, j, k, block); - if (world.getType(i, j, k) == this) { - this.n(world, i, j, k); - } - } - - private void n(World world, int i, int j, int k) { - int l = world.getData(i, j, k); - - world.setTypeAndData(i, j, k, Block.getById(Block.getId(this) - 1), l, 2); - world.a(i, j, k, Block.getById(Block.getId(this) - 1), this.a(world)); - } - - public void a(World world, int i, int j, int k, Random random) { - if (this.material == Material.LAVA) { - int l = random.nextInt(3); - - int i1; - - // CraftBukkit start - Prevent lava putting something on fire, remember igniter block coords - int x = i; - int y = j; - int z = k; - // CraftBukkit end - - for (i1 = 0; i1 < l; ++i1) { - i += random.nextInt(3) - 1; - ++j; - k += random.nextInt(3) - 1; - Block block = world.getType(i, j, k); - - if (block.material == Material.AIR) { - if (this.o(world, i - 1, j, k) || this.o(world, i + 1, j, k) || this.o(world, i, j, k - 1) || this.o(world, i, j, k + 1) || this.o(world, i, j - 1, k) || this.o(world, i, j + 1, k)) { - // CraftBukkit start - Prevent lava putting something on fire - if (world.getType(i, j, k) != Blocks.FIRE) { - if (CraftEventFactory.callBlockIgniteEvent(world, i, j, k, x, y, z).isCancelled()) { - continue; - } - } - // CraftBukkit end - - world.setTypeUpdate(i, j, k, Blocks.FIRE); - return; - } - } else if (block.material.isSolid()) { - return; - } - } - - if (l == 0) { - i1 = i; - int j1 = k; - - for (int k1 = 0; k1 < 3; ++k1) { - i = i1 + random.nextInt(3) - 1; - k = j1 + random.nextInt(3) - 1; - if (world.isEmpty(i, j + 1, k) && this.o(world, i, j, k)) { - // CraftBukkit start - Prevent lava putting something on fire - if (world.getType(i, j + 1, k) != Blocks.FIRE) { - if (CraftEventFactory.callBlockIgniteEvent(world, i, j + 1, k, x, y, z).isCancelled()) { - continue; - } - } - // CraftBukkit end - - world.setTypeUpdate(i, j + 1, k, Blocks.FIRE); - } - } - } - } - } - - private boolean o(World world, int i, int j, int k) { - return world.getType(i, j, k).getMaterial().isBurnable(); - } -} diff --git a/src/main/java/net/minecraft/server/BlockStem.java b/src/main/java/net/minecraft/server/BlockStem.java deleted file mode 100644 index 40ad1c65..00000000 --- a/src/main/java/net/minecraft/server/BlockStem.java +++ /dev/null @@ -1,190 +0,0 @@ -package net.minecraft.server; - -import java.util.Random; - -import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit - -public class BlockStem extends BlockPlant implements IBlockFragilePlantElement { - - private final Block blockFruit; - - protected BlockStem(Block block) { - this.blockFruit = block; - this.a(true); - float f = 0.125F; - - this.a(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.25F, 0.5F + f); - this.a((CreativeModeTab) null); - } - - protected boolean a(Block block) { - return block == Blocks.SOIL; - } - - public void a(World world, int i, int j, int k, Random random) { - super.a(world, i, j, k, random); - if (world.getLightLevel(i, j + 1, k) >= 9) { - float f = this.n(world, i, j, k); - - if (random.nextInt((int) (25.0F / f) + 1) == 0) { - int l = world.getData(i, j, k); - - if (l < 7) { - ++l; - CraftEventFactory.handleBlockGrowEvent(world, i, j, k, this, l); // CraftBukkit - } else { - if (world.getType(i - 1, j, k) == this.blockFruit) { - return; - } - - if (world.getType(i + 1, j, k) == this.blockFruit) { - return; - } - - if (world.getType(i, j, k - 1) == this.blockFruit) { - return; - } - - if (world.getType(i, j, k + 1) == this.blockFruit) { - return; - } - - int i1 = random.nextInt(4); - int j1 = i; - int k1 = k; - - if (i1 == 0) { - j1 = i - 1; - } - - if (i1 == 1) { - ++j1; - } - - if (i1 == 2) { - k1 = k - 1; - } - - if (i1 == 3) { - ++k1; - } - - Block block = world.getType(j1, j - 1, k1); - - if (world.getType(j1, j, k1).material == Material.AIR && (block == Blocks.SOIL || block == Blocks.DIRT || block == Blocks.GRASS)) { - CraftEventFactory.handleBlockGrowEvent(world, j1, j, k1, this.blockFruit, 0); // CraftBukkit - } - } - } - } - } - - public void m(World world, int i, int j, int k) { - int l = world.getData(i, j, k) + MathHelper.nextInt(world.random, 2, 5); - - if (l > 7) { - l = 7; - } - - CraftEventFactory.handleBlockGrowEvent(world, i, j, k, this, l); // CraftBukkit - } - - private float n(World world, int i, int j, int k) { - float f = 1.0F; - Block block = world.getType(i, j, k - 1); - Block block1 = world.getType(i, j, k + 1); - Block block2 = world.getType(i - 1, j, k); - Block block3 = world.getType(i + 1, j, k); - Block block4 = world.getType(i - 1, j, k - 1); - Block block5 = world.getType(i + 1, j, k - 1); - Block block6 = world.getType(i + 1, j, k + 1); - Block block7 = world.getType(i - 1, j, k + 1); - boolean flag = block2 == this || block3 == this; - boolean flag1 = block == this || block1 == this; - boolean flag2 = block4 == this || block5 == this || block6 == this || block7 == this; - - for (int l = i - 1; l <= i + 1; ++l) { - for (int i1 = k - 1; i1 <= k + 1; ++i1) { - Block block8 = world.getType(l, j - 1, i1); - float f1 = 0.0F; - - if (block8 == Blocks.SOIL) { - f1 = 1.0F; - if (world.getData(l, j - 1, i1) > 0) { - f1 = 3.0F; - } - } - - if (l != i || i1 != k) { - f1 /= 4.0F; - } - - f += f1; - } - } - - if (flag2 || flag && flag1) { - f /= 2.0F; - } - - return f; - } - - public void g() { - float f = 0.125F; - - this.a(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.25F, 0.5F + f); - } - - public void updateShape(IBlockAccess iblockaccess, int i, int j, int k) { - this.maxY = (double) ((float) (iblockaccess.getData(i, j, k) * 2 + 2) / 16.0F); - float f = 0.125F; - - this.a(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, (float) this.maxY, 0.5F + f); - } - - public int b() { - return 19; - } - - 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, i1); - if (!world.isStatic) { - Item item = null; - - if (this.blockFruit == Blocks.PUMPKIN) { - item = Items.PUMPKIN_SEEDS; - } - - if (this.blockFruit == Blocks.MELON) { - item = Items.MELON_SEEDS; - } - - for (int j1 = 0; j1 < 3; ++j1) { - if (world.random.nextInt(15) <= l) { - this.a(world, i, j, k, new ItemStack(item)); - } - } - } - } - - public Item getDropType(int i, Random random, int j) { - return null; - } - - public int a(Random random) { - return 1; - } - - public boolean a(World world, int i, int j, int k, boolean flag) { - return world.getData(i, j, k) != 7; - } - - public boolean a(World world, Random random, int i, int j, int k) { - return true; - } - - public void b(World world, Random random, int i, int j, int k) { - this.m(world, i, j, k); - } -} diff --git a/src/main/java/net/minecraft/server/BlockTallPlant.java b/src/main/java/net/minecraft/server/BlockTallPlant.java deleted file mode 100644 index f8adc614..00000000 --- a/src/main/java/net/minecraft/server/BlockTallPlant.java +++ /dev/null @@ -1,160 +0,0 @@ -package net.minecraft.server; - -import java.util.Random; - -public class BlockTallPlant extends BlockPlant implements IBlockFragilePlantElement { - - public static final String[] a = new String[] { "sunflower", "syringa", "grass", "fern", "rose", "paeonia"}; - - public BlockTallPlant() { - super(Material.PLANT); - this.c(0.0F); - this.a(h); - this.c("doublePlant"); - } - - public int b() { - return 40; - } - - public void updateShape(IBlockAccess iblockaccess, int i, int j, int k) { - this.a(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); - } - - public int e(IBlockAccess iblockaccess, int i, int j, int k) { - int l = iblockaccess.getData(i, j, k); - - return !c(l) ? l & 7 : iblockaccess.getData(i, j - 1, k) & 7; - } - - public boolean canPlace(World world, int i, int j, int k) { - return super.canPlace(world, i, j, k) && world.isEmpty(i, j + 1, k); - } - - protected void e(World world, int i, int j, int k) { - if (!this.j(world, i, j, k)) { - int l = world.getData(i, j, k); - - if (!c(l)) { - this.b(world, i, j, k, l, 0); - if (world.getType(i, j + 1, k) == this) { - world.setTypeAndData(i, j + 1, k, Blocks.AIR, 0, 2); - } - } - - world.setTypeAndData(i, j, k, Blocks.AIR, 0, 2); - } - } - - public boolean j(World world, int i, int j, int k) { - int l = world.getData(i, j, k); - - return c(l) ? world.getType(i, j - 1, k) == this : world.getType(i, j + 1, k) == this && super.j(world, i, j, k); - } - - public Item getDropType(int i, Random random, int j) { - if (c(i)) { - return null; - } else { - int k = d(i); - - return k != 3 && k != 2 ? Item.getItemOf(this) : null; - } - } - - public int getDropData(int i) { - return c(i) ? 0 : i & 7; - } - - public static boolean c(int i) { - return (i & 8) != 0; - } - - public static int d(int i) { - return i & 7; - } - - public void c(World world, int i, int j, int k, int l, int i1) { - world.setTypeAndData(i, j, k, this, l, i1); - org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(world, i, j + 1, k, this, 8); // CraftBukkit - } - - public void postPlace(World world, int i, int j, int k, EntityLiving entityliving, ItemStack itemstack) { - int l = ((MathHelper.floor((double) (entityliving.yaw * 4.0F / 360.0F) + 0.5D) & 3) + 2) % 4; - - world.setTypeAndData(i, j + 1, k, this, 8 | l, 2); - } - - public void a(World world, EntityHuman entityhuman, int i, int j, int k, int l) { - if (world.isStatic || entityhuman.bF() == null || entityhuman.bF().getItem() != Items.SHEARS || c(l) || !this.b(world, i, j, k, l, entityhuman)) { - super.a(world, entityhuman, i, j, k, l); - } - } - - public void a(World world, int i, int j, int k, int l, EntityHuman entityhuman) { - if (c(l)) { - if (world.getType(i, j - 1, k) == this) { - if (!entityhuman.abilities.canInstantlyBuild) { - int i1 = world.getData(i, j - 1, k); - int j1 = d(i1); - - if (j1 != 3 && j1 != 2) { - world.setAir(i, j - 1, k, true); - } else { - if (!world.isStatic && entityhuman.bF() != null && entityhuman.bF().getItem() == Items.SHEARS) { - this.b(world, i, j, k, i1, entityhuman); - } - - world.setAir(i, j - 1, k); - } - } else { - world.setAir(i, j - 1, k); - } - } - } else if (entityhuman.abilities.canInstantlyBuild && world.getType(i, j + 1, k) == this) { - world.setTypeAndData(i, j + 1, k, Blocks.AIR, 0, 2); - } - - super.a(world, i, j, k, l, entityhuman); - } - - private boolean b(World world, int i, int j, int k, int l, EntityHuman entityhuman) { - int i1 = d(l); - - if (i1 != 3 && i1 != 2) { - return false; - } else { - entityhuman.a(StatisticList.MINE_BLOCK_COUNT[Block.getId(this)], 1); - byte b0 = 1; - - if (i1 == 3) { - b0 = 2; - } - - this.a(world, i, j, k, new ItemStack(Blocks.LONG_GRASS, 2, b0)); - return true; - } - } - - public int getDropData(World world, int i, int j, int k) { - int l = world.getData(i, j, k); - - return c(l) ? d(world.getData(i, j - 1, k)) : d(l); - } - - public boolean a(World world, int i, int j, int k, boolean flag) { - int l = this.e((IBlockAccess) world, i, j, k); - - return l != 2 && l != 3; - } - - public boolean a(World world, Random random, int i, int j, int k) { - return true; - } - - public void b(World world, Random random, int i, int j, int k) { - int l = this.e((IBlockAccess) world, i, j, k); - - this.a(world, i, j, k, new ItemStack(this, 1, l)); - } -} diff --git a/src/main/java/net/minecraft/server/BlockTrapdoor.java b/src/main/java/net/minecraft/server/BlockTrapdoor.java deleted file mode 100644 index ecc429ea..00000000 --- a/src/main/java/net/minecraft/server/BlockTrapdoor.java +++ /dev/null @@ -1,212 +0,0 @@ -package net.minecraft.server; - -import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit - -public class BlockTrapdoor extends Block { - - protected BlockTrapdoor(Material material) { - super(material); - float f = 0.5F; - float f1 = 1.0F; - - this.a(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f1, 0.5F + f); - this.a(CreativeModeTab.d); - } - - public boolean c() { - return false; - } - - public boolean d() { - return false; - } - - public boolean b(IBlockAccess iblockaccess, int i, int j, int k) { - return !d(iblockaccess.getData(i, j, k)); - } - - public int b() { - return 0; - } - - public AxisAlignedBB a(World world, int i, int j, int k) { - this.updateShape(world, i, j, k); - return super.a(world, i, j, k); - } - - public void updateShape(IBlockAccess iblockaccess, int i, int j, int k) { - this.b(iblockaccess.getData(i, j, k)); - } - - public void g() { - float f = 0.1875F; - - this.a(0.0F, 0.5F - f / 2.0F, 0.0F, 1.0F, 0.5F + f / 2.0F, 1.0F); - } - - public void b(int i) { - float f = 0.1875F; - - 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 (d(i)) { - if ((i & 3) == 0) { - this.a(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F); - } - - if ((i & 3) == 1) { - this.a(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f); - } - - if ((i & 3) == 2) { - this.a(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); - } - - if ((i & 3) == 3) { - this.a(0.0F, 0.0F, 0.0F, f, 1.0F, 1.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) { - return true; - } else { - int i1 = world.getData(i, j, k); - - world.setData(i, j, k, i1 ^ 4, 2); - world.a(entityhuman, 1003, i, j, k, 0); - return true; - } - } - - public void setOpen(World world, int i, int j, int k, boolean flag) { - int l = world.getData(i, j, k); - boolean flag1 = (l & 4) > 0; - - if (flag1 != flag) { - world.setData(i, j, k, l ^ 4, 2); - world.a((EntityHuman) null, 1003, i, j, k, 0); - } - } - - public void doPhysics(World world, int i, int j, int k, Block block) { - if (!world.isStatic) { - int l = world.getData(i, j, k); - int i1 = i; - int j1 = k; - - if ((l & 3) == 0) { - j1 = k + 1; - } - - if ((l & 3) == 1) { - --j1; - } - - if ((l & 3) == 2) { - i1 = i + 1; - } - - if ((l & 3) == 3) { - --i1; - } - - if (!a(world.getType(i1, j, j1))) { - world.setAir(i, j, k); - this.b(world, i, j, k, l, 0); - } - - boolean flag = world.isBlockIndirectlyPowered(i, j, k); - - if (flag || block.isPowerSource()) { - // CraftBukkit start - org.bukkit.World bworld = world.getWorld(); - org.bukkit.block.Block bblock = bworld.getBlockAt(i, j, k); - - int power = bblock.getBlockPower(); - int oldPower = (world.getData(i, j, k) & 4) > 0 ? 15 : 0; - - if (oldPower == 0 ^ power == 0 || block.isPowerSource()) { - BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bblock, oldPower, power); - world.getServer().getPluginManager().callEvent(eventRedstone); - flag = eventRedstone.getNewCurrent() > 0; - } - // CraftBukkit end - - this.setOpen(world, i, j, k, flag); - } - } - } - - public MovingObjectPosition a(World world, int i, int j, int k, Vec3D vec3d, Vec3D vec3d1) { - this.updateShape(world, i, j, k); - return super.a(world, i, j, k, vec3d, vec3d1); - } - - public int getPlacedData(World world, int i, int j, int k, int l, float f, float f1, float f2, int i1) { - int j1 = 0; - - if (l == 2) { - j1 = 0; - } - - if (l == 3) { - j1 = 1; - } - - if (l == 4) { - j1 = 2; - } - - if (l == 5) { - j1 = 3; - } - - if (l != 1 && l != 0 && f1 > 0.5F) { - j1 |= 8; - } - - return j1; - } - - public boolean canPlace(World world, int i, int j, int k, int l) { - if (l == 0) { - return false; - } else if (l == 1) { - return false; - } else { - if (l == 2) { - ++k; - } - - if (l == 3) { - --k; - } - - if (l == 4) { - ++i; - } - - if (l == 5) { - --i; - } - - return a(world.getType(i, j, k)); - } - } - - public static boolean d(int i) { - return (i & 4) != 0; - } - - private static boolean a(Block block) { - return block.material.k() && block.d() || block == Blocks.GLOWSTONE || block instanceof BlockStepAbstract || block instanceof BlockStairs; - } -} diff --git a/src/main/java/net/minecraft/server/BlockTripwire.java b/src/main/java/net/minecraft/server/BlockTripwire.java deleted file mode 100644 index cf84d794..00000000 --- a/src/main/java/net/minecraft/server/BlockTripwire.java +++ /dev/null @@ -1,201 +0,0 @@ -package net.minecraft.server; - -import java.util.Iterator; -import java.util.List; -import java.util.Random; - -import org.bukkit.event.entity.EntityInteractEvent; // CraftBukkit - -public class BlockTripwire extends Block { - - public BlockTripwire() { - super(Material.ORIENTABLE); - this.a(0.0F, 0.0F, 0.0F, 1.0F, 0.15625F, 1.0F); - this.a(true); - } - - public int a(World world) { - return 10; - } - - public AxisAlignedBB a(World world, int i, int j, int k) { - return null; - } - - public boolean c() { - return false; - } - - public boolean d() { - return false; - } - - public int b() { - return 30; - } - - public Item getDropType(int i, Random random, int j) { - return Items.STRING; - } - - public void doPhysics(World world, int i, int j, int k, Block block) { - int l = world.getData(i, j, k); - boolean flag = (l & 2) == 2; - boolean flag1 = !World.a((IBlockAccess) world, i, j - 1, k); - - if (flag != flag1) { - this.b(world, i, j, k, l, 0); - world.setAir(i, j, k); - } - } - - public void updateShape(IBlockAccess iblockaccess, int i, int j, int k) { - int l = iblockaccess.getData(i, j, k); - boolean flag = (l & 4) == 4; - boolean flag1 = (l & 2) == 2; - - if (!flag1) { - this.a(0.0F, 0.0F, 0.0F, 1.0F, 0.09375F, 1.0F); - } else if (!flag) { - this.a(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F); - } else { - this.a(0.0F, 0.0625F, 0.0F, 1.0F, 0.15625F, 1.0F); - } - } - - public void onPlace(World world, int i, int j, int k) { - int l = World.a((IBlockAccess) world, i, j - 1, k) ? 0 : 2; - - world.setData(i, j, k, l, 3); - this.a(world, i, j, k, l); - } - - public void remove(World world, int i, int j, int k, Block block, int l) { - this.a(world, i, j, k, l | 1); - } - - public void a(World world, int i, int j, int k, int l, EntityHuman entityhuman) { - if (!world.isStatic) { - if (entityhuman.bF() != null && entityhuman.bF().getItem() == Items.SHEARS) { - world.setData(i, j, k, l | 8, 4); - } - } - } - - private void a(World world, int i, int j, int k, int l) { - int i1 = 0; - - while (i1 < 2) { - int j1 = 1; - - while (true) { - if (j1 < 42) { - int k1 = i + Direction.a[i1] * j1; - int l1 = k + Direction.b[i1] * j1; - Block block = world.getType(k1, j, l1); - - if (block == Blocks.TRIPWIRE_SOURCE) { - int i2 = world.getData(k1, j, l1) & 3; - - if (i2 == Direction.f[i1]) { - Blocks.TRIPWIRE_SOURCE.a(world, k1, j, l1, false, world.getData(k1, j, l1), true, j1, l); - } - } else if (block == Blocks.TRIPWIRE) { - ++j1; - continue; - } - } - - ++i1; - break; - } - } - } - - public void a(World world, int i, int j, int k, Entity entity) { - if (!world.isStatic) { - if ((world.getData(i, j, k) & 1) != 1) { - this.e(world, i, j, k); - } - } - } - - public void a(World world, int i, int j, int k, Random random) { - if (!world.isStatic) { - if ((world.getData(i, j, k) & 1) == 1) { - this.e(world, i, j, k); - } - } - } - - private void e(World world, int i, int j, int k) { - int l = world.getData(i, j, k); - boolean flag = (l & 1) == 1; - boolean flag1 = false; - List list = world.getEntities((Entity) null, AxisAlignedBB.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()) { - Iterator iterator = list.iterator(); - - while (iterator.hasNext()) { - Entity entity = (Entity) iterator.next(); - - if (!entity.az()) { - flag1 = true; - break; - } - } - } - - // CraftBukkit start - Call interact even when triggering connected tripwire - if (flag != flag1 && flag1 && (world.getData(i, j, k) & 4) == 4) { - org.bukkit.World bworld = world.getWorld(); - org.bukkit.plugin.PluginManager manager = world.getServer().getPluginManager(); - org.bukkit.block.Block block = bworld.getBlockAt(i, j, k); - boolean allowed = false; - - // If all of the events are cancelled block the tripwire trigger, else allow - for (Object object : list) { - if (object != null) { - org.bukkit.event.Cancellable cancellable; - - if (object instanceof EntityHuman) { - cancellable = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent((EntityHuman) object, org.bukkit.event.block.Action.PHYSICAL, i, j, k, -1, null); - } else if (object instanceof Entity) { - cancellable = new EntityInteractEvent(((Entity) object).getBukkitEntity(), block); - manager.callEvent((EntityInteractEvent) cancellable); - } else { - continue; - } - - if (!cancellable.isCancelled()) { - allowed = true; - break; - } - } - } - - if (!allowed) { - return; - } - } - // CraftBukkit end - - if (flag1 && !flag) { - l |= 1; - } - - if (!flag1 && flag) { - l &= -2; - } - - if (flag1 != flag) { - world.setData(i, j, k, l, 3); - this.a(world, i, j, k, l); - } - - if (flag1) { - world.a(i, j, k, this, this.a(world)); - } - } -} diff --git a/src/main/java/net/minecraft/server/BlockTripwireHook.java b/src/main/java/net/minecraft/server/BlockTripwireHook.java deleted file mode 100644 index c2342658..00000000 --- a/src/main/java/net/minecraft/server/BlockTripwireHook.java +++ /dev/null @@ -1,300 +0,0 @@ -package net.minecraft.server; - -import java.util.Random; - -import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit - -public class BlockTripwireHook extends Block { - - public BlockTripwireHook() { - super(Material.ORIENTABLE); - this.a(CreativeModeTab.d); - this.a(true); - } - - public AxisAlignedBB a(World world, int i, int j, int k) { - return null; - } - - public boolean c() { - return false; - } - - public boolean d() { - return false; - } - - public int b() { - return 29; - } - - public int a(World world) { - return 10; - } - - public boolean canPlace(World world, int i, int j, int k, int l) { - return l == 2 && world.getType(i, j, k + 1).r() ? true : (l == 3 && world.getType(i, j, k - 1).r() ? true : (l == 4 && world.getType(i + 1, j, k).r() ? true : l == 5 && world.getType(i - 1, j, k).r())); - } - - public boolean canPlace(World world, int i, int j, int k) { - return world.getType(i - 1, j, k).r() ? true : (world.getType(i + 1, j, k).r() ? true : (world.getType(i, j, k - 1).r() ? true : world.getType(i, j, k + 1).r())); - } - - public int getPlacedData(World world, int i, int j, int k, int l, float f, float f1, float f2, int i1) { - byte b0 = 0; - - if (l == 2 && world.c(i, j, k + 1, true)) { - b0 = 2; - } - - if (l == 3 && world.c(i, j, k - 1, true)) { - b0 = 0; - } - - if (l == 4 && world.c(i + 1, j, k, true)) { - b0 = 1; - } - - if (l == 5 && world.c(i - 1, j, k, true)) { - b0 = 3; - } - - return b0; - } - - public void postPlace(World world, int i, int j, int k, int l) { - this.a(world, i, j, k, false, l, false, -1, 0); - } - - public void doPhysics(World world, int i, int j, int k, Block block) { - if (block != this) { - if (this.e(world, i, j, k)) { - int l = world.getData(i, j, k); - int i1 = l & 3; - boolean flag = false; - - if (!world.getType(i - 1, j, k).r() && i1 == 3) { - flag = true; - } - - if (!world.getType(i + 1, j, k).r() && i1 == 1) { - flag = true; - } - - if (!world.getType(i, j, k - 1).r() && i1 == 0) { - flag = true; - } - - if (!world.getType(i, j, k + 1).r() && i1 == 2) { - flag = true; - } - - if (flag) { - this.b(world, i, j, k, l, 0); - world.setAir(i, j, k); - } - } - } - } - - public void a(World world, int i, int j, int k, boolean flag, int l, boolean flag1, int i1, int j1) { - int k1 = l & 3; - boolean flag2 = (l & 4) == 4; - boolean flag3 = (l & 8) == 8; - boolean flag4 = !flag; - boolean flag5 = false; - boolean flag6 = !World.a((IBlockAccess) world, i, j - 1, k); - int l1 = Direction.a[k1]; - int i2 = Direction.b[k1]; - int j2 = 0; - int[] aint = new int[42]; - - int k2; - int l2; - int i3; - int j3; - - for (l2 = 1; l2 < 42; ++l2) { - k2 = i + l1 * l2; - i3 = k + i2 * l2; - Block block = world.getType(k2, j, i3); - - if (block == Blocks.TRIPWIRE_SOURCE) { - j3 = world.getData(k2, j, i3); - if ((j3 & 3) == Direction.f[k1]) { - j2 = l2; - } - break; - } - - if (block != Blocks.TRIPWIRE && l2 != i1) { - aint[l2] = -1; - flag4 = false; - } else { - j3 = l2 == i1 ? j1 : world.getData(k2, j, i3); - boolean flag7 = (j3 & 8) != 8; - boolean flag8 = (j3 & 1) == 1; - boolean flag9 = (j3 & 2) == 2; - - flag4 &= flag9 == flag6; - flag5 |= flag7 && flag8; - aint[l2] = j3; - if (l2 == i1) { - world.a(i, j, k, this, this.a(world)); - flag4 &= flag7; - } - } - } - - flag4 &= j2 > 1; - flag5 &= flag4; - l2 = (flag4 ? 4 : 0) | (flag5 ? 8 : 0); - l = k1 | l2; - int k3; - - if (j2 > 0) { - k2 = i + l1 * j2; - i3 = k + i2 * j2; - k3 = Direction.f[k1]; - world.setData(k2, j, i3, k3 | l2, 3); - this.a(world, k2, j, i3, k3); - this.a(world, k2, j, i3, flag4, flag5, flag2, flag3); - } - - // CraftBukkit start - org.bukkit.block.Block block = world.getWorld().getBlockAt(i, j, k); - - BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, 15, 0); - world.getServer().getPluginManager().callEvent(eventRedstone); - - if (eventRedstone.getNewCurrent() > 0) { - return; - } - // CraftBukkit end - - this.a(world, i, j, k, flag4, flag5, flag2, flag3); - if (!flag) { - world.setData(i, j, k, l, 3); - if (flag1) { - this.a(world, i, j, k, k1); - } - } - - if (flag2 != flag4) { - for (k2 = 1; k2 < j2; ++k2) { - i3 = i + l1 * k2; - k3 = k + i2 * k2; - j3 = aint[k2]; - if (j3 >= 0) { - if (flag4) { - j3 |= 4; - } else { - j3 &= -5; - } - - world.setData(i3, j, k3, j3, 3); - } - } - } - } - - public void a(World world, int i, int j, int k, Random random) { - this.a(world, i, j, k, false, world.getData(i, j, k), true, -1, 0); - } - - private void a(World world, int i, int j, int k, boolean flag, boolean flag1, boolean flag2, boolean flag3) { - if (flag1 && !flag3) { - world.makeSound((double) i + 0.5D, (double) j + 0.1D, (double) k + 0.5D, "random.click", 0.4F, 0.6F); - } else if (!flag1 && flag3) { - world.makeSound((double) i + 0.5D, (double) j + 0.1D, (double) k + 0.5D, "random.click", 0.4F, 0.5F); - } else if (flag && !flag2) { - world.makeSound((double) i + 0.5D, (double) j + 0.1D, (double) k + 0.5D, "random.click", 0.4F, 0.7F); - } else if (!flag && flag2) { - world.makeSound((double) i + 0.5D, (double) j + 0.1D, (double) k + 0.5D, "random.bowhit", 0.4F, 1.2F / (world.random.nextFloat() * 0.2F + 0.9F)); - } - } - - private void a(World world, int i, int j, int k, int l) { - world.applyPhysics(i, j, k, this); - if (l == 3) { - world.applyPhysics(i - 1, j, k, this); - } else if (l == 1) { - world.applyPhysics(i + 1, j, k, this); - } else if (l == 0) { - world.applyPhysics(i, j, k - 1, this); - } else if (l == 2) { - world.applyPhysics(i, j, k + 1, this); - } - } - - private boolean e(World world, int i, int j, int k) { - if (!this.canPlace(world, i, j, k)) { - this.b(world, i, j, k, world.getData(i, j, k), 0); - world.setAir(i, j, k); - return false; - } else { - return true; - } - } - - public void updateShape(IBlockAccess iblockaccess, int i, int j, int k) { - int l = iblockaccess.getData(i, j, k) & 3; - float f = 0.1875F; - - if (l == 3) { - this.a(0.0F, 0.2F, 0.5F - f, f * 2.0F, 0.8F, 0.5F + f); - } else if (l == 1) { - this.a(1.0F - f * 2.0F, 0.2F, 0.5F - f, 1.0F, 0.8F, 0.5F + f); - } else if (l == 0) { - this.a(0.5F - f, 0.2F, 0.0F, 0.5F + f, 0.8F, f * 2.0F); - } else if (l == 2) { - this.a(0.5F - f, 0.2F, 1.0F - f * 2.0F, 0.5F + f, 0.8F, 1.0F); - } - } - - public void remove(World world, int i, int j, int k, Block block, int l) { - boolean flag = (l & 4) == 4; - boolean flag1 = (l & 8) == 8; - - if (flag || flag1) { - this.a(world, i, j, k, true, l, false, -1, 0); - } - - if (flag1) { - world.applyPhysics(i, j, k, this); - int i1 = l & 3; - - if (i1 == 3) { - world.applyPhysics(i - 1, j, k, this); - } else if (i1 == 1) { - world.applyPhysics(i + 1, j, k, this); - } else if (i1 == 0) { - world.applyPhysics(i, j, k - 1, this); - } else if (i1 == 2) { - world.applyPhysics(i, j, k + 1, this); - } - } - - super.remove(world, i, j, k, block, l); - } - - public int b(IBlockAccess iblockaccess, int i, int j, int k, int l) { - return (iblockaccess.getData(i, j, k) & 8) == 8 ? 15 : 0; - } - - public int c(IBlockAccess iblockaccess, int i, int j, int k, int l) { - int i1 = iblockaccess.getData(i, j, k); - - if ((i1 & 8) != 8) { - return 0; - } else { - int j1 = i1 & 3; - - return j1 == 2 && l == 2 ? 15 : (j1 == 0 && l == 3 ? 15 : (j1 == 1 && l == 4 ? 15 : (j1 == 3 && l == 5 ? 15 : 0))); - } - } - - public boolean isPowerSource() { - return true; - } -} diff --git a/src/main/java/net/minecraft/server/BlockVine.java b/src/main/java/net/minecraft/server/BlockVine.java deleted file mode 100644 index ed007140..00000000 --- a/src/main/java/net/minecraft/server/BlockVine.java +++ /dev/null @@ -1,304 +0,0 @@ -package net.minecraft.server; - -import java.util.Random; - -import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit - -public class BlockVine extends Block { - - public BlockVine() { - super(Material.REPLACEABLE_PLANT); - this.a(true); - this.a(CreativeModeTab.c); - } - - public void g() { - this.a(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); - } - - public int b() { - return 20; - } - - public boolean c() { - return false; - } - - public boolean d() { - return false; - } - - public void updateShape(IBlockAccess iblockaccess, int i, int j, int k) { - float f = 0.0625F; - int l = iblockaccess.getData(i, j, k); - float f1 = 1.0F; - float f2 = 1.0F; - float f3 = 1.0F; - float f4 = 0.0F; - float f5 = 0.0F; - float f6 = 0.0F; - boolean flag = l > 0; - - if ((l & 2) != 0) { - f4 = Math.max(f4, 0.0625F); - f1 = 0.0F; - f2 = 0.0F; - f5 = 1.0F; - f3 = 0.0F; - f6 = 1.0F; - flag = true; - } - - if ((l & 8) != 0) { - f1 = Math.min(f1, 0.9375F); - f4 = 1.0F; - f2 = 0.0F; - f5 = 1.0F; - f3 = 0.0F; - f6 = 1.0F; - flag = true; - } - - if ((l & 4) != 0) { - f6 = Math.max(f6, 0.0625F); - f3 = 0.0F; - f1 = 0.0F; - f4 = 1.0F; - f2 = 0.0F; - f5 = 1.0F; - flag = true; - } - - if ((l & 1) != 0) { - f3 = Math.min(f3, 0.9375F); - f6 = 1.0F; - f1 = 0.0F; - f4 = 1.0F; - f2 = 0.0F; - f5 = 1.0F; - flag = true; - } - - if (!flag && this.a(iblockaccess.getType(i, j + 1, k))) { - f2 = Math.min(f2, 0.9375F); - f5 = 1.0F; - f1 = 0.0F; - f4 = 1.0F; - f3 = 0.0F; - f6 = 1.0F; - } - - this.a(f1, f2, f3, f4, f5, f6); - } - - public AxisAlignedBB a(World world, int i, int j, int k) { - return null; - } - - public boolean canPlace(World world, int i, int j, int k, int l) { - switch (l) { - case 1: - return this.a(world.getType(i, j + 1, k)); - - case 2: - return this.a(world.getType(i, j, k + 1)); - - case 3: - return this.a(world.getType(i, j, k - 1)); - - case 4: - return this.a(world.getType(i + 1, j, k)); - - case 5: - return this.a(world.getType(i - 1, j, k)); - - default: - return false; - } - } - - private boolean a(Block block) { - return block.d() && block.material.isSolid(); - } - - private boolean e(World world, int i, int j, int k) { - int l = world.getData(i, j, k); - int i1 = l; - - if (l > 0) { - for (int j1 = 0; j1 <= 3; ++j1) { - int k1 = 1 << j1; - - if ((l & k1) != 0 && !this.a(world.getType(i + Direction.a[j1], j, k + Direction.b[j1])) && (world.getType(i, j + 1, k) != this || (world.getData(i, j + 1, k) & k1) == 0)) { - i1 &= ~k1; - } - } - } - - if (i1 == 0 && !this.a(world.getType(i, j + 1, k))) { - return false; - } else { - if (i1 != l) { - world.setData(i, j, k, i1, 2); - } - - return true; - } - } - - public void doPhysics(World world, int i, int j, int k, Block block) { - if (!world.isStatic && !this.e(world, i, j, k)) { - this.b(world, i, j, k, world.getData(i, j, k), 0); - world.setAir(i, j, k); - } - } - - public void a(World world, int i, int j, int k, Random random) { - if (!world.isStatic && world.random.nextInt(4) == 0) { - byte b0 = 4; - int l = 5; - boolean flag = false; - - int i1; - int j1; - int k1; - - label134: - for (i1 = i - b0; i1 <= i + b0; ++i1) { - for (j1 = k - b0; j1 <= k + b0; ++j1) { - for (k1 = j - 1; k1 <= j + 1; ++k1) { - if (world.getType(i1, k1, j1) == this) { - --l; - if (l <= 0) { - flag = true; - break label134; - } - } - } - } - } - - i1 = world.getData(i, j, k); - j1 = world.random.nextInt(6); - k1 = Direction.e[j1]; - int l1; - - if (j1 == 1 && j < 255 && world.isEmpty(i, j + 1, k)) { - if (flag) { - return; - } - - int i2 = world.random.nextInt(16) & i1; - - if (i2 > 0) { - for (l1 = 0; l1 <= 3; ++l1) { - if (!this.a(world.getType(i + Direction.a[l1], j + 1, k + Direction.b[l1]))) { - i2 &= ~(1 << l1); - } - } - - if (i2 > 0) { - // CraftBukkit start - Call BlockSpreadEvent - org.bukkit.block.Block source = world.getWorld().getBlockAt(i, j, k); - org.bukkit.block.Block block = world.getWorld().getBlockAt(i, j + 1, k); - CraftEventFactory.handleBlockSpreadEvent(block, source, this, l1); - // CraftBukkit end - } - } - } else { - Block block; - int j2; - - if (j1 >= 2 && j1 <= 5 && (i1 & 1 << k1) == 0) { - if (flag) { - return; - } - - block = world.getType(i + Direction.a[k1], j, k + Direction.b[k1]); - if (block.material == Material.AIR) { - l1 = k1 + 1 & 3; - j2 = k1 + 3 & 3; - - // CraftBukkit start - Call BlockSpreadEvent - org.bukkit.block.Block source = world.getWorld().getBlockAt(i, j, k); - org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(i + Direction.a[k1], j, k + Direction.b[k1]); - if ((i1 & 1 << l1) != 0 && this.a(world.getType(i + Direction.a[k1] + Direction.a[l1], j, k + Direction.b[k1] + Direction.b[l1]))) { - CraftEventFactory.handleBlockSpreadEvent(bukkitBlock, source, this, 1 << l1); - } else if ((i1 & 1 << j2) != 0 && this.a(world.getType(i + Direction.a[k1] + Direction.a[j2], j, k + Direction.b[k1] + Direction.b[j2]))) { - CraftEventFactory.handleBlockSpreadEvent(bukkitBlock, source, this, 1 << j2); - } else if ((i1 & 1 << l1) != 0 && world.isEmpty(i + Direction.a[k1] + Direction.a[l1], j, k + Direction.b[k1] + Direction.b[l1]) && this.a(world.getType(i + Direction.a[l1], j, k + Direction.b[l1]))) { - bukkitBlock = world.getWorld().getBlockAt(i + Direction.a[k1] + Direction.a[l1], j, k + Direction.b[k1] + Direction.b[l1]); - CraftEventFactory.handleBlockSpreadEvent(bukkitBlock, source, this, 1 << (k1 + 2 & 3)); - } else if ((i1 & 1 << j2) != 0 && world.isEmpty(i + Direction.a[k1] + Direction.a[j2], j, k + Direction.b[k1] + Direction.b[j2]) && this.a(world.getType(i + Direction.a[j2], j, k + Direction.b[j2]))) { - bukkitBlock = world.getWorld().getBlockAt(i + Direction.a[k1] + Direction.a[j2], j, k + Direction.b[k1] + Direction.b[j2]); - CraftEventFactory.handleBlockSpreadEvent(bukkitBlock, source, this, 1 << (k1 + 2 & 3)); - } else if (this.a(world.getType(i + Direction.a[k1], j + 1, k + Direction.b[k1]))) { - CraftEventFactory.handleBlockSpreadEvent(bukkitBlock, source, this, 0); - } - // CraftBukkit end - } else if (block.material.k() && block.d()) { - world.setData(i, j, k, i1 | 1 << k1, 2); - } - } else if (j > 1) { - block = world.getType(i, j - 1, k); - if (block.material == Material.AIR) { - l1 = world.random.nextInt(16) & i1; - if (l1 > 0) { - // CraftBukkit start - Call BlockSpreadEvent - org.bukkit.block.Block source = world.getWorld().getBlockAt(i, j, k); - org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(i, j - 1, k); - CraftEventFactory.handleBlockSpreadEvent(bukkitBlock, source, this, l1); - // CraftBukkit end - } - } else if (block == this) { - l1 = world.random.nextInt(16) & i1; - j2 = world.getData(i, j - 1, k); - if (j2 != (j2 | l1)) { - world.setData(i, j - 1, k, j2 | l1, 2); - } - } - } - } - } - } - - public int getPlacedData(World world, int i, int j, int k, int l, float f, float f1, float f2, int i1) { - byte b0 = 0; - - switch (l) { - case 2: - b0 = 1; - break; - - case 3: - b0 = 4; - break; - - case 4: - b0 = 8; - break; - - case 5: - b0 = 2; - } - - return b0 != 0 ? b0 : i1; - } - - public Item getDropType(int i, Random random, int j) { - return null; - } - - public int a(Random random) { - return 0; - } - - public void a(World world, EntityHuman entityhuman, int i, int j, int k, int l) { - if (!world.isStatic && entityhuman.bF() != null && entityhuman.bF().getItem() == Items.SHEARS) { - entityhuman.a(StatisticList.MINE_BLOCK_COUNT[Block.getId(this)], 1); - this.a(world, i, j, k, new ItemStack(Blocks.VINE, 1, 0)); - } else { - super.a(world, entityhuman, i, j, k, l); - } - } -} diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java deleted file mode 100644 index 3ac0ae47..00000000 --- a/src/main/java/net/minecraft/server/Chunk.java +++ /dev/null @@ -1,1093 +0,0 @@ -package net.minecraft.server; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Random; -import java.util.concurrent.Callable; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import org.bukkit.Bukkit; // CraftBukkit - -public class Chunk { - - private static final Logger t = LogManager.getLogger(); - public static boolean a; - private ChunkSection[] sections; - private byte[] v; - public int[] b; - public boolean[] c; - public boolean d; - public World world; - public int[] heightMap; - public final int locX; - public final int locZ; - private boolean w; - public Map tileEntities; - public List[] entitySlices; - public boolean done; - public boolean lit; - public boolean m; - public boolean n; - public boolean o; - public long lastSaved; - public boolean q; - public int r; - public long s; - private int x; - - // CraftBukkit start - Neighbor loaded cache for chunk lighting and entity ticking - private int neighbors = 0x1 << 12; - - public boolean areNeighborsLoaded(final int radius) { - switch(radius) { - case 2: - return this.neighbors == Integer.MAX_VALUE >> 6; - case 1: - final int mask = - // x z offset x z offset x z offset - ( 0x1 << (1 * 5 + 1 + 12) ) | ( 0x1 << (0 * 5 + 1 + 12) ) | ( 0x1 << (-1 * 5 + 1 + 12) ) | - ( 0x1 << (1 * 5 + 0 + 12) ) | ( 0x1 << (0 * 5 + 0 + 12) ) | ( 0x1 << (-1 * 5 + 0 + 12) ) | - ( 0x1 << (1 * 5 + -1 + 12) ) | ( 0x1 << (0 * 5 + -1 + 12) ) | ( 0x1 << (-1 * 5 + -1 + 12) ); - return (this.neighbors & mask) == mask; - default: - throw new UnsupportedOperationException(String.valueOf(radius)); - } - } - - public void setNeighborLoaded(final int x, final int z) { - this.neighbors |= 0x1 << (x * 5 + 12 + z); - } - - public void setNeighborUnloaded(final int x, final int z) { - this.neighbors &= ~(0x1 << (x * 5 + 12 + z)); - } - // CraftBukkit end - - public Chunk(World world, int i, int j) { - this.sections = new ChunkSection[16]; - this.v = new byte[256]; - this.b = new int[256]; - this.c = new boolean[256]; - this.tileEntities = new HashMap(); - this.x = 4096; - this.entitySlices = new List[16]; - this.world = world; - this.locX = i; - this.locZ = j; - this.heightMap = new int[256]; - - for (int k = 0; k < this.entitySlices.length; ++k) { - this.entitySlices[k] = new org.bukkit.craftbukkit.util.UnsafeList(); // CraftBukkit - ArrayList -> UnsafeList - } - - Arrays.fill(this.b, -999); - Arrays.fill(this.v, (byte) -1); - - // CraftBukkit start - if (!(this instanceof EmptyChunk)) { - this.bukkitChunk = new org.bukkit.craftbukkit.CraftChunk(this); - } - } - - public org.bukkit.Chunk bukkitChunk; - public boolean mustSave; - // CraftBukkit end - - public Chunk(World world, Block[] ablock, int i, int j) { - this(world, i, j); - int k = ablock.length / 256; - boolean flag = !world.worldProvider.g; - - for (int l = 0; l < 16; ++l) { - for (int i1 = 0; i1 < 16; ++i1) { - for (int j1 = 0; j1 < k; ++j1) { - Block block = ablock[l << 11 | i1 << 7 | j1]; - - if (block != null && block.getMaterial() != Material.AIR) { - int k1 = j1 >> 4; - - if (this.sections[k1] == null) { - this.sections[k1] = new ChunkSection(k1 << 4, flag); - } - - this.sections[k1].setTypeId(l, j1 & 15, i1, block); - } - } - } - } - } - - public Chunk(World world, Block[] ablock, byte[] abyte, int i, int j) { - this(world, i, j); - int k = ablock.length / 256; - boolean flag = !world.worldProvider.g; - - for (int l = 0; l < 16; ++l) { - for (int i1 = 0; i1 < 16; ++i1) { - for (int j1 = 0; j1 < k; ++j1) { - int k1 = l * k * 16 | i1 * k | j1; - Block block = ablock[k1]; - - if (block != null && block != Blocks.AIR) { - int l1 = j1 >> 4; - - if (this.sections[l1] == null) { - this.sections[l1] = new ChunkSection(l1 << 4, flag); - } - - this.sections[l1].setTypeId(l, j1 & 15, i1, block); - this.sections[l1].setData(l, j1 & 15, i1, abyte[k1]); - } - } - } - } - } - - public boolean a(int i, int j) { - return i == this.locX && j == this.locZ; - } - - public int b(int i, int j) { - return this.heightMap[j << 4 | i]; - } - - public int h() { - for (int i = this.sections.length - 1; i >= 0; --i) { - if (this.sections[i] != null) { - return this.sections[i].getYPosition(); - } - } - - return 0; - } - - public ChunkSection[] getSections() { - return this.sections; - } - - public void initLighting() { - int i = this.h(); - - this.r = Integer.MAX_VALUE; - - for (int j = 0; j < 16; ++j) { - int k = 0; - - while (k < 16) { - this.b[j + (k << 4)] = -999; - int l = i + 16 - 1; - - while (true) { - if (l > 0) { - if (this.b(j, l - 1, k) == 0) { - --l; - continue; - } - - this.heightMap[k << 4 | j] = l; - if (l < this.r) { - this.r = l; - } - } - - if (!this.world.worldProvider.g) { - l = 15; - int i1 = i + 16 - 1; - - do { - int j1 = this.b(j, i1, k); - - if (j1 == 0 && l != 15) { - j1 = 1; - } - - l -= j1; - if (l > 0) { - ChunkSection chunksection = this.sections[i1 >> 4]; - - if (chunksection != null) { - chunksection.setSkyLight(j, i1 & 15, k, l); - this.world.m((this.locX << 4) + j, i1, (this.locZ << 4) + k); - } - } - - --i1; - } while (i1 > 0 && l > 0); - } - - ++k; - break; - } - } - } - - this.n = true; - } - - private void e(int i, int j) { - this.c[i + j * 16] = true; - this.w = true; - } - - private void c(boolean flag) { - this.world.methodProfiler.a("recheckGaps"); - if (this.world.areChunksLoaded(this.locX * 16 + 8, 0, this.locZ * 16 + 8, 16)) { - for (int i = 0; i < 16; ++i) { - for (int j = 0; j < 16; ++j) { - if (this.c[i + j * 16]) { - this.c[i + j * 16] = false; - int k = this.b(i, j); - int l = this.locX * 16 + i; - int i1 = this.locZ * 16 + j; - 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; - } - - if (l1 < j1) { - j1 = l1; - } - - if (i2 < j1) { - j1 = i2; - } - - this.g(l, i1, j1); - this.g(l - 1, i1, k); - this.g(l + 1, i1, k); - this.g(l, i1 - 1, k); - this.g(l, i1 + 1, k); - if (flag) { - this.world.methodProfiler.b(); - return; - } - } - } - } - - this.w = false; - } - - this.world.methodProfiler.b(); - } - - private void g(int i, int j, int k) { - int l = this.world.getHighestBlockYAt(i, j); - - if (l > k) { - this.c(i, j, k, l + 1); - } else if (l < k) { - this.c(i, j, l, k + 1); - } - } - - private void c(int i, int j, int k, int l) { - if (l > k && this.world.areChunksLoaded(i, 0, j, 16)) { - for (int i1 = k; i1 < l; ++i1) { - this.world.c(EnumSkyBlock.SKY, i, i1, j); - } - - this.n = true; - } - } - - private void h(int i, int j, int k) { - int l = this.heightMap[k << 4 | i] & 255; - int i1 = l; - - if (j > l) { - i1 = j; - } - - while (i1 > 0 && this.b(i, i1 - 1, k) == 0) { - --i1; - } - - if (i1 != l) { - this.world.b(i + this.locX * 16, k + this.locZ * 16, i1, l); - this.heightMap[k << 4 | i] = i1; - int j1 = this.locX * 16 + i; - int k1 = this.locZ * 16 + k; - int l1; - int i2; - - if (!this.world.worldProvider.g) { - ChunkSection chunksection; - - if (i1 < l) { - for (l1 = i1; l1 < l; ++l1) { - chunksection = this.sections[l1 >> 4]; - if (chunksection != null) { - chunksection.setSkyLight(i, l1 & 15, k, 15); - this.world.m((this.locX << 4) + i, l1, (this.locZ << 4) + k); - } - } - } else { - for (l1 = l; l1 < i1; ++l1) { - chunksection = this.sections[l1 >> 4]; - if (chunksection != null) { - chunksection.setSkyLight(i, l1 & 15, k, 0); - this.world.m((this.locX << 4) + i, l1, (this.locZ << 4) + k); - } - } - } - - l1 = 15; - - while (i1 > 0 && l1 > 0) { - --i1; - i2 = this.b(i, i1, k); - if (i2 == 0) { - i2 = 1; - } - - l1 -= i2; - if (l1 < 0) { - l1 = 0; - } - - ChunkSection chunksection1 = this.sections[i1 >> 4]; - - if (chunksection1 != null) { - chunksection1.setSkyLight(i, i1 & 15, k, l1); - } - } - } - - l1 = this.heightMap[k << 4 | i]; - i2 = l; - int j2 = l1; - - if (l1 < l) { - i2 = l1; - j2 = l; - } - - if (l1 < this.r) { - this.r = l1; - } - - if (!this.world.worldProvider.g) { - this.c(j1 - 1, k1, i2, j2); - this.c(j1 + 1, k1, i2, j2); - this.c(j1, k1 - 1, i2, j2); - this.c(j1, k1 + 1, i2, j2); - this.c(j1, k1, i2, j2); - } - - this.n = true; - } - } - - public int b(int i, int j, int k) { - return this.getType(i, j, k).k(); - } - - public Block getType(int i, int j, int k) { - Block block = Blocks.AIR; - - if (j >> 4 < this.sections.length) { - ChunkSection chunksection = this.sections[j >> 4]; - - if (chunksection != null) { - try { - block = chunksection.getTypeId(i, j & 15, k); - } catch (Throwable throwable) { - CrashReport crashreport = CrashReport.a(throwable, "Getting block"); - CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Block being got"); - - crashreportsystemdetails.a("Location", (Callable) (new CrashReportLocation(this, i, j, k))); - throw new ReportedException(crashreport); - } - } - } - - return block; - } - - public int getData(int i, int j, int k) { - if (j >> 4 >= this.sections.length) { - return 0; - } else { - ChunkSection chunksection = this.sections[j >> 4]; - - return chunksection != null ? chunksection.getData(i, j & 15, k) : 0; - } - } - - public boolean a(int i, int j, int k, Block block, int l) { - int i1 = k << 4 | i; - - if (j >= this.b[i1] - 1) { - this.b[i1] = -999; - } - - int j1 = this.heightMap[i1]; - Block block1 = this.getType(i, j, k); - int k1 = this.getData(i, j, k); - - if (block1 == block && k1 == l) { - return false; - } else { - ChunkSection chunksection = this.sections[j >> 4]; - boolean flag = false; - - if (chunksection == null) { - if (block == Blocks.AIR) { - return false; - } - - chunksection = this.sections[j >> 4] = new ChunkSection(j >> 4 << 4, !this.world.worldProvider.g); - flag = j >= j1; - } - - int l1 = this.locX * 16 + i; - int i2 = this.locZ * 16 + k; - - if (!this.world.isStatic) { - block1.f(this.world, l1, j, i2, k1); - } - - // CraftBukkit start - Delay removing containers until after they're cleaned up - if (!(block1 instanceof IContainer)) { - chunksection.setTypeId(i, j & 15, k, block); - } - // CraftBukkit end - - if (!this.world.isStatic) { - block1.remove(this.world, l1, j, i2, block1, k1); - } else if (block1 instanceof IContainer && block1 != block) { - this.world.p(l1, j, i2); - } - - // CraftBukkit start - Remove containers now after cleanup - if (block1 instanceof IContainer) { - chunksection.setTypeId(i, j & 15, k, block); - } - // CraftBukkit end - - if (chunksection.getTypeId(i, j & 15, k) != block) { - return false; - } else { - chunksection.setData(i, j & 15, k, l); - if (flag) { - this.initLighting(); - } else { - int j2 = block.k(); - int k2 = block1.k(); - - if (j2 > 0) { - if (j >= j1) { - this.h(i, j + 1, k); - } - } else if (j == j1 - 1) { - this.h(i, j, k); - } - - if (j2 != k2 && (j2 < k2 || this.getBrightness(EnumSkyBlock.SKY, i, j, k) > 0 || this.getBrightness(EnumSkyBlock.BLOCK, i, j, k) > 0)) { - this.e(i, k); - } - } - - TileEntity tileentity; - - if (block1 instanceof IContainer) { - tileentity = this.e(i, j, k); - if (tileentity != null) { - tileentity.u(); - } - } - - // CraftBukkit - Don't place while processing the BlockPlaceEvent, unless it's a BlockContainer. Prevents blocks such as TNT from activating when cancelled. - if (!this.world.isStatic && (!this.world.captureBlockStates || block instanceof BlockContainer)) { - block.onPlace(this.world, l1, j, i2); - } - - if (block instanceof IContainer) { - - tileentity = this.e(i, j, k); - if (tileentity == null) { - tileentity = ((IContainer) block).a(this.world, l); - this.world.setTileEntity(l1, j, i2, tileentity); - } - - if (tileentity != null) { - tileentity.u(); - } - } - - this.n = true; - return true; - } - } - } - - public boolean a(int i, int j, int k, int l) { - ChunkSection chunksection = this.sections[j >> 4]; - - if (chunksection == null) { - return false; - } else { - int i1 = chunksection.getData(i, j & 15, k); - - if (i1 == l) { - return false; - } else { - this.n = true; - chunksection.setData(i, j & 15, k, l); - if (chunksection.getTypeId(i, j & 15, k) instanceof IContainer) { - TileEntity tileentity = this.e(i, j, k); - - if (tileentity != null) { - tileentity.u(); - tileentity.g = l; - } - } - - return true; - } - } - } - - public int getBrightness(EnumSkyBlock enumskyblock, int i, int j, int k) { - ChunkSection chunksection = this.sections[j >> 4]; - - return chunksection == null ? (this.d(i, j, k) ? enumskyblock.c : 0) : (enumskyblock == EnumSkyBlock.SKY ? (this.world.worldProvider.g ? 0 : chunksection.getSkyLight(i, j & 15, k)) : (enumskyblock == EnumSkyBlock.BLOCK ? chunksection.getEmittedLight(i, j & 15, k) : enumskyblock.c)); - } - - public void a(EnumSkyBlock enumskyblock, int i, int j, int k, int l) { - ChunkSection chunksection = this.sections[j >> 4]; - - if (chunksection == null) { - chunksection = this.sections[j >> 4] = new ChunkSection(j >> 4 << 4, !this.world.worldProvider.g); - this.initLighting(); - } - - this.n = true; - if (enumskyblock == EnumSkyBlock.SKY) { - if (!this.world.worldProvider.g) { - chunksection.setSkyLight(i, j & 15, k, l); - } - } else if (enumskyblock == EnumSkyBlock.BLOCK) { - chunksection.setEmittedLight(i, j & 15, k, l); - } - } - - public int b(int i, int j, int k, int l) { - ChunkSection chunksection = this.sections[j >> 4]; - - if (chunksection == null) { - return !this.world.worldProvider.g && l < EnumSkyBlock.SKY.c ? EnumSkyBlock.SKY.c - l : 0; - } else { - int i1 = this.world.worldProvider.g ? 0 : chunksection.getSkyLight(i, j & 15, k); - - if (i1 > 0) { - a = true; - } - - i1 -= l; - int j1 = chunksection.getEmittedLight(i, j & 15, k); - - if (j1 > i1) { - i1 = j1; - } - - return i1; - } - } - - public void a(Entity entity) { - this.o = true; - int i = MathHelper.floor(entity.locX / 16.0D); - int j = MathHelper.floor(entity.locZ / 16.0D); - - if (i != this.locX || j != this.locZ) { - // CraftBukkit start - Bukkit.getLogger().warning("Wrong location for " + entity + " in world '" + world.getWorld().getName() + "'!"); - // t.warn("Wrong location! " + entity + " (at " + i + ", " + j + " instead of " + this.locX + ", " + this.locZ + ")"); - // Thread.dumpStack(); - Bukkit.getLogger().warning("Entity is at " + entity.locX + "," + entity.locZ + " (chunk " + i + "," + j + ") but was stored in chunk " + this.locX + "," + this.locZ); - // CraftBukkit end - } - - int k = MathHelper.floor(entity.locY / 16.0D); - - if (k < 0) { - k = 0; - } - - if (k >= this.entitySlices.length) { - k = this.entitySlices.length - 1; - } - - entity.ag = true; - entity.ah = this.locX; - entity.ai = k; - entity.aj = this.locZ; - this.entitySlices[k].add(entity); - } - - public void b(Entity entity) { - this.a(entity, entity.ai); - } - - public void a(Entity entity, int i) { - if (i < 0) { - i = 0; - } - - if (i >= this.entitySlices.length) { - i = this.entitySlices.length - 1; - } - - this.entitySlices[i].remove(entity); - } - - public boolean d(int i, int j, int k) { - return j >= this.heightMap[k << 4 | i]; - } - - public TileEntity e(int i, int j, int k) { - ChunkPosition chunkposition = new ChunkPosition(i, j, k); - TileEntity tileentity = (TileEntity) this.tileEntities.get(chunkposition); - - if (tileentity == null) { - Block block = this.getType(i, j, k); - - if (!block.isTileEntity()) { - return null; - } - - tileentity = ((IContainer) block).a(this.world, this.getData(i, j, k)); - this.world.setTileEntity(this.locX * 16 + i, j, this.locZ * 16 + k, tileentity); - } - - if (tileentity != null && tileentity.r()) { - this.tileEntities.remove(chunkposition); - return null; - } else { - return tileentity; - } - } - - public void a(TileEntity tileentity) { - int i = tileentity.x - this.locX * 16; - int j = tileentity.y; - int k = tileentity.z - this.locZ * 16; - - this.a(i, j, k, tileentity); - if (this.d) { - this.world.tileEntityList.add(tileentity); - } - } - - public void a(int i, int j, int k, TileEntity tileentity) { - ChunkPosition chunkposition = new ChunkPosition(i, j, k); - - tileentity.a(this.world); - tileentity.x = this.locX * 16 + i; - tileentity.y = j; - tileentity.z = this.locZ * 16 + k; - if (this.getType(i, j, k) instanceof IContainer) { - if (this.tileEntities.containsKey(chunkposition)) { - ((TileEntity) this.tileEntities.get(chunkposition)).s(); - } - - tileentity.t(); - this.tileEntities.put(chunkposition, tileentity); - // CraftBukkit start - } else { - System.out.println("Attempted to place a tile entity (" + tileentity + ") at " + tileentity.x + "," + tileentity.y + "," + tileentity.z - + " (" + org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(getType(i, j, k)) + ") where there was no entity tile!"); - System.out.println("Chunk coordinates: " + (this.locX * 16) + "," + (this.locZ * 16)); - new Exception().printStackTrace(); - // CraftBukkit end - } - } - - public void f(int i, int j, int k) { - ChunkPosition chunkposition = new ChunkPosition(i, j, k); - - if (this.d) { - TileEntity tileentity = (TileEntity) this.tileEntities.remove(chunkposition); - - if (tileentity != null) { - tileentity.s(); - } - } - } - - public void addEntities() { - this.d = true; - this.world.a(this.tileEntities.values()); - - for (int i = 0; i < this.entitySlices.length; ++i) { - Iterator iterator = this.entitySlices[i].iterator(); - - while (iterator.hasNext()) { - Entity entity = (Entity) iterator.next(); - - entity.X(); - } - - this.world.a(this.entitySlices[i]); - } - } - - public void removeEntities() { - this.d = false; - Iterator iterator = this.tileEntities.values().iterator(); - - while (iterator.hasNext()) { - TileEntity tileentity = (TileEntity) iterator.next(); - - this.world.a(tileentity); - } - - for (int i = 0; i < this.entitySlices.length; ++i) { - // CraftBukkit start - java.util.Iterator<Object> iter = this.entitySlices[i].iterator(); - while (iter.hasNext()) { - Entity entity = (Entity) iter.next(); - - // Do not pass along players, as doing so can get them stuck outside of time. - // (which for example disables inventory icon updates and prevents block breaking) - if (entity instanceof EntityPlayer) { - iter.remove(); - } - } - // CraftBukkit end - - this.world.b(this.entitySlices[i]); - } - } - - public void e() { - this.n = true; - } - - public void a(Entity entity, 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); - - i = MathHelper.a(i, 0, this.entitySlices.length - 1); - j = MathHelper.a(j, 0, this.entitySlices.length - 1); - - for (int k = i; k <= j; ++k) { - List list1 = this.entitySlices[k]; - - for (int l = 0; l < list1.size(); ++l) { - Entity entity1 = (Entity) list1.get(l); - - if (entity1 != entity && entity1.boundingBox.b(axisalignedbb) && (ientityselector == null || ientityselector.a(entity1))) { - list.add(entity1); - Entity[] aentity = entity1.at(); - - if (aentity != null) { - for (int i1 = 0; i1 < aentity.length; ++i1) { - entity1 = aentity[i1]; - if (entity1 != entity && entity1.boundingBox.b(axisalignedbb) && (ientityselector == null || ientityselector.a(entity1))) { - list.add(entity1); - } - } - } - } - } - } - } - - 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); - - i = MathHelper.a(i, 0, this.entitySlices.length - 1); - j = MathHelper.a(j, 0, this.entitySlices.length - 1); - - for (int k = i; k <= j; ++k) { - List list1 = this.entitySlices[k]; - - for (int l = 0; l < list1.size(); ++l) { - Entity entity = (Entity) list1.get(l); - - if (oclass.isAssignableFrom(entity.getClass()) && entity.boundingBox.b(axisalignedbb) && (ientityselector == null || ientityselector.a(entity))) { - list.add(entity); - } - } - } - } - - public boolean a(boolean flag) { - if (flag) { - if (this.o && this.world.getTime() != this.lastSaved || this.n) { - return true; - } - } else if (this.o && this.world.getTime() >= this.lastSaved + 600L) { - return true; - } - - return this.n; - } - - public Random a(long i) { - return new Random(this.world.getSeed() + (long) (this.locX * this.locX * 4987142) + (long) (this.locX * 5947611) + (long) (this.locZ * this.locZ) * 4392871L + (long) (this.locZ * 389711) ^ i); - } - - public boolean isEmpty() { - return false; - } - - public void loadNearby(IChunkProvider ichunkprovider, IChunkProvider ichunkprovider1, int i, int j) { - if (!this.done && ichunkprovider.isChunkLoaded(i + 1, j + 1) && ichunkprovider.isChunkLoaded(i, j + 1) && ichunkprovider.isChunkLoaded(i + 1, j)) { - ichunkprovider.getChunkAt(ichunkprovider1, i, j); - } - - if (ichunkprovider.isChunkLoaded(i - 1, j) && !ichunkprovider.getOrCreateChunk(i - 1, j).done && ichunkprovider.isChunkLoaded(i - 1, j + 1) && ichunkprovider.isChunkLoaded(i, j + 1) && ichunkprovider.isChunkLoaded(i - 1, j + 1)) { - ichunkprovider.getChunkAt(ichunkprovider1, i - 1, j); - } - - if (ichunkprovider.isChunkLoaded(i, j - 1) && !ichunkprovider.getOrCreateChunk(i, j - 1).done && ichunkprovider.isChunkLoaded(i + 1, j - 1) && ichunkprovider.isChunkLoaded(i + 1, j - 1) && ichunkprovider.isChunkLoaded(i + 1, j)) { - ichunkprovider.getChunkAt(ichunkprovider1, i, j - 1); - } - - if (ichunkprovider.isChunkLoaded(i - 1, j - 1) && !ichunkprovider.getOrCreateChunk(i - 1, j - 1).done && ichunkprovider.isChunkLoaded(i, j - 1) && ichunkprovider.isChunkLoaded(i - 1, j)) { - ichunkprovider.getChunkAt(ichunkprovider1, i - 1, j - 1); - } - } - - public int d(int i, int j) { - int k = i | j << 4; - int l = this.b[k]; - - if (l == -999) { - int i1 = this.h() + 15; - - l = -1; - - while (i1 > 0 && l == -1) { - Block block = this.getType(i, i1, j); - Material material = block.getMaterial(); - - if (!material.isSolid() && !material.isLiquid()) { - --i1; - } else { - l = i1 + 1; - } - } - - this.b[k] = l; - } - - return l; - } - - public void b(boolean flag) { - if (this.w && !this.world.worldProvider.g && !flag) { - this.c(this.world.isStatic); - } - - this.m = true; - if (!this.lit && this.done) { - this.p(); - } - } - - public boolean isReady() { - return this.m && this.done && this.lit; - } - - public ChunkCoordIntPair l() { - return new ChunkCoordIntPair(this.locX, this.locZ); - } - - public boolean c(int i, int j) { - if (i < 0) { - i = 0; - } - - if (j >= 256) { - j = 255; - } - - for (int k = i; k <= j; k += 16) { - ChunkSection chunksection = this.sections[k >> 4]; - - if (chunksection != null && !chunksection.isEmpty()) { - return false; - } - } - - return true; - } - - public void a(ChunkSection[] achunksection) { - this.sections = achunksection; - } - - public BiomeBase getBiome(int i, int j, WorldChunkManager worldchunkmanager) { - int k = this.v[j << 4 | i] & 255; - - if (k == 255) { - BiomeBase biomebase = worldchunkmanager.getBiome((this.locX << 4) + i, (this.locZ << 4) + j); - - k = biomebase.id; - this.v[j << 4 | i] = (byte) (k & 255); - } - - return BiomeBase.getBiome(k) == null ? BiomeBase.PLAINS : BiomeBase.getBiome(k); - } - - public byte[] m() { - return this.v; - } - - public void a(byte[] abyte) { - this.v = abyte; - } - - public void n() { - this.x = 0; - } - - public void o() { - for (int i = 0; i < 8; ++i) { - if (this.x >= 4096) { - return; - } - - int j = this.x % 16; - int k = this.x / 16 % 16; - int l = this.x / 256; - - ++this.x; - int i1 = (this.locX << 4) + k; - int j1 = (this.locZ << 4) + l; - - for (int k1 = 0; k1 < 16; ++k1) { - int l1 = (j << 4) + k1; - - if (this.sections[j] == null && (k1 == 0 || k1 == 15 || k == 0 || k == 15 || l == 0 || l == 15) || this.sections[j] != null && this.sections[j].getTypeId(k, k1, l).getMaterial() == Material.AIR) { - if (this.world.getType(i1, l1 - 1, j1).m() > 0) { - this.world.t(i1, l1 - 1, j1); - } - - if (this.world.getType(i1, l1 + 1, j1).m() > 0) { - this.world.t(i1, l1 + 1, j1); - } - - if (this.world.getType(i1 - 1, l1, j1).m() > 0) { - this.world.t(i1 - 1, l1, j1); - } - - if (this.world.getType(i1 + 1, l1, j1).m() > 0) { - this.world.t(i1 + 1, l1, j1); - } - - if (this.world.getType(i1, l1, j1 - 1).m() > 0) { - this.world.t(i1, l1, j1 - 1); - } - - if (this.world.getType(i1, l1, j1 + 1).m() > 0) { - this.world.t(i1, l1, j1 + 1); - } - - this.world.t(i1, l1, j1); - } - } - } - } - - public void p() { - this.done = true; - this.lit = true; - if (!this.world.worldProvider.g) { - if (this.world.b(this.locX * 16 - 1, 0, this.locZ * 16 - 1, this.locX * 16 + 1, 63, this.locZ * 16 + 1)) { - for (int i = 0; i < 16; ++i) { - for (int j = 0; j < 16; ++j) { - if (!this.f(i, j)) { - this.lit = false; - break; - } - } - } - - if (this.lit) { - Chunk chunk = this.world.getChunkAtWorldCoords(this.locX * 16 - 1, this.locZ * 16); - - chunk.a(3); - chunk = this.world.getChunkAtWorldCoords(this.locX * 16 + 16, this.locZ * 16); - chunk.a(1); - chunk = this.world.getChunkAtWorldCoords(this.locX * 16, this.locZ * 16 - 1); - chunk.a(0); - chunk = this.world.getChunkAtWorldCoords(this.locX * 16, this.locZ * 16 + 16); - chunk.a(2); - } - } else { - this.lit = false; - } - } - } - - private void a(int i) { - if (this.done) { - int j; - - if (i == 3) { - for (j = 0; j < 16; ++j) { - this.f(15, j); - } - } else if (i == 1) { - for (j = 0; j < 16; ++j) { - this.f(0, j); - } - } else if (i == 0) { - for (j = 0; j < 16; ++j) { - this.f(j, 15); - } - } else if (i == 2) { - for (j = 0; j < 16; ++j) { - this.f(j, 0); - } - } - } - } - - private boolean f(int i, int j) { - int k = this.h(); - boolean flag = false; - boolean flag1 = false; - - int l; - - for (l = k + 16 - 1; l > 63 || l > 0 && !flag1; --l) { - int i1 = this.b(i, l, j); - - if (i1 == 255 && l < 63) { - flag1 = true; - } - - if (!flag && i1 > 0) { - flag = true; - } else if (flag && i1 == 0 && !this.world.t(this.locX * 16 + i, l, this.locZ * 16 + j)) { - return false; - } - } - - for (; l > 0; --l) { - if (this.getType(i, l, j).m() > 0) { - this.world.t(this.locX * 16 + i, l, this.locZ * 16 + j); - } - } - - return true; - } -} diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java deleted file mode 100644 index c88d5d4d..00000000 --- a/src/main/java/net/minecraft/server/ChunkProviderServer.java +++ /dev/null @@ -1,399 +0,0 @@ -package net.minecraft.server; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; - -import net.minecraft.util.com.google.common.collect.Lists; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -// CraftBukkit start -import java.util.Random; - -import org.bukkit.Server; -import org.bukkit.craftbukkit.chunkio.ChunkIOExecutor; -import org.bukkit.craftbukkit.util.LongHash; -import org.bukkit.craftbukkit.util.LongHashSet; -import org.bukkit.craftbukkit.util.LongObjectHashMap; -import org.bukkit.event.world.ChunkUnloadEvent; -// CraftBukkit end - -public class ChunkProviderServer implements IChunkProvider { - - private static final Logger b = LogManager.getLogger(); - // CraftBukkit start - private -> public - public LongHashSet unloadQueue = new LongHashSet(); // LongHashSet - public Chunk emptyChunk; - public IChunkProvider chunkProvider; - private IChunkLoader f; - public boolean forceChunkLoad = false; // true -> false - public LongObjectHashMap<Chunk> chunks = new LongObjectHashMap<Chunk>(); - public WorldServer world; - // CraftBukkit end - - public ChunkProviderServer(WorldServer worldserver, IChunkLoader ichunkloader, IChunkProvider ichunkprovider) { - this.emptyChunk = new EmptyChunk(worldserver, 0, 0); - this.world = worldserver; - this.f = ichunkloader; - this.chunkProvider = ichunkprovider; - } - - public boolean isChunkLoaded(int i, int j) { - return this.chunks.containsKey(LongHash.toLong(i, j)); // CraftBukkit - } - - // CraftBukkit start - Change return type to Collection and return the values of our chunk map - public java.util.Collection a() { - // return this.chunkList; - return this.chunks.values(); - // CraftBukkit end - } - - public void queueUnload(int i, int j) { - if (this.world.worldProvider.e()) { - ChunkCoordinates chunkcoordinates = this.world.getSpawn(); - int k = i * 16 + 8 - chunkcoordinates.x; - int l = j * 16 + 8 - chunkcoordinates.z; - short short1 = 128; - - // CraftBukkit start - if (k < -short1 || k > short1 || l < -short1 || l > short1 || !(this.world.keepSpawnInMemory)) { // Added 'this.world.keepSpawnInMemory' - this.unloadQueue.add(i, j); - - Chunk c = this.chunks.get(LongHash.toLong(i, j)); - if (c != null) { - c.mustSave = true; - } - } - // CraftBukkit end - } else { - // CraftBukkit start - this.unloadQueue.add(i, j); - - Chunk c = this.chunks.get(LongHash.toLong(i, j)); - if (c != null) { - c.mustSave = true; - } - // CraftBukkit end - } - } - - public void b() { - Iterator iterator = this.chunks.values().iterator(); // CraftBukkit - - while (iterator.hasNext()) { - Chunk chunk = (Chunk) iterator.next(); - - this.queueUnload(chunk.locX, chunk.locZ); - } - } - - // CraftBukkit start - Add async variant, provide compatibility - public Chunk getChunkIfLoaded(int x, int z) { - return this.chunks.get(LongHash.toLong(x, z)); - } - - public Chunk getChunkAt(int i, int j) { - return getChunkAt(i, j, null); - } - - public Chunk getChunkAt(int i, int j, Runnable runnable) { - this.unloadQueue.remove(i, j); - Chunk chunk = this.chunks.get(LongHash.toLong(i, j)); - ChunkRegionLoader loader = null; - - if (this.f instanceof ChunkRegionLoader) { - loader = (ChunkRegionLoader) this.f; - } - - // We can only use the queue for already generated chunks - if (chunk == null && loader != null && loader.chunkExists(this.world, i, j)) { - if (runnable != null) { - ChunkIOExecutor.queueChunkLoad(this.world, loader, this, i, j, runnable); - return null; - } else { - chunk = ChunkIOExecutor.syncChunkLoad(this.world, loader, this, i, j); - } - } else if (chunk == null) { - chunk = this.originalGetChunkAt(i, j); - } - - // If we didn't load the chunk async and have a callback run it now - if (runnable != null) { - runnable.run(); - } - - return chunk; - } - - public Chunk originalGetChunkAt(int i, int j) { - this.unloadQueue.remove(i, j); - Chunk chunk = (Chunk) this.chunks.get(LongHash.toLong(i, j)); - boolean newChunk = false; - - if (chunk == null) { - chunk = this.loadChunk(i, j); - if (chunk == null) { - if (this.chunkProvider == null) { - chunk = this.emptyChunk; - } else { - try { - chunk = this.chunkProvider.getOrCreateChunk(i, j); - } catch (Throwable throwable) { - CrashReport crashreport = CrashReport.a(throwable, "Exception generating new chunk"); - CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Chunk to be generated"); - - crashreportsystemdetails.a("Location", String.format("%d,%d", new Object[] { Integer.valueOf(i), Integer.valueOf(j)})); - crashreportsystemdetails.a("Position hash", Long.valueOf(LongHash.toLong(i, j))); // CraftBukkit - Use LongHash - crashreportsystemdetails.a("Generator", this.chunkProvider.getName()); - throw new ReportedException(crashreport); - } - } - newChunk = true; // CraftBukkit - } - - this.chunks.put(LongHash.toLong(i, j), chunk); // CraftBukkit - chunk.addEntities(); - - // CraftBukkit start - Server server = this.world.getServer(); - if (server != null) { - /* - * If it's a new world, the first few chunks are generated inside - * the World constructor. We can't reliably alter that, so we have - * no way of creating a CraftWorld/CraftServer at that point. - */ - server.getPluginManager().callEvent(new org.bukkit.event.world.ChunkLoadEvent(chunk.bukkitChunk, newChunk)); - } - - // Update neighbor counts - for (int x = -2; x < 3; x++) { - for (int z = -2; z < 3; z++) { - if (x == 0 && z == 0) { - continue; - } - - Chunk neighbor = this.getChunkIfLoaded(chunk.locX + x, chunk.locZ + z); - if (neighbor != null) { - neighbor.setNeighborLoaded(-x, -z); - chunk.setNeighborLoaded(x, z); - } - } - } - // CraftBukkit end - chunk.loadNearby(this, this, i, j); - } - - return chunk; - } - - public Chunk getOrCreateChunk(int i, int j) { - // CraftBukkit start - Chunk chunk = (Chunk) this.chunks.get(LongHash.toLong(i, j)); - - chunk = chunk == null ? (!this.world.isLoading && !this.forceChunkLoad ? this.emptyChunk : this.getChunkAt(i, j)) : chunk; - if (chunk == this.emptyChunk) return chunk; - if (i != chunk.locX || j != chunk.locZ) { - b.error("Chunk (" + chunk.locX + ", " + chunk.locZ + ") stored at (" + i + ", " + j + ") in world '" + world.getWorld().getName() + "'"); - b.error(chunk.getClass().getName()); - Throwable ex = new Throwable(); - ex.fillInStackTrace(); - ex.printStackTrace(); - } - return chunk; - // CraftBukkit end - } - - public Chunk loadChunk(int i, int j) { // CraftBukkit - private -> public - if (this.f == null) { - return null; - } else { - try { - Chunk chunk = this.f.a(this.world, i, j); - - if (chunk != null) { - chunk.lastSaved = this.world.getTime(); - if (this.chunkProvider != null) { - this.chunkProvider.recreateStructures(i, j); - } - } - - return chunk; - } catch (Exception exception) { - b.error("Couldn\'t load chunk", exception); - return null; - } - } - } - - public void saveChunkNOP(Chunk chunk) { // CraftBukkit - private -> public - if (this.f != null) { - try { - this.f.b(this.world, chunk); - } catch (Exception exception) { - b.error("Couldn\'t save entities", exception); - } - } - } - - public void saveChunk(Chunk chunk) { // CraftBukkit - private -> public - if (this.f != null) { - try { - chunk.lastSaved = this.world.getTime(); - this.f.a(this.world, chunk); - // CraftBukkit start - IOException to Exception - } catch (Exception ioexception) { - b.error("Couldn\'t save chunk", ioexception); - /* Remove extra exception - } catch (ExceptionWorldConflict exceptionworldconflict) { - b.error("Couldn\'t save chunk; already in use by another instance of Minecraft?", exceptionworldconflict); - // CraftBukkit end */ - } - } - } - - public void getChunkAt(IChunkProvider ichunkprovider, int i, int j) { - Chunk chunk = this.getOrCreateChunk(i, j); - - if (!chunk.done) { - chunk.p(); - if (this.chunkProvider != null) { - this.chunkProvider.getChunkAt(ichunkprovider, i, j); - - // CraftBukkit start - BlockSand.instaFall = true; - Random random = new Random(); - random.setSeed(world.getSeed()); - long xRand = random.nextLong() / 2L * 2L + 1L; - long zRand = random.nextLong() / 2L * 2L + 1L; - random.setSeed((long) i * xRand + (long) j * zRand ^ world.getSeed()); - - org.bukkit.World world = this.world.getWorld(); - if (world != null) { - this.world.populating = true; - try { - for (org.bukkit.generator.BlockPopulator populator : world.getPopulators()) { - populator.populate(world, random, chunk.bukkitChunk); - } - } finally { - this.world.populating = false; - } - } - BlockSand.instaFall = false; - this.world.getServer().getPluginManager().callEvent(new org.bukkit.event.world.ChunkPopulateEvent(chunk.bukkitChunk)); - // CraftBukkit end - - chunk.e(); - } - } - } - - public boolean saveChunks(boolean flag, IProgressUpdate iprogressupdate) { - int i = 0; - // CraftBukkit start - Iterator iterator = this.chunks.values().iterator(); - - while (iterator.hasNext()) { - Chunk chunk = (Chunk) iterator.next(); - // CraftBukkit end - - if (flag) { - this.saveChunkNOP(chunk); - } - - if (chunk.a(flag)) { - this.saveChunk(chunk); - chunk.n = false; - ++i; - if (i == 24 && !flag) { - return false; - } - } - } - - return true; - } - - public void c() { - if (this.f != null) { - this.f.b(); - } - } - - public boolean unloadChunks() { - if (!this.world.savingDisabled) { - // CraftBukkit start - Server server = this.world.getServer(); - 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; - - ChunkUnloadEvent event = new ChunkUnloadEvent(chunk.bukkitChunk); - server.getPluginManager().callEvent(event); - if (!event.isCancelled()) { - if (chunk != null) { - chunk.removeEntities(); - this.saveChunk(chunk); - this.saveChunkNOP(chunk); - this.chunks.remove(chunkcoordinates); // CraftBukkit - } - - // this.unloadQueue.remove(olong); - // this.chunks.remove(olong.longValue()); - - // Update neighbor counts - for (int x = -2; x < 3; x++) { - for (int z = -2; z < 3; z++) { - if (x == 0 && z == 0) { - continue; - } - - Chunk neighbor = this.getChunkIfLoaded(chunk.locX + x, chunk.locZ + z); - if (neighbor != null) { - neighbor.setNeighborUnloaded(-x, -z); - chunk.setNeighborUnloaded(x, z); - } - } - } - } - } - // CraftBukkit end - - if (this.f != null) { - this.f.a(); - } - } - - return this.chunkProvider.unloadChunks(); - } - - public boolean canSave() { - return !this.world.savingDisabled; - } - - public String getName() { - // CraftBukkit - this.chunks.count() -> .values().size() - return "ServerChunkCache: " + this.chunks.values().size() + " Drop: " + this.unloadQueue.size(); - } - - public List getMobsFor(EnumCreatureType enumcreaturetype, int i, int j, int k) { - return this.chunkProvider.getMobsFor(enumcreaturetype, i, j, k); - } - - public ChunkPosition findNearestMapFeature(World world, String s, int i, int j, int k) { - return this.chunkProvider.findNearestMapFeature(world, s, i, j, k); - } - - public int getLoadedChunks() { - // CraftBukkit - this.chunks.count() -> this.chunks.size() - return this.chunks.size(); - } - - 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 deleted file mode 100644 index 9402f0fd..00000000 --- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java +++ /dev/null @@ -1,406 +0,0 @@ -package net.minecraft.server; - -import java.io.DataInputStream; -import java.io.DataOutput; -import java.io.DataOutputStream; -import java.io.File; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver { - - private static final Logger a = LogManager.getLogger(); - private List b = new ArrayList(); - private Set c = new HashSet(); - private Object d = new Object(); - private final File e; - - public ChunkRegionLoader(File file1) { - this.e = file1; - } - - // CraftBukkit start - public boolean chunkExists(World world, int i, int j) { - ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(i, j); - - synchronized (this.d) { - if (this.c.contains(chunkcoordintpair)) { - for (int k = 0; k < this.b.size(); ++k) { - if (((PendingChunkToSave) this.b.get(k)).a.equals(chunkcoordintpair)) { - return true; - } - } - } - } - - return RegionFileCache.a(this.e, i, j).chunkExists(i & 31, j & 31); - } - // CraftBukkit end - - // CraftBukkit start - Add async variant, provide compatibility - public Chunk a(World world, int i, int j) { - Object[] data = this.loadChunk(world, i, j); - if (data != null) { - Chunk chunk = (Chunk) data[0]; - NBTTagCompound nbttagcompound = (NBTTagCompound) data[1]; - this.loadEntities(chunk, nbttagcompound.getCompound("Level"), world); - return chunk; - } - - return null; - } - - public Object[] loadChunk(World world, int i, int j) { - // CraftBukkit end - NBTTagCompound nbttagcompound = null; - ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(i, j); - Object object = this.d; - - synchronized (this.d) { - if (this.c.contains(chunkcoordintpair)) { - for (int k = 0; k < this.b.size(); ++k) { - if (((PendingChunkToSave) this.b.get(k)).a.equals(chunkcoordintpair)) { - nbttagcompound = ((PendingChunkToSave) this.b.get(k)).b; - break; - } - } - } - } - - if (nbttagcompound == null) { - DataInputStream datainputstream = RegionFileCache.c(this.e, i, j); - - if (datainputstream == null) { - return null; - } - - nbttagcompound = NBTCompressedStreamTools.a(datainputstream); - } - - return this.a(world, i, j, nbttagcompound); - } - - protected Object[] a(World world, int i, int j, NBTTagCompound nbttagcompound) { // CraftBukkit - return Chunk -> Object[] - if (!nbttagcompound.hasKeyOfType("Level", 10)) { - a.error("Chunk file at " + i + "," + j + " is missing level data, skipping"); - return null; - } else if (!nbttagcompound.getCompound("Level").hasKeyOfType("Sections", 9)) { - a.error("Chunk file at " + i + "," + j + " is missing block data, skipping"); - return null; - } else { - Chunk chunk = this.a(world, nbttagcompound.getCompound("Level")); - - if (!chunk.a(i, j)) { - a.error("Chunk file at " + i + "," + j + " is in the wrong location; relocating. (Expected " + i + ", " + j + ", got " + chunk.locX + ", " + chunk.locZ + ")"); - nbttagcompound.getCompound("Level").setInt("xPos", i); // CraftBukkit - .getCompound("Level") - nbttagcompound.getCompound("Level").setInt("zPos", j); // CraftBukkit - .getCompound("Level") - - // CraftBukkit start - Have to move tile entities since we don't load them at this stage - NBTTagList tileEntities = nbttagcompound.getCompound("Level").getList("TileEntities", 10); - if (tileEntities != null) { - for (int te = 0; te < tileEntities.size(); te++) { - NBTTagCompound tileEntity = (NBTTagCompound) tileEntities.get(te); - int x = tileEntity.getInt("x") - chunk.locX * 16; - int z = tileEntity.getInt("z") - chunk.locZ * 16; - tileEntity.setInt("x", i * 16 + x); - tileEntity.setInt("z", j * 16 + z); - } - } - // CraftBukkit end - chunk = this.a(world, nbttagcompound.getCompound("Level")); - } - - // CraftBukkit start - Object[] data = new Object[2]; - data[0] = chunk; - data[1] = nbttagcompound; - return data; - // CraftBukkit end - } - } - - public void a(World world, Chunk chunk) { - // CraftBukkit start - "handle" exception - try { - world.G(); - } catch (ExceptionWorldConflict ex) { - ex.printStackTrace(); - } - // CraftBukkit end - - try { - NBTTagCompound nbttagcompound = new NBTTagCompound(); - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - - nbttagcompound.set("Level", nbttagcompound1); - this.a(chunk, world, nbttagcompound1); - this.a(chunk.l(), nbttagcompound); - } catch (Exception exception) { - exception.printStackTrace(); - } - } - - protected void a(ChunkCoordIntPair chunkcoordintpair, NBTTagCompound nbttagcompound) { - Object object = this.d; - - synchronized (this.d) { - if (this.c.contains(chunkcoordintpair)) { - for (int i = 0; i < this.b.size(); ++i) { - if (((PendingChunkToSave) this.b.get(i)).a.equals(chunkcoordintpair)) { - this.b.set(i, new PendingChunkToSave(chunkcoordintpair, nbttagcompound)); - return; - } - } - } - - this.b.add(new PendingChunkToSave(chunkcoordintpair, nbttagcompound)); - this.c.add(chunkcoordintpair); - FileIOThread.a.a(this); - } - } - - public boolean c() { - PendingChunkToSave pendingchunktosave = null; - Object object = this.d; - - synchronized (this.d) { - if (this.b.isEmpty()) { - return false; - } - - pendingchunktosave = (PendingChunkToSave) this.b.remove(0); - this.c.remove(pendingchunktosave.a); - } - - if (pendingchunktosave != null) { - try { - this.a(pendingchunktosave); - } catch (Exception exception) { - exception.printStackTrace(); - } - } - - return true; - } - - public void a(PendingChunkToSave pendingchunktosave) throws java.io.IOException { // CraftBukkit - public -> private, added throws - DataOutputStream dataoutputstream = RegionFileCache.d(this.e, pendingchunktosave.a.x, pendingchunktosave.a.z); - - NBTCompressedStreamTools.a(pendingchunktosave.b, (DataOutput) dataoutputstream); - dataoutputstream.close(); - } - - public void b(World world, Chunk chunk) {} - - public void a() {} - - public void b() { - while (this.c()) { - ; - } - } - - private void a(Chunk chunk, World world, NBTTagCompound nbttagcompound) { - nbttagcompound.setByte("V", (byte) 1); - nbttagcompound.setInt("xPos", chunk.locX); - nbttagcompound.setInt("zPos", chunk.locZ); - nbttagcompound.setLong("LastUpdate", world.getTime()); - nbttagcompound.setIntArray("HeightMap", chunk.heightMap); - nbttagcompound.setBoolean("TerrainPopulated", chunk.done); - nbttagcompound.setBoolean("LightPopulated", chunk.lit); - nbttagcompound.setLong("InhabitedTime", chunk.s); - ChunkSection[] achunksection = chunk.getSections(); - NBTTagList nbttaglist = new NBTTagList(); - boolean flag = !world.worldProvider.g; - ChunkSection[] achunksection1 = achunksection; - int i = achunksection.length; - - NBTTagCompound nbttagcompound1; - - for (int j = 0; j < i; ++j) { - ChunkSection chunksection = achunksection1[j]; - - if (chunksection != null) { - nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Y", (byte) (chunksection.getYPosition() >> 4 & 255)); - nbttagcompound1.setByteArray("Blocks", chunksection.getIdArray()); - if (chunksection.getExtendedIdArray() != null) { - nbttagcompound1.setByteArray("Add", chunksection.getExtendedIdArray().a); - } - - nbttagcompound1.setByteArray("Data", chunksection.getDataArray().a); - nbttagcompound1.setByteArray("BlockLight", chunksection.getEmittedLightArray().a); - if (flag) { - nbttagcompound1.setByteArray("SkyLight", chunksection.getSkyLightArray().a); - } else { - nbttagcompound1.setByteArray("SkyLight", new byte[chunksection.getEmittedLightArray().a.length]); - } - - nbttaglist.add(nbttagcompound1); - } - } - - nbttagcompound.set("Sections", nbttaglist); - nbttagcompound.setByteArray("Biomes", chunk.m()); - chunk.o = false; - NBTTagList nbttaglist1 = new NBTTagList(); - - Iterator iterator; - - for (i = 0; i < chunk.entitySlices.length; ++i) { - iterator = chunk.entitySlices[i].iterator(); - - while (iterator.hasNext()) { - Entity entity = (Entity) iterator.next(); - - nbttagcompound1 = new NBTTagCompound(); - if (entity.d(nbttagcompound1)) { - chunk.o = true; - nbttaglist1.add(nbttagcompound1); - } - } - } - - nbttagcompound.set("Entities", nbttaglist1); - NBTTagList nbttaglist2 = new NBTTagList(); - - iterator = chunk.tileEntities.values().iterator(); - - while (iterator.hasNext()) { - TileEntity tileentity = (TileEntity) iterator.next(); - - nbttagcompound1 = new NBTTagCompound(); - tileentity.b(nbttagcompound1); - nbttaglist2.add(nbttagcompound1); - } - - nbttagcompound.set("TileEntities", nbttaglist2); - List list = world.a(chunk, false); - - if (list != null) { - long k = world.getTime(); - NBTTagList nbttaglist3 = new NBTTagList(); - Iterator iterator1 = list.iterator(); - - while (iterator1.hasNext()) { - NextTickListEntry nextticklistentry = (NextTickListEntry) iterator1.next(); - NBTTagCompound nbttagcompound2 = new NBTTagCompound(); - - nbttagcompound2.setInt("i", Block.getId(nextticklistentry.a())); - nbttagcompound2.setInt("x", nextticklistentry.a); - nbttagcompound2.setInt("y", nextticklistentry.b); - nbttagcompound2.setInt("z", nextticklistentry.c); - nbttagcompound2.setInt("t", (int) (nextticklistentry.d - k)); - nbttagcompound2.setInt("p", nextticklistentry.e); - nbttaglist3.add(nbttagcompound2); - } - - nbttagcompound.set("TileTicks", nbttaglist3); - } - } - - private Chunk a(World world, NBTTagCompound nbttagcompound) { - int i = nbttagcompound.getInt("xPos"); - int j = nbttagcompound.getInt("zPos"); - Chunk chunk = new Chunk(world, i, j); - - chunk.heightMap = nbttagcompound.getIntArray("HeightMap"); - chunk.done = nbttagcompound.getBoolean("TerrainPopulated"); - chunk.lit = nbttagcompound.getBoolean("LightPopulated"); - chunk.s = nbttagcompound.getLong("InhabitedTime"); - NBTTagList nbttaglist = nbttagcompound.getList("Sections", 10); - byte b0 = 16; - ChunkSection[] achunksection = new ChunkSection[b0]; - boolean flag = !world.worldProvider.g; - - for (int k = 0; k < nbttaglist.size(); ++k) { - NBTTagCompound nbttagcompound1 = nbttaglist.get(k); - byte b1 = nbttagcompound1.getByte("Y"); - ChunkSection chunksection = new ChunkSection(b1 << 4, flag); - - chunksection.setIdArray(nbttagcompound1.getByteArray("Blocks")); - if (nbttagcompound1.hasKeyOfType("Add", 7)) { - chunksection.setExtendedIdArray(new NibbleArray(nbttagcompound1.getByteArray("Add"), 4)); - } - - chunksection.setDataArray(new NibbleArray(nbttagcompound1.getByteArray("Data"), 4)); - chunksection.setEmittedLightArray(new NibbleArray(nbttagcompound1.getByteArray("BlockLight"), 4)); - if (flag) { - chunksection.setSkyLightArray(new NibbleArray(nbttagcompound1.getByteArray("SkyLight"), 4)); - } - - chunksection.recalcBlockCounts(); - achunksection[b1] = chunksection; - } - - chunk.a(achunksection); - if (nbttagcompound.hasKeyOfType("Biomes", 7)) { - chunk.a(nbttagcompound.getByteArray("Biomes")); - } - - // CraftBukkit start - End this method here and split off entity loading to another method - return chunk; - } - - public void loadEntities(Chunk chunk, NBTTagCompound nbttagcompound, World world) { - // CraftBukkit end - NBTTagList nbttaglist1 = nbttagcompound.getList("Entities", 10); - - if (nbttaglist1 != null) { - for (int l = 0; l < nbttaglist1.size(); ++l) { - NBTTagCompound nbttagcompound2 = nbttaglist1.get(l); - Entity entity = EntityTypes.a(nbttagcompound2, world); - - chunk.o = true; - if (entity != null) { - chunk.a(entity); - Entity entity1 = entity; - - for (NBTTagCompound nbttagcompound3 = nbttagcompound2; nbttagcompound3.hasKeyOfType("Riding", 10); nbttagcompound3 = nbttagcompound3.getCompound("Riding")) { - Entity entity2 = EntityTypes.a(nbttagcompound3.getCompound("Riding"), world); - - if (entity2 != null) { - chunk.a(entity2); - entity1.mount(entity2); - } - - entity1 = entity2; - } - } - } - } - - NBTTagList nbttaglist2 = nbttagcompound.getList("TileEntities", 10); - - if (nbttaglist2 != null) { - for (int i1 = 0; i1 < nbttaglist2.size(); ++i1) { - NBTTagCompound nbttagcompound4 = nbttaglist2.get(i1); - TileEntity tileentity = TileEntity.c(nbttagcompound4); - - if (tileentity != null) { - chunk.a(tileentity); - } - } - } - - if (nbttagcompound.hasKeyOfType("TileTicks", 9)) { - NBTTagList nbttaglist3 = nbttagcompound.getList("TileTicks", 10); - - if (nbttaglist3 != null) { - for (int j1 = 0; j1 < nbttaglist3.size(); ++j1) { - NBTTagCompound nbttagcompound5 = nbttaglist3.get(j1); - - world.b(nbttagcompound5.getInt("x"), nbttagcompound5.getInt("y"), nbttagcompound5.getInt("z"), Block.getById(nbttagcompound5.getInt("i")), nbttagcompound5.getInt("t"), nbttagcompound5.getInt("p")); - } - } - } - - // return chunk; // CraftBukkit - } -} diff --git a/src/main/java/net/minecraft/server/ChunkSection.java b/src/main/java/net/minecraft/server/ChunkSection.java deleted file mode 100644 index db1e52c9..00000000 --- a/src/main/java/net/minecraft/server/ChunkSection.java +++ /dev/null @@ -1,488 +0,0 @@ -package net.minecraft.server; - -import java.util.Arrays; // CraftBukkit - -public class ChunkSection { - - private int yPos; - private int nonEmptyBlockCount; - private int tickingBlockCount; - private byte[] blockIds; - private NibbleArray extBlockIds; - private NibbleArray blockData; - private NibbleArray emittedLight; - private NibbleArray skyLight; - // CraftBukkit start - Compact storage - private int compactId; - private byte compactExtId; - private byte compactData; - private byte compactEmitted; - private byte compactSky; - - // Pre-generated (read-only!) NibbleArrays for every possible value, used for chunk saving - private static NibbleArray[] compactPregen = new NibbleArray[16]; - static { - for (int i = 0; i < 16; i++) { - compactPregen[i] = expandCompactNibble((byte) i); - } - } - - private static NibbleArray expandCompactNibble(byte value) { - byte[] data = new byte[2048]; - Arrays.fill(data, (byte) (value | (value << 4))); - return new NibbleArray(data, 4); - } - - private boolean canBeCompact(byte[] array) { - byte value = array[0]; - for (int i = 1; i < array.length; i++) { - if (value != array[i]) { - return false; - } - } - - return true; - } - // CraftBukkit end - - public ChunkSection(int i, boolean flag) { - this.yPos = i; - /* CraftBukkit - Start as null, using compact storage - this.blockIds = new byte[4096]; - this.blockData = new NibbleArray(this.blockIds.length, 4); - this.emittedLight = new NibbleArray(this.blockIds.length, 4); - if (flag) { - this.skyLight = new NibbleArray(this.blockIds.length, 4); - } - */ - if (!flag) { - this.compactSky = -1; - } - // CraftBukkit end - } - - // CraftBukkit start - public ChunkSection(int y, boolean flag, byte[] blkIds, byte[] extBlkIds) { - this.yPos = y; - this.setIdArray(blkIds); - if (extBlkIds != null) { - this.setExtendedIdArray(new NibbleArray(extBlkIds, 4)); - } - if (!flag) { - this.compactSky = -1; - } - this.recalcBlockCounts(); - } - // CraftBukkit end - - public Block getTypeId(int i, int j, int k) { - // CraftBukkit start - Compact storage - if (this.blockIds == null) { - int id = this.compactId; - if (this.extBlockIds == null) { - id |= this.compactExtId << 8; - } else { - id |= this.extBlockIds.a(i, j, k) << 8; - } - - return Block.getById(id); - } - // CraftBukkit end - - int l = this.blockIds[j << 8 | k << 4 | i] & 255; - - if (this.extBlockIds != null) { - l |= this.extBlockIds.a(i, j, k) << 8; - } - - return Block.getById(l); - } - - public void setTypeId(int i, int j, int k, Block block) { - // CraftBukkit start - Compact storage - Block block1 = this.getTypeId(i, j, k); - if (block == block1) { - return; - } - // CraftBukkit end - - if (block1 != Blocks.AIR) { - --this.nonEmptyBlockCount; - if (block1.isTicking()) { - --this.tickingBlockCount; - } - } - - if (block != Blocks.AIR) { - ++this.nonEmptyBlockCount; - if (block.isTicking()) { - ++this.tickingBlockCount; - } - } - - int i1 = Block.getId(block); - - // CraftBukkit start - Compact storage - if (this.blockIds == null) { - this.blockIds = new byte[4096]; - Arrays.fill(this.blockIds, (byte) (this.compactId & 255)); - } - // CraftBukkit end - - this.blockIds[j << 8 | k << 4 | i] = (byte) (i1 & 255); - if (i1 > 255) { - if (this.extBlockIds == null) { - this.extBlockIds = expandCompactNibble(this.compactExtId); // CraftBukkit - Compact storage - } - - this.extBlockIds.a(i, j, k, (i1 & 3840) >> 8); - } else if (this.extBlockIds != null) { - this.extBlockIds.a(i, j, k, 0); - } - } - - public int getData(int i, int j, int k) { - // CraftBukkit start - Compact storage - if (this.blockData == null) { - return this.compactData; - } - // CraftBukkit end - return this.blockData.a(i, j, k); - } - - public void setData(int i, int j, int k, int l) { - // CraftBukkit start - Compact storage - if (this.blockData == null) { - if (this.compactData == l) { - return; - } - this.blockData = expandCompactNibble(this.compactData); - } - // CraftBukkit end - this.blockData.a(i, j, k, l); - } - - public boolean isEmpty() { - return this.nonEmptyBlockCount == 0; - } - - public boolean shouldTick() { - return this.tickingBlockCount > 0; - } - - public int getYPosition() { - return this.yPos; - } - - public void setSkyLight(int i, int j, int k, int l) { - // CraftBukkit start - Compact storage - if (this.skyLight == null) { - if (this.compactSky == l) { - return; - } - this.skyLight = expandCompactNibble(this.compactSky); - } - // CraftBukkit end - this.skyLight.a(i, j, k, l); - } - - public int getSkyLight(int i, int j, int k) { - // CraftBukkit start - Compact storage - if (this.skyLight == null) { - return this.compactSky; - } - // CraftBukkit end - return this.skyLight.a(i, j, k); - } - - public void setEmittedLight(int i, int j, int k, int l) { - // CraftBukkit start - Compact storage - if (this.emittedLight == null) { - if (this.compactEmitted == l) { - return; - } - this.emittedLight = expandCompactNibble(this.compactEmitted); - } - // CraftBukkit end - this.emittedLight.a(i, j, k, l); - } - - public int getEmittedLight(int i, int j, int k) { - // CraftBukkit start - Compact storage - if (this.emittedLight == null) { - return this.compactEmitted; - } - // CraftBukkit end - return this.emittedLight.a(i, j, k); - } - - public void recalcBlockCounts() { - // CraftBukkit start - Optimize for speed - int cntNonEmpty = 0; - int cntTicking = 0; - - if (this.blockIds == null) { - int id = this.compactId; - if (this.extBlockIds == null) { - id |= this.compactExtId << 8; - if (id > 0) { - Block block = Block.getById(id); - if (block == null) { - this.compactId = 0; - this.compactExtId = 0; - } else { - cntNonEmpty = 4096; - if (block.isTicking()) { - cntTicking = 4096; - } - } - } - } else { - byte[] ext = this.extBlockIds.a; - for (int off = 0, off2 = 0; off < 4096;) { - byte extid = ext[off2]; - int l = (id & 0xFF) | ((extid & 0xF) << 8); // Even data - if (l > 0) { - Block block = Block.getById(l); - if (block == null) { - this.compactId = 0; - ext[off2] &= 0xF0; - } else { - ++cntNonEmpty; - if (block.isTicking()) { - ++cntTicking; - } - } - } - off++; - l = (id & 0xFF) | ((extid & 0xF0) << 4); // Odd data - if (l > 0) { - Block block = Block.getById(l); - if (block == null) { - this.compactId = 0; - ext[off2] &= 0x0F; - } else { - ++cntNonEmpty; - if (block.isTicking()) { - ++cntTicking; - } - } - } - off++; - off2++; - } - } - } else { - byte[] blkIds = this.blockIds; - 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.getById(l) == null) { - blkIds[off] = 0; - } else { - ++cntNonEmpty; - if (Block.getById(l).isTicking()) { - ++cntTicking; - } - } - } - } - } else { - byte[] ext = this.extBlockIds.a; - for (int off = 0, off2 = 0; off < blkIds.length;) { - byte extid = ext[off2]; - int l = (blkIds[off] & 0xFF) | ((extid & 0xF) << 8); // Even data - if (l > 0) { - if (Block.getById(l) == null) { - blkIds[off] = 0; - ext[off2] &= 0xF0; - } else { - ++cntNonEmpty; - if (Block.getById(l).isTicking()) { - ++cntTicking; - } - } - } - off++; - l = (blkIds[off] & 0xFF) | ((extid & 0xF0) << 4); // Odd data - if (l > 0) { - if (Block.getById(l) == null) { - blkIds[off] = 0; - ext[off2] &= 0x0F; - } else { - ++cntNonEmpty; - if (Block.getById(l).isTicking()) { - ++cntTicking; - } - } - } - off++; - off2++; - } - } - } - this.nonEmptyBlockCount = cntNonEmpty; - this.tickingBlockCount = cntTicking; - } - - public void old_recalcBlockCounts() { - // CraftBukkit end - this.nonEmptyBlockCount = 0; - this.tickingBlockCount = 0; - - for (int i = 0; i < 16; ++i) { - for (int j = 0; j < 16; ++j) { - for (int k = 0; k < 16; ++k) { - Block block = this.getTypeId(i, j, k); - - if (block != Blocks.AIR) { - ++this.nonEmptyBlockCount; - if (block.isTicking()) { - ++this.tickingBlockCount; - } - } - } - } - } - } - - public byte[] getIdArray() { - // CraftBukkit start - Compact storage - if (this.blockIds == null) { - byte[] ids = new byte[4096]; - Arrays.fill(ids, (byte) (this.compactId & 255)); - return ids; - } - // CraftBukkit end - return this.blockIds; - } - - public NibbleArray getExtendedIdArray() { - // CraftBukkit start - Compact storage - if (this.extBlockIds == null && this.compactExtId != 0) { - return compactPregen[this.compactExtId]; - } - // CraftBukkit end - return this.extBlockIds; - } - - public NibbleArray getDataArray() { - // CraftBukkit start - Compact storage - if (this.blockData == null) { - return compactPregen[this.compactData]; - } - // CraftBukkit end - return this.blockData; - } - - public NibbleArray getEmittedLightArray() { - // CraftBukkit start - Compact storage - if (this.emittedLight == null) { - return compactPregen[this.compactEmitted]; - } - // CraftBukkit end - return this.emittedLight; - } - - public NibbleArray getSkyLightArray() { - // CraftBukkit start - Compact storage - if (this.skyLight == null && this.compactSky != -1) { - return compactPregen[this.compactSky]; - } - // CraftBukkit end - return this.skyLight; - } - - public void setIdArray(byte[] abyte) { - // CraftBukkit start - Compact storage - if (abyte == null) { - this.compactId = 0; - this.blockIds = null; - return; - } else if (canBeCompact(abyte)) { - this.compactId = abyte[0] & 255; - return; - } - // CraftBukkit end - this.blockIds = this.validateByteArray(abyte); // CraftBukkit - Validate data - } - - public void setExtendedIdArray(NibbleArray nibblearray) { - // CraftBukkit start - Compact storage - if (nibblearray == null) { - this.compactExtId = 0; - this.extBlockIds = null; - return; - } else if (canBeCompact(nibblearray.a)) { - this.compactExtId = (byte) (nibblearray.a(0, 0, 0) & 0xF); - return; - } - // CraftBukkit end - this.extBlockIds = this.validateNibbleArray(nibblearray); // CraftBukkit - Validate data - } - - public void setDataArray(NibbleArray nibblearray) { - // CraftBukkit start - Compact storage - if (nibblearray == null) { - this.compactData = 0; - this.blockData = null; - return; - } else if (canBeCompact(nibblearray.a)) { - this.compactData = (byte) (nibblearray.a(0, 0, 0) & 0xF); - return; - } - // CraftBukkit end - this.blockData = this.validateNibbleArray(nibblearray); // CraftBukkit - Validate data - } - - public void setEmittedLightArray(NibbleArray nibblearray) { - // CraftBukkit start - Compact storage - if (nibblearray == null) { - this.compactEmitted = 0; - this.emittedLight = null; - return; - } else if (canBeCompact(nibblearray.a)) { - this.compactEmitted = (byte) (nibblearray.a(0, 0, 0) & 0xF); - return; - } - // CraftBukkit end - this.emittedLight = this.validateNibbleArray(nibblearray); // CraftBukkit - Validate data - } - - public void setSkyLightArray(NibbleArray nibblearray) { - // CraftBukkit start - Compact storage - if (nibblearray == null) { - this.compactSky = -1; - this.skyLight = null; - return; - } else if (canBeCompact(nibblearray.a)) { - this.compactSky = (byte) (nibblearray.a(0, 0, 0) & 0xF); - return; - } - // CraftBukkit end - this.skyLight = this.validateNibbleArray(nibblearray); // CraftBukkit - Validate data - } - - // CraftBukkit start - Validate array lengths - private NibbleArray validateNibbleArray(NibbleArray nibbleArray) { - if (nibbleArray != null && nibbleArray.a.length < 2048) { - byte[] newArray = new byte[2048]; - System.arraycopy(nibbleArray.a, 0, newArray, 0, nibbleArray.a.length); - nibbleArray = new NibbleArray(newArray, 4); - } - - return nibbleArray; - } - - private byte[] validateByteArray(byte[] byteArray) { - if (byteArray != null && byteArray.length < 4096) { - byte[] newArray = new byte[4096]; - System.arraycopy(byteArray, 0, newArray, 0, byteArray.length); - byteArray = newArray; - } - - return byteArray; - } - // CraftBukkit end -} diff --git a/src/main/java/net/minecraft/server/ClientCommandOrdinalWrapper.java b/src/main/java/net/minecraft/server/ClientCommandOrdinalWrapper.java deleted file mode 100644 index 04eacb8e..00000000 --- a/src/main/java/net/minecraft/server/ClientCommandOrdinalWrapper.java +++ /dev/null @@ -1,27 +0,0 @@ -package net.minecraft.server; - -// CraftBukkit - import package private class -class ClientCommandOrdinalWrapper { - - static final int[] a = new int[EnumClientCommand.values().length]; - - static { - try { - a[EnumClientCommand.PERFORM_RESPAWN.ordinal()] = 1; - } catch (NoSuchFieldError nosuchfielderror) { - ; - } - - try { - a[EnumClientCommand.REQUEST_STATS.ordinal()] = 2; - } catch (NoSuchFieldError nosuchfielderror1) { - ; - } - - try { - a[EnumClientCommand.OPEN_INVENTORY_ACHIEVEMENT.ordinal()] = 3; - } catch (NoSuchFieldError nosuchfielderror2) { - ; - } - } -} diff --git a/src/main/java/net/minecraft/server/CommandBlockListenerAbstract.java b/src/main/java/net/minecraft/server/CommandBlockListenerAbstract.java deleted file mode 100644 index 0cd512d5..00000000 --- a/src/main/java/net/minecraft/server/CommandBlockListenerAbstract.java +++ /dev/null @@ -1,230 +0,0 @@ -package net.minecraft.server; - -import java.text.SimpleDateFormat; -import java.util.Date; - -// CraftBukkit start -import java.util.ArrayList; -import org.apache.logging.log4j.Level; -import org.bukkit.craftbukkit.command.VanillaCommandWrapper; -import com.google.common.base.Joiner; -// CraftBukkit end - -public abstract class CommandBlockListenerAbstract implements ICommandListener { - - private static final SimpleDateFormat a = new SimpleDateFormat("HH:mm:ss"); - private int b; - private boolean c = true; - private IChatBaseComponent d = null; - public String e = ""; // CraftBukkit - private -> public - private String f = "@"; - protected org.bukkit.command.CommandSender sender; // CraftBukkit - add sender; - - public CommandBlockListenerAbstract() {} - - public int g() { - return this.b; - } - - public IChatBaseComponent h() { - return this.d; - } - - public void a(NBTTagCompound nbttagcompound) { - nbttagcompound.setString("Command", this.e); - nbttagcompound.setInt("SuccessCount", this.b); - nbttagcompound.setString("CustomName", this.f); - if (this.d != null) { - nbttagcompound.setString("LastOutput", ChatSerializer.a(this.d)); - } - - nbttagcompound.setBoolean("TrackOutput", this.c); - } - - public void b(NBTTagCompound nbttagcompound) { - this.e = nbttagcompound.getString("Command"); - this.b = nbttagcompound.getInt("SuccessCount"); - if (nbttagcompound.hasKeyOfType("CustomName", 8)) { - this.f = nbttagcompound.getString("CustomName"); - } - - if (nbttagcompound.hasKeyOfType("LastOutput", 8)) { - this.d = ChatSerializer.a(nbttagcompound.getString("LastOutput")); - } - - if (nbttagcompound.hasKeyOfType("TrackOutput", 1)) { - this.c = nbttagcompound.getBoolean("TrackOutput"); - } - } - - public boolean a(int i, String s) { - return i <= 2; - } - - public void setCommand(String s) { - this.e = s; - } - - public String getCommand() { - return this.e; - } - - public void a(World world) { - if (world.isStatic) { - this.b = 0; - } - - MinecraftServer minecraftserver = MinecraftServer.getServer(); - - if (minecraftserver != null && minecraftserver.getEnableCommandBlock()) { - // CraftBukkit start - Handle command block commands using Bukkit dispatcher - org.bukkit.command.SimpleCommandMap commandMap = minecraftserver.server.getCommandMap(); - Joiner joiner = Joiner.on(" "); - String command = this.e; - if (this.e.startsWith("/")) { - command = this.e.substring(1); - } - String[] args = command.split(" "); - ArrayList<String[]> commands = new ArrayList<String[]>(); - - // Block disallowed commands - if (args[0].equalsIgnoreCase("stop") || args[0].equalsIgnoreCase("kick") || args[0].equalsIgnoreCase("op") || - args[0].equalsIgnoreCase("deop") || args[0].equalsIgnoreCase("ban") || args[0].equalsIgnoreCase("ban-ip") || - args[0].equalsIgnoreCase("pardon") || args[0].equalsIgnoreCase("pardon-ip") || args[0].equalsIgnoreCase("reload")) { - this.b = 0; - return; - } - - // If the world has no players don't run - if (this.getWorld().players.isEmpty()) { - this.b = 0; - return; - } - - // Handle vanilla commands; - if (minecraftserver.server.getCommandBlockOverride(args[0])) { - org.bukkit.command.Command commandBlockCommand = commandMap.getCommand("minecraft:" + args[0]); - if (commandBlockCommand instanceof VanillaCommandWrapper) { - this.b = ((VanillaCommandWrapper) commandBlockCommand).dispatchVanillaCommandBlock(this, this.e); - return; - } - } - - // Make sure this is a valid command - if (commandMap.getCommand(args[0]) == null) { - this.b = 0; - return; - } - - // testfor command requires special handling - if (args[0].equalsIgnoreCase("testfor")) { - if (args.length < 2) { - this.b = 0; - return; - } - - EntityPlayer[] players = PlayerSelector.getPlayers(this, args[1]); - - if (players != null && players.length > 0) { - this.b = players.length; - return; - } else { - EntityPlayer player = MinecraftServer.getServer().getPlayerList().getPlayer(args[1]); - if (player == null) { - this.b = 0; - return; - } else { - this.b = 1; - return; - } - } - } - - commands.add(args); - - // Find positions of command block syntax, if any - ArrayList<String[]> newCommands = new ArrayList<String[]>(); - for (int i = 0; i < args.length; i++) { - if (PlayerSelector.isPattern(args[i])) { - for (int j = 0; j < commands.size(); j++) { - newCommands.addAll(this.buildCommands(commands.get(j), i)); - } - ArrayList<String[]> temp = commands; - commands = newCommands; - newCommands = temp; - newCommands.clear(); - } - } - - int completed = 0; - - // Now dispatch all of the commands we ended up with - for (int i = 0; i < commands.size(); i++) { - try { - if (commandMap.dispatch(sender, joiner.join(java.util.Arrays.asList(commands.get(i))))) { - completed++; - } - } catch (Throwable exception) { - if(this instanceof TileEntityCommandListener) { - TileEntityCommandListener listener = (TileEntityCommandListener) this; - MinecraftServer.getLogger().log(Level.WARN, String.format("CommandBlock at (%d,%d,%d) failed to handle command", listener.getChunkCoordinates().x, listener.getChunkCoordinates().y, listener.getChunkCoordinates().z), exception); - } else if (this instanceof EntityMinecartCommandBlockListener) { - EntityMinecartCommandBlockListener listener = (EntityMinecartCommandBlockListener) this; - MinecraftServer.getLogger().log(Level.WARN, String.format("MinecartCommandBlock at (%d,%d,%d) failed to handle command", listener.getChunkCoordinates().x, listener.getChunkCoordinates().y, listener.getChunkCoordinates().z), exception); - } else { - MinecraftServer.getLogger().log(Level.WARN, String.format("Unknown CommandBlock failed to handle command"), exception); - } - } - } - - this.b = completed; - // CraftBukkit end - } else { - this.b = 0; - } - } - - // CraftBukkit start - private ArrayList<String[]> buildCommands(String[] args, int pos) { - ArrayList<String[]> commands = new ArrayList<String[]>(); - EntityPlayer[] players = PlayerSelector.getPlayers(this, args[pos]); - if (players != null) { - for (EntityPlayer player : players) { - if (player.world != this.getWorld()) { - continue; - } - String[] command = args.clone(); - command[pos] = player.getName(); - commands.add(command); - } - } - - return commands; - } - // CraftBukkit end - - public String getName() { - return this.f; - } - - public IChatBaseComponent getScoreboardDisplayName() { - return new ChatComponentText(this.getName()); - } - - public void setName(String s) { - this.f = s; - } - - public void sendMessage(IChatBaseComponent ichatbasecomponent) { - if (this.c && this.getWorld() != null && !this.getWorld().isStatic) { - this.d = (new ChatComponentText("[" + a.format(new Date()) + "] ")).addSibling(ichatbasecomponent); - this.e(); - } - } - - public abstract void e(); - - public void b(IChatBaseComponent ichatbasecomponent) { - this.d = ichatbasecomponent; - } -} diff --git a/src/main/java/net/minecraft/server/Container.java b/src/main/java/net/minecraft/server/Container.java deleted file mode 100644 index a10108b9..00000000 --- a/src/main/java/net/minecraft/server/Container.java +++ /dev/null @@ -1,615 +0,0 @@ -package net.minecraft.server; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -// CraftBukkit start -import java.util.HashMap; -import java.util.Map; -import org.bukkit.craftbukkit.inventory.CraftInventory; -import org.bukkit.craftbukkit.inventory.CraftItemStack; -import org.bukkit.event.Event.Result; -import org.bukkit.event.inventory.InventoryDragEvent; -import org.bukkit.event.inventory.InventoryType; -import org.bukkit.inventory.InventoryView; -// CraftBukkit end - -public abstract class Container { - - public List b = new ArrayList(); - public List c = new ArrayList(); - public int windowId; - private int dragType = -1; - public int g; // CraftBukkit - private -> public - private final Set h = new HashSet(); - protected List listeners = new ArrayList(); - private Set i = new HashSet(); - - // CraftBukkit start - public boolean checkReachable = true; - public abstract InventoryView getBukkitView(); - public void transferTo(Container other, org.bukkit.craftbukkit.entity.CraftHumanEntity player) { - InventoryView source = this.getBukkitView(), destination = other.getBukkitView(); - ((CraftInventory) source.getTopInventory()).getInventory().onClose(player); - ((CraftInventory) source.getBottomInventory()).getInventory().onClose(player); - ((CraftInventory) destination.getTopInventory()).getInventory().onOpen(player); - ((CraftInventory) destination.getBottomInventory()).getInventory().onOpen(player); - } - // CraftBukkit end - - public Container() {} - - protected Slot a(Slot slot) { - slot.rawSlotIndex = this.c.size(); - this.c.add(slot); - this.b.add(null); - return slot; - } - - public void addSlotListener(ICrafting icrafting) { - if (this.listeners.contains(icrafting)) { - throw new IllegalArgumentException("Listener already listening"); - } else { - this.listeners.add(icrafting); - icrafting.a(this, this.a()); - this.b(); - } - } - - public List a() { - ArrayList arraylist = new ArrayList(); - - for (int i = 0; i < this.c.size(); ++i) { - arraylist.add(((Slot) this.c.get(i)).getItem()); - } - - return arraylist; - } - - public void b() { - for (int i = 0; i < this.c.size(); ++i) { - ItemStack itemstack = ((Slot) this.c.get(i)).getItem(); - ItemStack itemstack1 = (ItemStack) this.b.get(i); - - if (!ItemStack.matches(itemstack1, itemstack)) { - itemstack1 = itemstack == null ? null : itemstack.cloneItemStack(); - this.b.set(i, itemstack1); - - for (int j = 0; j < this.listeners.size(); ++j) { - ((ICrafting) this.listeners.get(j)).a(this, i, itemstack1); - } - } - } - } - - public boolean a(EntityHuman entityhuman, int i) { - return false; - } - - public Slot getSlot(IInventory iinventory, int i) { - for (int j = 0; j < this.c.size(); ++j) { - Slot slot = (Slot) this.c.get(j); - - if (slot.a(iinventory, i)) { - return slot; - } - } - - return null; - } - - public Slot getSlot(int i) { - return (Slot) this.c.get(i); - } - - public ItemStack b(EntityHuman entityhuman, int i) { - Slot slot = (Slot) this.c.get(i); - - return slot != null ? slot.getItem() : null; - } - - public ItemStack clickItem(int i, int j, int k, EntityHuman entityhuman) { - ItemStack itemstack = null; - PlayerInventory playerinventory = entityhuman.inventory; - int l; - ItemStack itemstack1; - - if (k == 5) { - int i1 = this.g; - - this.g = c(j); - if ((i1 != 1 || this.g != 2) && i1 != this.g) { - this.d(); - } else if (playerinventory.getCarried() == null) { - this.d(); - } else if (this.g == 0) { - this.dragType = b(j); - if (d(this.dragType)) { - this.g = 1; - this.h.clear(); - } else { - this.d(); - } - } else if (this.g == 1) { - Slot slot = (Slot) this.c.get(i); - - if (slot != null && a(slot, playerinventory.getCarried(), true) && slot.isAllowed(playerinventory.getCarried()) && playerinventory.getCarried().count > this.h.size() && this.b(slot)) { - this.h.add(slot); - } - } else if (this.g == 2) { - if (!this.h.isEmpty()) { - itemstack1 = playerinventory.getCarried().cloneItemStack(); - l = playerinventory.getCarried().count; - Iterator iterator = this.h.iterator(); - - Map<Integer, ItemStack> draggedSlots = new HashMap<Integer, ItemStack>(); // CraftBukkit - Store slots from drag in map (raw slot id -> new stack) - while (iterator.hasNext()) { - Slot slot1 = (Slot) iterator.next(); - - if (slot1 != null && a(slot1, playerinventory.getCarried(), true) && slot1.isAllowed(playerinventory.getCarried()) && playerinventory.getCarried().count >= this.h.size() && this.b(slot1)) { - ItemStack itemstack2 = itemstack1.cloneItemStack(); - int j1 = slot1.hasItem() ? slot1.getItem().count : 0; - - a(this.h, this.dragType, itemstack2, j1); - if (itemstack2.count > itemstack2.getMaxStackSize()) { - itemstack2.count = itemstack2.getMaxStackSize(); - } - - if (itemstack2.count > slot1.getMaxStackSize()) { - itemstack2.count = slot1.getMaxStackSize(); - } - - l -= itemstack2.count - j1; - draggedSlots.put(slot1.rawSlotIndex, itemstack2); // CraftBukkit - Put in map instead of setting - } - } - - // CraftBukkit start - InventoryDragEvent - InventoryView view = getBukkitView(); - org.bukkit.inventory.ItemStack newcursor = CraftItemStack.asCraftMirror(itemstack1); - newcursor.setAmount(l); - Map<Integer, org.bukkit.inventory.ItemStack> eventmap = new HashMap<Integer, org.bukkit.inventory.ItemStack>(); - for (Map.Entry<Integer, ItemStack> ditem : draggedSlots.entrySet()) { - eventmap.put(ditem.getKey(), CraftItemStack.asBukkitCopy(ditem.getValue())); - } - - // It's essential that we set the cursor to the new value here to prevent item duplication if a plugin closes the inventory. - ItemStack oldCursor = playerinventory.getCarried(); - playerinventory.setCarried(CraftItemStack.asNMSCopy(newcursor)); - - InventoryDragEvent event = new InventoryDragEvent(view, (newcursor.getType() != org.bukkit.Material.AIR ? newcursor : null), CraftItemStack.asBukkitCopy(oldCursor), this.dragType == 1, eventmap); - entityhuman.world.getServer().getPluginManager().callEvent(event); - - // Whether or not a change was made to the inventory that requires an update. - boolean needsUpdate = event.getResult() != Result.DEFAULT; - - if (event.getResult() != Result.DENY) { - for (Map.Entry<Integer, ItemStack> dslot : draggedSlots.entrySet()) { - view.setItem(dslot.getKey(), CraftItemStack.asBukkitCopy(dslot.getValue())); - } - // The only time the carried item will be set to null is if the inventory is closed by the server. - // If the inventory is closed by the server, then the cursor items are dropped. This is why we change the cursor early. - if (playerinventory.getCarried() != null) { - playerinventory.setCarried(CraftItemStack.asNMSCopy(event.getCursor())); - needsUpdate = true; - - } - } else { - playerinventory.setCarried(oldCursor); - } - - if (needsUpdate && entityhuman instanceof EntityPlayer) { - ((EntityPlayer) entityhuman).updateInventory(this); - } - // CraftBukkit end - } - - this.d(); - } else { - this.d(); - } - } else if (this.g != 0) { - this.d(); - } else { - Slot slot2; - int k1; - ItemStack itemstack3; - - 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(), true); - playerinventory.setCarried((ItemStack) null); - } - - if (j == 1) { - // CraftBukkit start - Store a reference - ItemStack itemstack4 = playerinventory.getCarried(); - if (itemstack4.count > 0) { - entityhuman.drop(itemstack4.a(1), true); - } - - if (itemstack4.count == 0) { - // CraftBukkit end - playerinventory.setCarried((ItemStack) null); - } - } - } - } else if (k == 1) { - if (i < 0) { - return null; - } - - slot2 = (Slot) this.c.get(i); - if (slot2 != null && slot2.isAllowed(entityhuman)) { - itemstack1 = this.b(entityhuman, i); - if (itemstack1 != null) { - Item item = itemstack1.getItem(); - - itemstack = itemstack1.cloneItemStack(); - if (slot2.getItem() != null && slot2.getItem().getItem() == item) { - this.a(i, j, true, entityhuman); - } - } - } - } else { - if (i < 0) { - return null; - } - - slot2 = (Slot) this.c.get(i); - if (slot2 != null) { - itemstack1 = slot2.getItem(); - ItemStack itemstack4 = playerinventory.getCarried(); - - if (itemstack1 != null) { - itemstack = itemstack1.cloneItemStack(); - } - - if (itemstack1 == null) { - if (itemstack4 != null && slot2.isAllowed(itemstack4)) { - k1 = j == 0 ? itemstack4.count : 1; - if (k1 > slot2.getMaxStackSize()) { - k1 = slot2.getMaxStackSize(); - } - - if (itemstack4.count >= k1) { - slot2.set(itemstack4.a(k1)); - } - - if (itemstack4.count == 0) { - playerinventory.setCarried((ItemStack) null); - // CraftBukkit start - Update client cursor if we didn't empty it - } else if (entityhuman instanceof EntityPlayer) { - ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutSetSlot(-1, -1, entityhuman.inventory.getCarried())); - } - // CraftBukkit end - } - } else if (slot2.isAllowed(entityhuman)) { - if (itemstack4 == null) { - k1 = j == 0 ? itemstack1.count : (itemstack1.count + 1) / 2; - itemstack3 = slot2.a(k1); - playerinventory.setCarried(itemstack3); - if (itemstack1.count == 0) { - slot2.set((ItemStack) null); - } - - slot2.a(entityhuman, playerinventory.getCarried()); - } else if (slot2.isAllowed(itemstack4)) { - if (itemstack1.getItem() == itemstack4.getItem() && itemstack1.getData() == itemstack4.getData() && ItemStack.equals(itemstack1, itemstack4)) { - k1 = j == 0 ? itemstack4.count : 1; - if (k1 > slot2.getMaxStackSize() - itemstack1.count) { - k1 = slot2.getMaxStackSize() - itemstack1.count; - } - - if (k1 > itemstack4.getMaxStackSize() - itemstack1.count) { - k1 = itemstack4.getMaxStackSize() - itemstack1.count; - } - - itemstack4.a(k1); - if (itemstack4.count == 0) { - playerinventory.setCarried((ItemStack) null); - // CraftBukkit start - Update client cursor if we didn't empty it - } else if (entityhuman instanceof EntityPlayer) { - ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutSetSlot(-1, -1, entityhuman.inventory.getCarried())); - } - // CraftBukkit end - - itemstack1.count += k1; - } else if (itemstack4.count <= slot2.getMaxStackSize()) { - slot2.set(itemstack4); - playerinventory.setCarried(itemstack1); - } - } else if (itemstack1.getItem() == itemstack4.getItem() && itemstack4.getMaxStackSize() > 1 && (!itemstack1.usesData() || itemstack1.getData() == itemstack4.getData()) && ItemStack.equals(itemstack1, itemstack4)) { - k1 = itemstack1.count; - // CraftBukkit start - itemstack4.getMaxStackSize() -> maxStack - int maxStack = Math.min(itemstack4.getMaxStackSize(), slot2.getMaxStackSize()); - if (k1 > 0 && k1 + itemstack4.count <= maxStack) { - // CraftBukkit end - itemstack4.count += k1; - itemstack1 = slot2.a(k1); - if (itemstack1.count == 0) { - slot2.set((ItemStack) null); - } - - slot2.a(entityhuman, playerinventory.getCarried()); - // CraftBukkit start - Update client cursor if we didn't empty it - } else if (entityhuman instanceof EntityPlayer) { - ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutSetSlot(-1, -1, entityhuman.inventory.getCarried())); - } - // CraftBukkit end - } - } - - slot2.f(); - // CraftBukkit start - Make sure the client has the right slot contents - if (entityhuman instanceof EntityPlayer && slot2.getMaxStackSize() != 64) { - ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutSetSlot(this.windowId, slot2.rawSlotIndex, slot2.getItem())); - // Updating a crafting inventory makes the client reset the result slot, have to send it again - if (this.getBukkitView().getType() == InventoryType.WORKBENCH || this.getBukkitView().getType() == InventoryType.CRAFTING) { - ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutSetSlot(this.windowId, 0, this.getSlot(0).getItem())); - } - } - // CraftBukkit end - } - } - } else if (k == 2 && j >= 0 && j < 9) { - slot2 = (Slot) this.c.get(i); - if (slot2.isAllowed(entityhuman)) { - itemstack1 = playerinventory.getItem(j); - boolean flag = itemstack1 == null || slot2.inventory == playerinventory && slot2.isAllowed(itemstack1); - - k1 = -1; - if (!flag) { - k1 = playerinventory.getFirstEmptySlotIndex(); - flag |= k1 > -1; - } - - if (slot2.hasItem() && flag) { - itemstack3 = slot2.getItem(); - playerinventory.setItem(j, itemstack3.cloneItemStack()); - if ((slot2.inventory != playerinventory || !slot2.isAllowed(itemstack1)) && itemstack1 != null) { - if (k1 > -1) { - playerinventory.pickup(itemstack1); - slot2.a(itemstack3.count); - slot2.set((ItemStack) null); - slot2.a(entityhuman, itemstack3); - } - } else { - slot2.a(itemstack3.count); - slot2.set(itemstack1); - slot2.a(entityhuman, itemstack3); - } - } else if (!slot2.hasItem() && itemstack1 != null && slot2.isAllowed(itemstack1)) { - playerinventory.setItem(j, (ItemStack) null); - slot2.set(itemstack1); - } - } - } else if (k == 3 && entityhuman.abilities.canInstantlyBuild && playerinventory.getCarried() == null && i >= 0) { - slot2 = (Slot) this.c.get(i); - if (slot2 != null && slot2.hasItem()) { - itemstack1 = slot2.getItem().cloneItemStack(); - itemstack1.count = itemstack1.getMaxStackSize(); - playerinventory.setCarried(itemstack1); - } - } else if (k == 4 && playerinventory.getCarried() == null && i >= 0) { - slot2 = (Slot) this.c.get(i); - if (slot2 != null && slot2.hasItem() && slot2.isAllowed(entityhuman)) { - itemstack1 = slot2.a(j == 0 ? 1 : slot2.getItem().count); - slot2.a(entityhuman, itemstack1); - entityhuman.drop(itemstack1, true); - } - } else if (k == 6 && i >= 0) { - slot2 = (Slot) this.c.get(i); - itemstack1 = playerinventory.getCarried(); - if (itemstack1 != null && (slot2 == null || !slot2.hasItem() || !slot2.isAllowed(entityhuman))) { - l = j == 0 ? 0 : this.c.size() - 1; - k1 = j == 0 ? 1 : -1; - - for (int l1 = 0; l1 < 2; ++l1) { - for (int i2 = l; i2 >= 0 && i2 < this.c.size() && itemstack1.count < itemstack1.getMaxStackSize(); i2 += k1) { - Slot slot3 = (Slot) this.c.get(i2); - - if (slot3.hasItem() && a(slot3, itemstack1, true) && slot3.isAllowed(entityhuman) && this.a(itemstack1, slot3) && (l1 != 0 || slot3.getItem().count != slot3.getItem().getMaxStackSize())) { - int j2 = Math.min(itemstack1.getMaxStackSize() - itemstack1.count, slot3.getItem().count); - ItemStack itemstack5 = slot3.a(j2); - - itemstack1.count += j2; - if (itemstack5.count <= 0) { - slot3.set((ItemStack) null); - } - - slot3.a(entityhuman, itemstack5); - } - } - } - } - - this.b(); - } - } - - return itemstack; - } - - public boolean a(ItemStack itemstack, Slot slot) { - return true; - } - - protected void a(int i, int j, boolean flag, EntityHuman entityhuman) { - this.clickItem(i, j, 1, entityhuman); - } - - public void b(EntityHuman entityhuman) { - PlayerInventory playerinventory = entityhuman.inventory; - - if (playerinventory.getCarried() != null) { - entityhuman.drop(playerinventory.getCarried(), false); - playerinventory.setCarried((ItemStack) null); - } - } - - public void a(IInventory iinventory) { - this.b(); - } - - public void setItem(int i, ItemStack itemstack) { - this.getSlot(i).set(itemstack); - } - - public boolean c(EntityHuman entityhuman) { - return !this.i.contains(entityhuman); - } - - public void a(EntityHuman entityhuman, boolean flag) { - if (flag) { - this.i.remove(entityhuman); - } else { - this.i.add(entityhuman); - } - } - - public abstract boolean a(EntityHuman entityhuman); - - protected boolean a(ItemStack itemstack, int i, int j, boolean flag) { - boolean flag1 = false; - int k = i; - - if (flag) { - k = j - 1; - } - - Slot slot; - ItemStack itemstack1; - - if (itemstack.isStackable()) { - while (itemstack.count > 0 && (!flag && k < j || flag && k >= i)) { - slot = (Slot) this.c.get(k); - itemstack1 = slot.getItem(); - if (itemstack1 != null && itemstack1.getItem() == itemstack.getItem() && (!itemstack.usesData() || itemstack.getData() == itemstack1.getData()) && ItemStack.equals(itemstack, itemstack1)) { - int l = itemstack1.count + itemstack.count; - - // CraftBukkit start - itemstack.getMaxStackSize() -> maxStack - int maxStack = Math.min(itemstack.getMaxStackSize(), slot.getMaxStackSize()); - if (l <= maxStack) { - itemstack.count = 0; - itemstack1.count = l; - slot.f(); - flag1 = true; - } else if (itemstack1.count < maxStack) { - itemstack.count -= maxStack - itemstack1.count; - itemstack1.count = maxStack; - slot.f(); - flag1 = true; - } - // CraftBukkit end - } - - if (flag) { - --k; - } else { - ++k; - } - } - } - - if (itemstack.count > 0) { - if (flag) { - k = j - 1; - } else { - k = i; - } - - while (!flag && k < j || flag && k >= i) { - slot = (Slot) this.c.get(k); - itemstack1 = slot.getItem(); - if (itemstack1 == null) { - slot.set(itemstack.cloneItemStack()); - slot.f(); - itemstack.count = 0; - flag1 = true; - break; - } - - if (flag) { - --k; - } else { - ++k; - } - } - } - - return flag1; - } - - public static int b(int i) { - return i >> 2 & 3; - } - - public static int c(int i) { - return i & 3; - } - - public static boolean d(int i) { - return i == 0 || i == 1; - } - - protected void d() { - this.g = 0; - this.h.clear(); - } - - public static boolean a(Slot slot, ItemStack itemstack, boolean flag) { - boolean flag1 = slot == null || !slot.hasItem(); - - if (slot != null && slot.hasItem() && itemstack != null && itemstack.doMaterialsMatch(slot.getItem()) && ItemStack.equals(slot.getItem(), itemstack)) { - int i = flag ? 0 : itemstack.count; - - flag1 |= slot.getItem().count + i <= itemstack.getMaxStackSize(); - } - - return flag1; - } - - public static void a(Set set, int i, ItemStack itemstack, int j) { - switch (i) { - case 0: - itemstack.count = MathHelper.d((float) itemstack.count / (float) set.size()); - break; - - case 1: - itemstack.count = 1; - } - - itemstack.count += j; - } - - public boolean b(Slot slot) { - return true; - } - - public static int b(IInventory iinventory) { - if (iinventory == null) { - return 0; - } else { - int i = 0; - float f = 0.0F; - - for (int j = 0; j < iinventory.getSize(); ++j) { - ItemStack itemstack = iinventory.getItem(j); - - if (itemstack != null) { - f += (float) itemstack.count / (float) Math.min(iinventory.getMaxStackSize(), itemstack.getMaxStackSize()); - ++i; - } - } - - f /= (float) iinventory.getSize(); - return MathHelper.d(f * 14.0F) + (i > 0 ? 1 : 0); - } - } -} diff --git a/src/main/java/net/minecraft/server/ContainerAnvil.java b/src/main/java/net/minecraft/server/ContainerAnvil.java deleted file mode 100644 index af8847f1..00000000 --- a/src/main/java/net/minecraft/server/ContainerAnvil.java +++ /dev/null @@ -1,400 +0,0 @@ -package net.minecraft.server; - -import java.util.Iterator; -import java.util.Map; - -import net.minecraft.util.org.apache.commons.lang3.StringUtils; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import org.bukkit.craftbukkit.inventory.CraftInventoryView; // CraftBukkit - -public class ContainerAnvil extends Container { - - private static final Logger f = LogManager.getLogger(); - private IInventory g = new InventoryCraftResult(); - private IInventory h = new ContainerAnvilInventory(this, "Repair", true, 2); - private World i; - private int j; - private int k; - private int l; - public int a; - private int m; - private String n; - private final EntityHuman o; - // 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.i = world; - this.j = i; - this.k = j; - this.l = k; - this.o = entityhuman; - this.a(new Slot(this.h, 0, 27, 47)); - this.a(new Slot(this.h, 1, 76, 47)); - this.a((Slot) (new SlotAnvilResult(this, this.g, 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.h) { - this.e(); - } - } - - public void e() { - ItemStack itemstack = this.h.getItem(0); - - this.a = 0; - int i = 0; - byte b0 = 0; - int j = 0; - - if (itemstack == null) { - this.g.setItem(0, (ItemStack) null); - this.a = 0; - } else { - ItemStack itemstack1 = itemstack.cloneItemStack(); - ItemStack itemstack2 = this.h.getItem(1); - Map map = EnchantmentManager.a(itemstack1); - boolean flag = false; - int k = b0 + itemstack.getRepairCost() + (itemstack2 == null ? 0 : itemstack2.getRepairCost()); - - this.m = 0; - int l; - int i1; - int j1; - int k1; - int l1; - Iterator iterator; - Enchantment enchantment; - - if (itemstack2 != null) { - flag = itemstack2.getItem() == Items.ENCHANTED_BOOK && Items.ENCHANTED_BOOK.g(itemstack2).size() > 0; - if (itemstack1.g() && itemstack1.getItem().a(itemstack, itemstack2)) { - l = Math.min(itemstack1.j(), itemstack1.l() / 4); - if (l <= 0) { - this.g.setItem(0, (ItemStack) null); - this.a = 0; - return; - } - - for (i1 = 0; l > 0 && i1 < itemstack2.count; ++i1) { - j1 = itemstack1.j() - l; - itemstack1.setData(j1); - i += Math.max(1, l / 100) + map.size(); - l = Math.min(itemstack1.j(), itemstack1.l() / 4); - } - - this.m = i1; - } else { - if (!flag && (itemstack1.getItem() != itemstack2.getItem() || !itemstack1.g())) { - this.g.setItem(0, (ItemStack) null); - this.a = 0; - return; - } - - if (itemstack1.g() && !flag) { - l = itemstack.l() - itemstack.j(); - i1 = itemstack2.l() - itemstack2.j(); - j1 = i1 + itemstack1.l() * 12 / 100; - int i2 = l + j1; - - k1 = itemstack1.l() - i2; - 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; - l1 = ((Integer) map1.get(Integer.valueOf(j1))).intValue(); - int j2; - - if (k1 == l1) { - ++l1; - j2 = l1; - } else { - j2 = Math.max(l1, k1); - } - - l1 = j2; - int k2 = l1 - k1; - boolean flag1 = enchantment.canEnchant(itemstack); - - if (this.o.abilities.canInstantlyBuild || itemstack.getItem() == Items.ENCHANTED_BOOK) { - flag1 = true; - } - - Iterator iterator1 = map.keySet().iterator(); - - while (iterator1.hasNext()) { - int l2 = ((Integer) iterator1.next()).intValue(); - - if (l2 != j1 && !enchantment.a(Enchantment.byId[l2])) { - flag1 = false; - i += k2; - } - } - - if (flag1) { - if (l1 > enchantment.getMaxLevel()) { - l1 = enchantment.getMaxLevel(); - } - - map.put(Integer.valueOf(j1), Integer.valueOf(l1)); - int i3 = 0; - - switch (enchantment.getRandomWeight()) { - case 1: - i3 = 8; - break; - - case 2: - i3 = 4; - - case 3: - case 4: - case 6: - case 7: - case 8: - case 9: - default: - break; - - case 5: - i3 = 2; - break; - - case 10: - i3 = 1; - } - - if (flag) { - i3 = Math.max(1, i3 / 2); - } - - i += i3 * k2; - } - } - } - } - - if (StringUtils.isBlank(this.n)) { - if (itemstack.hasName()) { - j = itemstack.g() ? 7 : itemstack.count * 5; - i += j; - itemstack1.t(); - } - } else if (!this.n.equals(itemstack.getName())) { - j = itemstack.g() ? 7 : itemstack.count * 5; - i += j; - if (itemstack.hasName()) { - k += j / 2; - } - - itemstack1.c(this.n); - } - - l = 0; - - for (iterator = map.keySet().iterator(); iterator.hasNext(); k += l + k1 * l1) { - j1 = ((Integer) iterator.next()).intValue(); - enchantment = Enchantment.byId[j1]; - k1 = ((Integer) map.get(Integer.valueOf(j1))).intValue(); - l1 = 0; - ++l; - switch (enchantment.getRandomWeight()) { - case 1: - l1 = 8; - break; - - case 2: - l1 = 4; - - case 3: - case 4: - case 6: - case 7: - case 8: - case 9: - default: - break; - - case 5: - l1 = 2; - break; - - case 10: - l1 = 1; - } - - if (flag) { - l1 = Math.max(1, l1 / 2); - } - } - - if (flag) { - k = Math.max(1, k / 2); - } - - this.a = k + i; - if (i <= 0) { - itemstack1 = null; - } - - if (j == i && j > 0 && this.a >= 40) { - this.a = 39; - } - - if (this.a >= 40 && !this.o.abilities.canInstantlyBuild) { - itemstack1 = null; - } - - if (itemstack1 != null) { - i1 = itemstack1.getRepairCost(); - if (itemstack2 != null && i1 < itemstack2.getRepairCost()) { - i1 = itemstack2.getRepairCost(); - } - - if (itemstack1.hasName()) { - i1 -= 9; - } - - if (i1 < 0) { - i1 = 0; - } - - i1 += 2; - itemstack1.setRepairCost(i1); - EnchantmentManager.a(map, itemstack1); - } - - this.g.setItem(0, itemstack1); - this.b(); - } - } - - public void addSlotListener(ICrafting icrafting) { - super.addSlotListener(icrafting); - icrafting.setContainerData(this, 0, this.a); - } - - public void b(EntityHuman entityhuman) { - super.b(entityhuman); - if (!this.i.isStatic) { - for (int i = 0; i < this.h.getSize(); ++i) { - ItemStack itemstack = this.h.splitWithoutUpdate(i); - - if (itemstack != null) { - entityhuman.drop(itemstack, false); - } - } - } - } - - public boolean a(EntityHuman entityhuman) { - if (!this.checkReachable) return true; // CraftBukkit - return this.i.getType(this.j, this.k, this.l) != Blocks.ANVIL ? false : entityhuman.e((double) this.j + 0.5D, (double) this.k + 0.5D, (double) this.l + 0.5D) <= 64.0D; - } - - public ItemStack b(EntityHuman entityhuman, int i) { - ItemStack itemstack = null; - Slot slot = (Slot) this.c.get(i); - - if (slot != null && slot.hasItem()) { - 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.f(); - } - - if (itemstack1.count == itemstack.count) { - return null; - } - - slot.a(entityhuman, itemstack1); - } - - return itemstack; - } - - public void a(String s) { - this.n = s; - if (this.getSlot(2).hasItem()) { - ItemStack itemstack = this.getSlot(2).getItem(); - - if (StringUtils.isBlank(s)) { - itemstack.t(); - } else { - itemstack.c(this.n); - } - } - - this.e(); - } - - static IInventory a(ContainerAnvil containeranvil) { - return containeranvil.h; - } - - static int b(ContainerAnvil containeranvil) { - return containeranvil.m; - } - - // CraftBukkit start - public CraftInventoryView getBukkitView() { - if (bukkitEntity != null) { - return bukkitEntity; - } - - org.bukkit.craftbukkit.inventory.CraftInventory inventory = new org.bukkit.craftbukkit.inventory.CraftInventoryAnvil(this.h, 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 deleted file mode 100644 index 6cc0d924..00000000 --- a/src/main/java/net/minecraft/server/ContainerAnvilInventory.java +++ /dev/null @@ -1,58 +0,0 @@ -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, boolean flag, int i) { - super(s, flag, i); - this.a = containeranvil; - } - - // CraftBukkit start - override inherited maxStack from InventorySubcontainer - public int getMaxStackSize() { - return maxStack; - } - // CraftBukkit end - - 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 deleted file mode 100644 index b7fa7b42..00000000 --- a/src/main/java/net/minecraft/server/ContainerBeacon.java +++ /dev/null @@ -1,114 +0,0 @@ -package net.minecraft.server; - -import org.bukkit.craftbukkit.inventory.CraftInventoryView; // CraftBukkit - -public class ContainerBeacon extends Container { - - private TileEntityBeacon a; - 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.a = 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.l(); - this.h = tileentitybeacon.j(); - this.i = tileentitybeacon.k(); - } - - 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 TileEntityBeacon e() { - return this.a; - } - - public boolean a(EntityHuman entityhuman) { - if (!this.checkReachable) return true; // CraftBukkit - return this.a.a(entityhuman); - } - - public ItemStack b(EntityHuman entityhuman, int i) { - ItemStack itemstack = null; - Slot slot = (Slot) this.c.get(i); - - if (slot != null && slot.hasItem()) { - 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.hasItem() && 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.f(); - } - - if (itemstack1.count == itemstack.count) { - return null; - } - - slot.a(entityhuman, itemstack1); - } - - return itemstack; - } - - // CraftBukkit start - public CraftInventoryView getBukkitView() { - if (bukkitEntity != null) { - return bukkitEntity; - } - - org.bukkit.craftbukkit.inventory.CraftInventory inventory = new org.bukkit.craftbukkit.inventory.CraftInventoryBeacon(this.a); - 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 deleted file mode 100644 index 903489ae..00000000 --- a/src/main/java/net/minecraft/server/ContainerBrewingStand.java +++ /dev/null @@ -1,126 +0,0 @@ -package net.minecraft.server; - -// CraftBukkit start -import org.bukkit.craftbukkit.inventory.CraftInventoryBrewer; -import org.bukkit.craftbukkit.inventory.CraftInventoryView; -// CraftBukkit end - -public class ContainerBrewingStand extends Container { - - private TileEntityBrewingStand brewingStand; - private final Slot f; - private int g; - // CraftBukkit start - private CraftInventoryView bukkitEntity = null; - private PlayerInventory player; - // CraftBukkit end - - public ContainerBrewingStand(PlayerInventory playerinventory, TileEntityBrewingStand tileentitybrewingstand) { - player = playerinventory; // CraftBukkit - this.brewingStand = tileentitybrewingstand; - this.a(new SlotPotionBottle(playerinventory.player, tileentitybrewingstand, 0, 56, 46)); - this.a(new SlotPotionBottle(playerinventory.player, tileentitybrewingstand, 1, 79, 53)); - this.a(new SlotPotionBottle(playerinventory.player, tileentitybrewingstand, 2, 102, 46)); - this.f = this.a(new SlotBrewing(this, tileentitybrewingstand, 3, 79, 17)); - - int i; - - for (i = 0; i < 3; ++i) { - for (int j = 0; j < 9; ++j) { - this.a(new Slot(playerinventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); - } - } - - for (i = 0; i < 9; ++i) { - this.a(new Slot(playerinventory, i, 8 + i * 18, 142)); - } - } - - public void addSlotListener(ICrafting icrafting) { - super.addSlotListener(icrafting); - icrafting.setContainerData(this, 0, this.brewingStand.i()); - } - - public void b() { - super.b(); - - for (int i = 0; i < this.listeners.size(); ++i) { - ICrafting icrafting = (ICrafting) this.listeners.get(i); - - if (this.g != this.brewingStand.i()) { - icrafting.setContainerData(this, 0, this.brewingStand.i()); - } - } - - this.g = this.brewingStand.i(); - } - - public boolean a(EntityHuman entityhuman) { - if (!this.checkReachable) return true; // CraftBukkit - return this.brewingStand.a(entityhuman); - } - - public ItemStack b(EntityHuman entityhuman, int i) { - ItemStack itemstack = null; - Slot slot = (Slot) this.c.get(i); - - if (slot != null && slot.hasItem()) { - ItemStack itemstack1 = slot.getItem(); - - itemstack = itemstack1.cloneItemStack(); - if ((i < 0 || i > 2) && i != 3) { - if (!this.f.hasItem() && this.f.isAllowed(itemstack1)) { - if (!this.a(itemstack1, 3, 4, false)) { - return null; - } - } else if (SlotPotionBottle.b_(itemstack)) { - if (!this.a(itemstack1, 0, 3, false)) { - return null; - } - } else if (i >= 4 && i < 31) { - if (!this.a(itemstack1, 31, 40, false)) { - return null; - } - } else if (i >= 31 && i < 40) { - if (!this.a(itemstack1, 4, 31, false)) { - return null; - } - } else if (!this.a(itemstack1, 4, 40, false)) { - return null; - } - } else { - if (!this.a(itemstack1, 4, 40, true)) { - return null; - } - - slot.a(itemstack1, itemstack); - } - - if (itemstack1.count == 0) { - slot.set((ItemStack) null); - } else { - slot.f(); - } - - if (itemstack1.count == itemstack.count) { - return null; - } - - slot.a(entityhuman, itemstack1); - } - - return itemstack; - } - - // CraftBukkit start - public CraftInventoryView getBukkitView() { - if (bukkitEntity != null) { - return bukkitEntity; - } - - CraftInventoryBrewer inventory = new CraftInventoryBrewer(this.brewingStand); - bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), inventory, this); - return bukkitEntity; - } - // CraftBukkit end -} diff --git a/src/main/java/net/minecraft/server/ContainerChest.java b/src/main/java/net/minecraft/server/ContainerChest.java deleted file mode 100644 index c2c4fb53..00000000 --- a/src/main/java/net/minecraft/server/ContainerChest.java +++ /dev/null @@ -1,104 +0,0 @@ -package net.minecraft.server; - -// CraftBukkit start -import org.bukkit.craftbukkit.inventory.CraftInventory; -import org.bukkit.craftbukkit.inventory.CraftInventoryView; -// CraftBukkit end - -public class ContainerChest extends Container { - - public IInventory container; // CraftBukkit - private->public - private int f; - // CraftBukkit start - private CraftInventoryView bukkitEntity = null; - private PlayerInventory player; - - public CraftInventoryView getBukkitView() { - if (bukkitEntity != null) { - return bukkitEntity; - } - - CraftInventory inventory; - if (this.container instanceof PlayerInventory) { - inventory = new org.bukkit.craftbukkit.inventory.CraftInventoryPlayer((PlayerInventory) this.container); - } else if (this.container instanceof InventoryLargeChest) { - inventory = new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest((InventoryLargeChest) this.container); - } else { - inventory = new CraftInventory(this.container); - } - - bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), inventory, this); - return bukkitEntity; - } - // CraftBukkit end - - public ContainerChest(IInventory iinventory, IInventory iinventory1) { - this.container = iinventory1; - this.f = iinventory1.getSize() / 9; - iinventory1.startOpen(); - int i = (this.f - 4) * 18; - // CraftBukkit start - Save player - // TODO: Should we check to make sure it really is an InventoryPlayer? - this.player = (PlayerInventory) iinventory; - // CraftBukkit end - - int j; - int k; - - for (j = 0; j < this.f; ++j) { - for (k = 0; k < 9; ++k) { - this.a(new Slot(iinventory1, k + j * 9, 8 + k * 18, 18 + j * 18)); - } - } - - for (j = 0; j < 3; ++j) { - for (k = 0; k < 9; ++k) { - this.a(new Slot(iinventory, k + j * 9 + 9, 8 + k * 18, 103 + j * 18 + i)); - } - } - - for (j = 0; j < 9; ++j) { - this.a(new Slot(iinventory, j, 8 + j * 18, 161 + i)); - } - } - - public boolean a(EntityHuman entityhuman) { - if (!this.checkReachable) return true; // CraftBukkit - return this.container.a(entityhuman); - } - - public ItemStack b(EntityHuman entityhuman, int i) { - ItemStack itemstack = null; - Slot slot = (Slot) this.c.get(i); - - if (slot != null && slot.hasItem()) { - ItemStack itemstack1 = slot.getItem(); - - itemstack = itemstack1.cloneItemStack(); - if (i < this.f * 9) { - if (!this.a(itemstack1, this.f * 9, this.c.size(), true)) { - return null; - } - } else if (!this.a(itemstack1, 0, this.f * 9, false)) { - return null; - } - - if (itemstack1.count == 0) { - slot.set((ItemStack) null); - } else { - slot.f(); - } - } - - return itemstack; - } - - public void b(EntityHuman entityhuman) { - super.b(entityhuman); - this.container.closeContainer(); - } - - public IInventory e() { - return this.container; - } -} diff --git a/src/main/java/net/minecraft/server/ContainerDispenser.java b/src/main/java/net/minecraft/server/ContainerDispenser.java deleted file mode 100644 index 32187ec1..00000000 --- a/src/main/java/net/minecraft/server/ContainerDispenser.java +++ /dev/null @@ -1,91 +0,0 @@ -package net.minecraft.server; - -// CraftBukkit start -import org.bukkit.craftbukkit.inventory.CraftInventory; -import org.bukkit.craftbukkit.inventory.CraftInventoryView; -// CraftBukkit end - -public class ContainerDispenser extends Container { - - public TileEntityDispenser items; // CraftBukkit - private -> public - // CraftBukkit start - private CraftInventoryView bukkitEntity = null; - private PlayerInventory player; - // CraftBukkit end - - public ContainerDispenser(IInventory iinventory, TileEntityDispenser tileentitydispenser) { - this.items = tileentitydispenser; - // CraftBukkit start - Save player - // TODO: Should we check to make sure it really is an InventoryPlayer? - this.player = (PlayerInventory)iinventory; - // CraftBukkit end - - int i; - int j; - - for (i = 0; i < 3; ++i) { - for (j = 0; j < 3; ++j) { - this.a(new Slot(tileentitydispenser, j + i * 3, 62 + j * 18, 17 + i * 18)); - } - } - - for (i = 0; i < 3; ++i) { - for (j = 0; j < 9; ++j) { - this.a(new Slot(iinventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); - } - } - - for (i = 0; i < 9; ++i) { - this.a(new Slot(iinventory, i, 8 + i * 18, 142)); - } - } - - public boolean a(EntityHuman entityhuman) { - if (!this.checkReachable) return true; // CraftBukkit - return this.items.a(entityhuman); - } - - public ItemStack b(EntityHuman entityhuman, int i) { - ItemStack itemstack = null; - Slot slot = (Slot) this.c.get(i); - - if (slot != null && slot.hasItem()) { - ItemStack itemstack1 = slot.getItem(); - - itemstack = itemstack1.cloneItemStack(); - if (i < 9) { - if (!this.a(itemstack1, 9, 45, true)) { - return null; - } - } else if (!this.a(itemstack1, 0, 9, false)) { - return null; - } - - if (itemstack1.count == 0) { - slot.set((ItemStack) null); - } else { - slot.f(); - } - - 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 CraftInventory(this.items); - bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), inventory, this); - return bukkitEntity; - } - // CraftBukkit end -} diff --git a/src/main/java/net/minecraft/server/ContainerEnchantTable.java b/src/main/java/net/minecraft/server/ContainerEnchantTable.java deleted file mode 100644 index 5f948e47..00000000 --- a/src/main/java/net/minecraft/server/ContainerEnchantTable.java +++ /dev/null @@ -1,284 +0,0 @@ -package net.minecraft.server; - -import java.util.List; -import java.util.Random; - -// CraftBukkit start -import java.util.Map; - -import org.bukkit.craftbukkit.inventory.CraftInventoryEnchanting; -import org.bukkit.craftbukkit.inventory.CraftInventoryView; -import org.bukkit.craftbukkit.inventory.CraftItemStack; -import org.bukkit.event.enchantment.EnchantItemEvent; -import org.bukkit.event.enchantment.PrepareItemEnchantEvent; -import org.bukkit.entity.Player; -// CraftBukkit end - -public class ContainerEnchantTable extends Container { - - // CraftBukkit - make type specific (changed from IInventory) - public ContainerEnchantTableInventory enchantSlots = new ContainerEnchantTableInventory(this, "Enchant", true, 1); - private World world; - private int x; - private int y; - private int z; - private Random l = new Random(); - public long f; - public int[] costs = new int[3]; - // CraftBukkit start - private CraftInventoryView bukkitEntity = null; - private Player player; - // CraftBukkit end - - public ContainerEnchantTable(PlayerInventory playerinventory, World world, int i, int j, int k) { - this.world = world; - this.x = i; - this.y = j; - this.z = k; - this.a((Slot) (new SlotEnchant(this, this.enchantSlots, 0, 25, 47))); - - 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)); - } - - // CraftBukkit start - player = (Player) playerinventory.player.getBukkitEntity(); - enchantSlots.player = player; - // CraftBukkit end - } - - public void addSlotListener(ICrafting icrafting) { - super.addSlotListener(icrafting); - icrafting.setContainerData(this, 0, this.costs[0]); - icrafting.setContainerData(this, 1, this.costs[1]); - icrafting.setContainerData(this, 2, this.costs[2]); - } - - public void b() { - super.b(); - - for (int i = 0; i < this.listeners.size(); ++i) { - ICrafting icrafting = (ICrafting) this.listeners.get(i); - - icrafting.setContainerData(this, 0, this.costs[0]); - icrafting.setContainerData(this, 1, this.costs[1]); - icrafting.setContainerData(this, 2, this.costs[2]); - } - } - - public void a(IInventory iinventory) { - if (iinventory == this.enchantSlots) { - ItemStack itemstack = iinventory.getItem(0); - int i; - - if (itemstack != null) { // CraftBukkit - relax condition - this.f = this.l.nextLong(); - if (!this.world.isStatic) { - i = 0; - - int j; - - for (j = -1; j <= 1; ++j) { - for (int k = -1; k <= 1; ++k) { - if ((j != 0 || k != 0) && this.world.isEmpty(this.x + k, this.y, this.z + j) && this.world.isEmpty(this.x + k, this.y + 1, this.z + j)) { - if (this.world.getType(this.x + k * 2, this.y, this.z + j * 2) == Blocks.BOOKSHELF) { - ++i; - } - - if (this.world.getType(this.x + k * 2, this.y + 1, this.z + j * 2) == Blocks.BOOKSHELF) { - ++i; - } - - if (k != 0 && j != 0) { - if (this.world.getType(this.x + k * 2, this.y, this.z + j) == Blocks.BOOKSHELF) { - ++i; - } - - if (this.world.getType(this.x + k * 2, this.y + 1, this.z + j) == Blocks.BOOKSHELF) { - ++i; - } - - if (this.world.getType(this.x + k, this.y, this.z + j * 2) == Blocks.BOOKSHELF) { - ++i; - } - - if (this.world.getType(this.x + k, this.y + 1, this.z + j * 2) == Blocks.BOOKSHELF) { - ++i; - } - } - } - } - } - - for (j = 0; j < 3; ++j) { - this.costs[j] = EnchantmentManager.a(this.l, j, i, itemstack); - } - - // CraftBukkit start - CraftItemStack item = CraftItemStack.asCraftMirror(itemstack); - PrepareItemEnchantEvent event = new PrepareItemEnchantEvent(player, this.getBukkitView(), this.world.getWorld().getBlockAt(this.x, this.y, this.z), item, this.costs, i); - event.setCancelled(!itemstack.x()); - this.world.getServer().getPluginManager().callEvent(event); - - if (event.isCancelled()) { - for (i = 0; i < 3; ++i) { - this.costs[i] = 0; - } - return; - } - // CraftBukkit end - - this.b(); - } - } else { - for (i = 0; i < 3; ++i) { - this.costs[i] = 0; - } - } - } - } - - public boolean a(EntityHuman entityhuman, int i) { - ItemStack itemstack = this.enchantSlots.getItem(0); - - if (this.costs[i] > 0 && itemstack != null && (entityhuman.expLevel >= this.costs[i] || entityhuman.abilities.canInstantlyBuild)) { - if (!this.world.isStatic) { - List list = EnchantmentManager.b(this.l, itemstack, this.costs[i]); - // CraftBukkit start - Provide an empty enchantment list - if (list == null) { - list = new java.util.ArrayList<EnchantmentInstance>(); - } - // CraftBukkit end - - boolean flag = itemstack.getItem() == Items.BOOK; - - if (list != null) { - // CraftBukkit start - Map<org.bukkit.enchantments.Enchantment, Integer> enchants = new java.util.HashMap<org.bukkit.enchantments.Enchantment, Integer>(); - for (Object obj : list) { - EnchantmentInstance instance = (EnchantmentInstance) obj; - enchants.put(org.bukkit.enchantments.Enchantment.getById(instance.enchantment.id), instance.level); - } - CraftItemStack item = CraftItemStack.asCraftMirror(itemstack); - - EnchantItemEvent event = new EnchantItemEvent((Player) entityhuman.getBukkitEntity(), this.getBukkitView(), this.world.getWorld().getBlockAt(this.x, this.y, this.z), item, this.costs[i], enchants, i); - this.world.getServer().getPluginManager().callEvent(event); - - int level = event.getExpLevelCost(); - if (event.isCancelled() || (level > entityhuman.expLevel && !entityhuman.abilities.canInstantlyBuild) || event.getEnchantsToAdd().isEmpty()) { - return false; - } - - if (flag) { - itemstack.setItem(Items.ENCHANTED_BOOK); - } - - for (Map.Entry<org.bukkit.enchantments.Enchantment, Integer> entry : event.getEnchantsToAdd().entrySet()) { - try { - if (flag) { - int enchantId = entry.getKey().getId(); - if (Enchantment.byId[enchantId] == null) { - continue; - } - - EnchantmentInstance enchantment = new EnchantmentInstance(enchantId, entry.getValue()); - Items.ENCHANTED_BOOK.a(itemstack, enchantment); - } else { - item.addUnsafeEnchantment(entry.getKey(), entry.getValue()); - } - } catch (IllegalArgumentException e) { - /* Just swallow invalid enchantments */ - } - } - - entityhuman.levelDown(-level); - // CraftBukkit end - - this.a(this.enchantSlots); - } - } - - return true; - } else { - return false; - } - } - - public void b(EntityHuman entityhuman) { - super.b(entityhuman); - if (!this.world.isStatic) { - ItemStack itemstack = this.enchantSlots.splitWithoutUpdate(0); - - if (itemstack != null) { - entityhuman.drop(itemstack, false); - } - } - } - - public boolean a(EntityHuman entityhuman) { - if (!this.checkReachable) return true; // CraftBukkit - return this.world.getType(this.x, this.y, this.z) != Blocks.ENCHANTMENT_TABLE ? false : entityhuman.e((double) this.x + 0.5D, (double) this.y + 0.5D, (double) this.z + 0.5D) <= 64.0D; - } - - public ItemStack b(EntityHuman entityhuman, int i) { - ItemStack itemstack = null; - Slot slot = (Slot) this.c.get(i); - - if (slot != null && slot.hasItem()) { - ItemStack itemstack1 = slot.getItem(); - - itemstack = itemstack1.cloneItemStack(); - if (i == 0) { - if (!this.a(itemstack1, 1, 37, true)) { - return null; - } - } else { - if (((Slot) this.c.get(0)).hasItem() || !((Slot) this.c.get(0)).isAllowed(itemstack1)) { - return null; - } - - if (itemstack1.hasTag() && itemstack1.count == 1) { - ((Slot) this.c.get(0)).set(itemstack1.cloneItemStack()); - itemstack1.count = 0; - } else if (itemstack1.count >= 1) { - ((Slot) this.c.get(0)).set(new ItemStack(itemstack1.getItem(), 1, itemstack1.getData())); - --itemstack1.count; - } - } - - if (itemstack1.count == 0) { - slot.set((ItemStack) null); - } else { - slot.f(); - } - - if (itemstack1.count == itemstack.count) { - return null; - } - - slot.a(entityhuman, itemstack1); - } - - return itemstack; - } - - // CraftBukkit start - public CraftInventoryView getBukkitView() { - if (bukkitEntity != null) { - return bukkitEntity; - } - - CraftInventoryEnchanting inventory = new CraftInventoryEnchanting(this.enchantSlots); - bukkitEntity = new CraftInventoryView(this.player, inventory, this); - return bukkitEntity; - } - // CraftBukkit end -} diff --git a/src/main/java/net/minecraft/server/ContainerEnchantTableInventory.java b/src/main/java/net/minecraft/server/ContainerEnchantTableInventory.java deleted file mode 100644 index b9dbf60a..00000000 --- a/src/main/java/net/minecraft/server/ContainerEnchantTableInventory.java +++ /dev/null @@ -1,57 +0,0 @@ -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 ContainerEnchantTableInventory extends InventorySubcontainer { // CraftBukkit -> public - - final ContainerEnchantTable enchantTable; - - // 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 - - ContainerEnchantTableInventory(ContainerEnchantTable containerenchanttable, String s, boolean flag, int i) { - super(s, flag, i); - this.enchantTable = containerenchanttable; - this.setMaxStackSize(1); // CraftBukkit - } - - public int getMaxStackSize() { - return maxStack; // CraftBukkit - } - - public void update() { - super.update(); - this.enchantTable.a((IInventory) this); - } -} diff --git a/src/main/java/net/minecraft/server/ContainerFurnace.java b/src/main/java/net/minecraft/server/ContainerFurnace.java deleted file mode 100644 index 24385282..00000000 --- a/src/main/java/net/minecraft/server/ContainerFurnace.java +++ /dev/null @@ -1,135 +0,0 @@ -package net.minecraft.server; - -// CraftBukkit start -import org.bukkit.craftbukkit.inventory.CraftInventoryFurnace; -import org.bukkit.craftbukkit.inventory.CraftInventoryView; -// CraftBukkit end - -public class ContainerFurnace extends Container { - - private TileEntityFurnace furnace; - private int f; - private int g; - private int h; - - // CraftBukkit start - private CraftInventoryView bukkitEntity = null; - private PlayerInventory player; - - public CraftInventoryView getBukkitView() { - if (bukkitEntity != null) { - return bukkitEntity; - } - - CraftInventoryFurnace inventory = new CraftInventoryFurnace(this.furnace); - bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), inventory, this); - return bukkitEntity; - } - // CraftBukkit end - - public ContainerFurnace(PlayerInventory playerinventory, TileEntityFurnace tileentityfurnace) { - this.furnace = tileentityfurnace; - this.a(new Slot(tileentityfurnace, 0, 56, 17)); - this.a(new Slot(tileentityfurnace, 1, 56, 53)); - this.a(new SlotFurnaceResult(playerinventory.player, tileentityfurnace, 2, 116, 35)); - this.player = playerinventory; // CraftBukkit - save player - - int i; - - for (i = 0; i < 3; ++i) { - for (int j = 0; j < 9; ++j) { - this.a(new Slot(playerinventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); - } - } - - for (i = 0; i < 9; ++i) { - this.a(new Slot(playerinventory, i, 8 + i * 18, 142)); - } - } - - public void addSlotListener(ICrafting icrafting) { - super.addSlotListener(icrafting); - icrafting.setContainerData(this, 0, this.furnace.cookTime); - icrafting.setContainerData(this, 1, this.furnace.burnTime); - icrafting.setContainerData(this, 2, this.furnace.ticksForCurrentFuel); - } - - public void b() { - super.b(); - - for (int i = 0; i < this.listeners.size(); ++i) { - ICrafting icrafting = (ICrafting) this.listeners.get(i); - - if (this.f != this.furnace.cookTime) { - icrafting.setContainerData(this, 0, this.furnace.cookTime); - } - - if (this.g != this.furnace.burnTime) { - icrafting.setContainerData(this, 1, this.furnace.burnTime); - } - - if (this.h != this.furnace.ticksForCurrentFuel) { - icrafting.setContainerData(this, 2, this.furnace.ticksForCurrentFuel); - } - } - - this.f = this.furnace.cookTime; - this.g = this.furnace.burnTime; - this.h = this.furnace.ticksForCurrentFuel; - } - - public boolean a(EntityHuman entityhuman) { - if (!this.checkReachable) return true; // CraftBukkit - return this.furnace.a(entityhuman); - } - - public ItemStack b(EntityHuman entityhuman, int i) { - ItemStack itemstack = null; - Slot slot = (Slot) this.c.get(i); - - if (slot != null && slot.hasItem()) { - 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 != 1 && i != 0) { - if (RecipesFurnace.getInstance().getResult(itemstack1) != null) { - if (!this.a(itemstack1, 0, 1, false)) { - return null; - } - } else if (TileEntityFurnace.isFuel(itemstack1)) { - if (!this.a(itemstack1, 1, 2, false)) { - return null; - } - } else if (i >= 3 && i < 30) { - if (!this.a(itemstack1, 30, 39, false)) { - return null; - } - } else if (i >= 30 && i < 39 && !this.a(itemstack1, 3, 30, false)) { - return null; - } - } else if (!this.a(itemstack1, 3, 39, false)) { - return null; - } - - if (itemstack1.count == 0) { - slot.set((ItemStack) null); - } else { - slot.f(); - } - - if (itemstack1.count == itemstack.count) { - return null; - } - - slot.a(entityhuman, itemstack1); - } - - return itemstack; - } -} diff --git a/src/main/java/net/minecraft/server/ContainerHopper.java b/src/main/java/net/minecraft/server/ContainerHopper.java deleted file mode 100644 index e2c789b4..00000000 --- a/src/main/java/net/minecraft/server/ContainerHopper.java +++ /dev/null @@ -1,85 +0,0 @@ -package net.minecraft.server; - -// CraftBukkit start -import org.bukkit.craftbukkit.inventory.CraftInventory; -import org.bukkit.craftbukkit.inventory.CraftInventoryView; -// CraftBukkit end - -public class ContainerHopper extends Container { - - private final IInventory hopper; - - // CraftBukkit start - private CraftInventoryView bukkitEntity = null; - private PlayerInventory player; - - public CraftInventoryView getBukkitView() { - if (bukkitEntity != null) { - return bukkitEntity; - } - - CraftInventory inventory = new CraftInventory(this.hopper); - bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), inventory, this); - return bukkitEntity; - } - // CraftBukkit end - - public ContainerHopper(PlayerInventory playerinventory, IInventory iinventory) { - this.hopper = iinventory; - this.player = playerinventory; // CraftBukkit - save player - iinventory.startOpen(); - byte b0 = 51; - - int i; - - for (i = 0; i < iinventory.getSize(); ++i) { - this.a(new Slot(iinventory, i, 44 + i * 18, 20)); - } - - for (i = 0; i < 3; ++i) { - for (int j = 0; j < 9; ++j) { - this.a(new Slot(playerinventory, j + i * 9 + 9, 8 + j * 18, i * 18 + b0)); - } - } - - for (i = 0; i < 9; ++i) { - this.a(new Slot(playerinventory, i, 8 + i * 18, 58 + b0)); - } - } - - public boolean a(EntityHuman entityhuman) { - if (!this.checkReachable) return true; // CraftBukkit - return this.hopper.a(entityhuman); - } - - public ItemStack b(EntityHuman entityhuman, int i) { - ItemStack itemstack = null; - Slot slot = (Slot) this.c.get(i); - - if (slot != null && slot.hasItem()) { - ItemStack itemstack1 = slot.getItem(); - - itemstack = itemstack1.cloneItemStack(); - if (i < this.hopper.getSize()) { - if (!this.a(itemstack1, this.hopper.getSize(), this.c.size(), true)) { - return null; - } - } else if (!this.a(itemstack1, 0, this.hopper.getSize(), false)) { - return null; - } - - if (itemstack1.count == 0) { - slot.set((ItemStack) null); - } else { - slot.f(); - } - } - - return itemstack; - } - - public void b(EntityHuman entityhuman) { - super.b(entityhuman); - this.hopper.closeContainer(); - } -} diff --git a/src/main/java/net/minecraft/server/ContainerHorse.java b/src/main/java/net/minecraft/server/ContainerHorse.java deleted file mode 100644 index 79aa1826..00000000 --- a/src/main/java/net/minecraft/server/ContainerHorse.java +++ /dev/null @@ -1,104 +0,0 @@ -package net.minecraft.server; - -// CraftBukkit start -import org.bukkit.craftbukkit.inventory.CraftInventory; -import org.bukkit.craftbukkit.inventory.CraftInventoryView; -import org.bukkit.inventory.InventoryView; -// CraftBukkit end - -public class ContainerHorse extends Container { - - private IInventory a; - private EntityHorse f; - - // CraftBukkit start - org.bukkit.craftbukkit.inventory.CraftInventoryView bukkitEntity; - PlayerInventory player; - - @Override - public InventoryView getBukkitView() { - if (bukkitEntity != null) { - return bukkitEntity; - } - - CraftInventory inventory = new org.bukkit.craftbukkit.inventory.CraftInventoryHorse(this.a); - return bukkitEntity = new CraftInventoryView(player.player.getBukkitEntity(), inventory, this); - } - - public ContainerHorse(IInventory iinventory, IInventory iinventory1, EntityHorse entityhorse) { - player = (PlayerInventory) iinventory; - // CraftBukkit end - this.a = iinventory1; - this.f = entityhorse; - byte b0 = 3; - - iinventory1.startOpen(); - int i = (b0 - 4) * 18; - - this.a(new SlotHorseSaddle(this, iinventory1, 0, 8, 18)); - this.a(new SlotHorseArmor(this, iinventory1, 1, 8, 36, entityhorse)); - int j; - int k; - - if (entityhorse.hasChest()) { - for (j = 0; j < b0; ++j) { - for (k = 0; k < 5; ++k) { - this.a(new Slot(iinventory1, 2 + k + j * 5, 80 + k * 18, 18 + j * 18)); - } - } - } - - for (j = 0; j < 3; ++j) { - for (k = 0; k < 9; ++k) { - this.a(new Slot(iinventory, k + j * 9 + 9, 8 + k * 18, 102 + j * 18 + i)); - } - } - - for (j = 0; j < 9; ++j) { - this.a(new Slot(iinventory, j, 8 + j * 18, 160 + i)); - } - } - - public boolean a(EntityHuman entityhuman) { - return this.a.a(entityhuman) && this.f.isAlive() && this.f.e(entityhuman) < 8.0F; - } - - public ItemStack b(EntityHuman entityhuman, int i) { - ItemStack itemstack = null; - Slot slot = (Slot) this.c.get(i); - - if (slot != null && slot.hasItem()) { - ItemStack itemstack1 = slot.getItem(); - - itemstack = itemstack1.cloneItemStack(); - if (i < this.a.getSize()) { - if (!this.a(itemstack1, this.a.getSize(), this.c.size(), true)) { - return null; - } - } else if (this.getSlot(1).isAllowed(itemstack1) && !this.getSlot(1).hasItem()) { - if (!this.a(itemstack1, 1, 2, false)) { - return null; - } - } else if (this.getSlot(0).isAllowed(itemstack1)) { - if (!this.a(itemstack1, 0, 1, false)) { - return null; - } - } else if (this.a.getSize() <= 2 || !this.a(itemstack1, 2, this.a.getSize(), false)) { - return null; - } - - if (itemstack1.count == 0) { - slot.set((ItemStack) null); - } else { - slot.f(); - } - } - - return itemstack; - } - - public void b(EntityHuman entityhuman) { - super.b(entityhuman); - this.a.closeContainer(); - } -} diff --git a/src/main/java/net/minecraft/server/ContainerMerchant.java b/src/main/java/net/minecraft/server/ContainerMerchant.java deleted file mode 100644 index 97f97f3e..00000000 --- a/src/main/java/net/minecraft/server/ContainerMerchant.java +++ /dev/null @@ -1,131 +0,0 @@ -package net.minecraft.server; - -import org.bukkit.craftbukkit.inventory.CraftInventoryView; // CraftBukkit - -public class ContainerMerchant extends Container { - - private IMerchant merchant; - private InventoryMerchant f; - private final World g; - - // CraftBukkit start - private CraftInventoryView bukkitEntity = null; - private PlayerInventory player; - - @Override - public CraftInventoryView getBukkitView() { - if (bukkitEntity == null) { - bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), new org.bukkit.craftbukkit.inventory.CraftInventoryMerchant(this.getMerchantInventory()), this); - } - return bukkitEntity; - } - // CraftBukkit end - - - public ContainerMerchant(PlayerInventory playerinventory, IMerchant imerchant, World world) { - this.merchant = imerchant; - this.g = world; - this.f = new InventoryMerchant(playerinventory.player, imerchant); - this.a(new Slot(this.f, 0, 36, 53)); - this.a(new Slot(this.f, 1, 62, 53)); - this.a((Slot) (new SlotMerchantResult(playerinventory.player, imerchant, this.f, 2, 120, 53))); - this.player = playerinventory; // CraftBukkit - save player - - int i; - - for (i = 0; i < 3; ++i) { - for (int j = 0; j < 9; ++j) { - this.a(new Slot(playerinventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); - } - } - - for (i = 0; i < 9; ++i) { - this.a(new Slot(playerinventory, i, 8 + i * 18, 142)); - } - } - - public InventoryMerchant getMerchantInventory() { - return this.f; - } - - public void addSlotListener(ICrafting icrafting) { - super.addSlotListener(icrafting); - } - - public void b() { - super.b(); - } - - public void a(IInventory iinventory) { - this.f.h(); - super.a(iinventory); - } - - public void e(int i) { - this.f.c(i); - } - - public boolean a(EntityHuman entityhuman) { - return this.merchant.b() == entityhuman; - } - - public ItemStack b(EntityHuman entityhuman, int i) { - ItemStack itemstack = null; - Slot slot = (Slot) this.c.get(i); - - if (slot != null && slot.hasItem()) { - 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 < 30) { - if (!this.a(itemstack1, 30, 39, false)) { - return null; - } - } else if (i >= 30 && i < 39 && !this.a(itemstack1, 3, 30, false)) { - return null; - } - } else if (!this.a(itemstack1, 3, 39, false)) { - return null; - } - - if (itemstack1.count == 0) { - slot.set((ItemStack) null); - } else { - slot.f(); - } - - if (itemstack1.count == itemstack.count) { - return null; - } - - slot.a(entityhuman, itemstack1); - } - - return itemstack; - } - - public void b(EntityHuman entityhuman) { - super.b(entityhuman); - this.merchant.a_((EntityHuman) null); - super.b(entityhuman); - if (!this.g.isStatic) { - ItemStack itemstack = this.f.splitWithoutUpdate(0); - - if (itemstack != null) { - entityhuman.drop(itemstack, false); - } - - itemstack = this.f.splitWithoutUpdate(1); - if (itemstack != null) { - entityhuman.drop(itemstack, false); - } - } - } -} diff --git a/src/main/java/net/minecraft/server/ContainerPlayer.java b/src/main/java/net/minecraft/server/ContainerPlayer.java deleted file mode 100644 index 587ee261..00000000 --- a/src/main/java/net/minecraft/server/ContainerPlayer.java +++ /dev/null @@ -1,157 +0,0 @@ -package net.minecraft.server; - -// CraftBukkit start -import org.bukkit.craftbukkit.inventory.CraftInventoryCrafting; -import org.bukkit.craftbukkit.inventory.CraftInventoryView; -// CraftBukkit end - -public class ContainerPlayer extends Container { - - public InventoryCrafting craftInventory = new InventoryCrafting(this, 2, 2); - public IInventory resultInventory = new InventoryCraftResult(); - public boolean g; - private final EntityHuman h; - // CraftBukkit start - private CraftInventoryView bukkitEntity = null; - private PlayerInventory player; - // CraftBukkit end - - 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.a((Slot) (new SlotResult(playerinventory.player, this.craftInventory, this.resultInventory, 0, 144, 36))); - - int i; - int j; - - for (i = 0; i < 2; ++i) { - for (j = 0; j < 2; ++j) { - this.a(new Slot(this.craftInventory, j + i * 2, 88 + j * 18, 26 + i * 18)); - } - } - - for (i = 0; i < 4; ++i) { - this.a((Slot) (new SlotArmor(this, playerinventory, playerinventory.getSize() - 1 - i, 8, 8 + i * 18, i))); - } - - for (i = 0; i < 3; ++i) { - for (j = 0; j < 9; ++j) { - this.a(new Slot(playerinventory, j + (i + 1) * 9, 8 + j * 18, 84 + i * 18)); - } - } - - for (i = 0; i < 9; ++i) { - this.a(new Slot(playerinventory, i, 8 + i * 18, 142)); - } - - // this.a((IInventory) this.craftInventory); // CraftBukkit - unneeded since it just sets result slot to empty - } - - 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, this.h.world); - this.resultInventory.setItem(0, craftResult); - if (super.listeners.size() < 1) { - return; - } - - EntityPlayer player = (EntityPlayer) super.listeners.get(0); // TODO: Is this _always_ correct? Seems like it. - player.playerConnection.sendPacket(new PacketPlayOutSetSlot(player.activeContainer.windowId, 0, craftResult)); - // CraftBukkit end - } - - public void b(EntityHuman entityhuman) { - super.b(entityhuman); - - for (int i = 0; i < 4; ++i) { - ItemStack itemstack = this.craftInventory.splitWithoutUpdate(i); - - if (itemstack != null) { - entityhuman.drop(itemstack, false); - } - } - - this.resultInventory.setItem(0, (ItemStack) null); - } - - public boolean a(EntityHuman entityhuman) { - return true; - } - - public ItemStack b(EntityHuman entityhuman, int i) { - ItemStack itemstack = null; - Slot slot = (Slot) this.c.get(i); - - if (slot != null && slot.hasItem()) { - ItemStack itemstack1 = slot.getItem(); - - itemstack = itemstack1.cloneItemStack(); - if (i == 0) { - if (!this.a(itemstack1, 9, 45, true)) { - return null; - } - - slot.a(itemstack1, itemstack); - } else if (i >= 1 && i < 5) { - if (!this.a(itemstack1, 9, 45, false)) { - return null; - } - } else if (i >= 5 && i < 9) { - if (!this.a(itemstack1, 9, 45, false)) { - return null; - } - } else if (itemstack.getItem() instanceof ItemArmor && !((Slot) this.c.get(5 + ((ItemArmor) itemstack.getItem()).b)).hasItem()) { - int j = 5 + ((ItemArmor) itemstack.getItem()).b; - - if (!this.a(itemstack1, j, j + 1, false)) { - return null; - } - } else if (i >= 9 && i < 36) { - if (!this.a(itemstack1, 36, 45, false)) { - return null; - } - } else if (i >= 36 && i < 45) { - if (!this.a(itemstack1, 9, 36, false)) { - return null; - } - } else if (!this.a(itemstack1, 9, 45, false)) { - return null; - } - - if (itemstack1.count == 0) { - slot.set((ItemStack) null); - } else { - slot.f(); - } - - if (itemstack1.count == itemstack.count) { - return null; - } - - slot.a(entityhuman, itemstack1); - } - - return itemstack; - } - - public boolean a(ItemStack itemstack, Slot slot) { - return slot.inventory != this.resultInventory && super.a(itemstack, slot); - } - - // CraftBukkit start - public CraftInventoryView getBukkitView() { - if (bukkitEntity != null) { - return bukkitEntity; - } - - CraftInventoryCrafting inventory = new CraftInventoryCrafting(this.craftInventory, this.resultInventory); - bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), inventory, this); - return bukkitEntity; - } - // CraftBukkit end -} diff --git a/src/main/java/net/minecraft/server/ContainerWorkbench.java b/src/main/java/net/minecraft/server/ContainerWorkbench.java deleted file mode 100644 index 37c61054..00000000 --- a/src/main/java/net/minecraft/server/ContainerWorkbench.java +++ /dev/null @@ -1,145 +0,0 @@ -package net.minecraft.server; - -// CraftBukkit start -import org.bukkit.craftbukkit.inventory.CraftInventoryCrafting; -import org.bukkit.craftbukkit.inventory.CraftInventoryView; -// CraftBukkit end - -public class ContainerWorkbench extends Container { - - public InventoryCrafting craftInventory; // CraftBukkit - move initialization into constructor - public IInventory resultInventory; // CraftBukkit - move initialization into constructor - private World g; - private int h; - private int i; - private int j; - // CraftBukkit start - private CraftInventoryView bukkitEntity = null; - private PlayerInventory player; - // CraftBukkit end - - public ContainerWorkbench(PlayerInventory playerinventory, World world, int i, int j, int k) { - // CraftBukkit start - Switched order of IInventory construction and stored player - this.resultInventory = new InventoryCraftResult(); - this.craftInventory = new InventoryCrafting(this, 3, 3, playerinventory.player); // CraftBukkit - pass player - this.craftInventory.resultInventory = this.resultInventory; - this.player = playerinventory; - // CraftBukkit end - this.g = world; - this.h = i; - this.i = j; - this.j = k; - this.a((Slot) (new SlotResult(playerinventory.player, this.craftInventory, this.resultInventory, 0, 124, 35))); - - int l; - int i1; - - for (l = 0; l < 3; ++l) { - for (i1 = 0; i1 < 3; ++i1) { - this.a(new Slot(this.craftInventory, i1 + l * 3, 30 + i1 * 18, 17 + l * 18)); - } - } - - for (l = 0; l < 3; ++l) { - for (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)); - } - - this.a((IInventory) this.craftInventory); - } - - public void a(IInventory iinventory) { - // CraftBukkit start - CraftingManager.getInstance().lastCraftView = getBukkitView(); - ItemStack craftResult = CraftingManager.getInstance().craft(this.craftInventory, this.g); - this.resultInventory.setItem(0, craftResult); - if (super.listeners.size() < 1) { - return; - } - - EntityPlayer player = (EntityPlayer) super.listeners.get(0); // TODO: Is this _always_ correct? Seems like it. - player.playerConnection.sendPacket(new PacketPlayOutSetSlot(player.activeContainer.windowId, 0, craftResult)); - // CraftBukkit end - } - - public void b(EntityHuman entityhuman) { - super.b(entityhuman); - if (!this.g.isStatic) { - for (int i = 0; i < 9; ++i) { - ItemStack itemstack = this.craftInventory.splitWithoutUpdate(i); - - if (itemstack != null) { - entityhuman.drop(itemstack, false); - } - } - } - } - - public boolean a(EntityHuman entityhuman) { - if (!this.checkReachable) return true; // CraftBukkit - return this.g.getType(this.h, this.i, this.j) != Blocks.WORKBENCH ? false : entityhuman.e((double) this.h + 0.5D, (double) this.i + 0.5D, (double) this.j + 0.5D) <= 64.0D; - } - - public ItemStack b(EntityHuman entityhuman, int i) { - ItemStack itemstack = null; - Slot slot = (Slot) this.c.get(i); - - if (slot != null && slot.hasItem()) { - ItemStack itemstack1 = slot.getItem(); - - itemstack = itemstack1.cloneItemStack(); - if (i == 0) { - if (!this.a(itemstack1, 10, 46, true)) { - return null; - } - - slot.a(itemstack1, itemstack); - } else if (i >= 10 && i < 37) { - if (!this.a(itemstack1, 37, 46, false)) { - return null; - } - } else if (i >= 37 && i < 46) { - if (!this.a(itemstack1, 10, 37, false)) { - return null; - } - } else if (!this.a(itemstack1, 10, 46, false)) { - return null; - } - - if (itemstack1.count == 0) { - slot.set((ItemStack) null); - } else { - slot.f(); - } - - if (itemstack1.count == itemstack.count) { - return null; - } - - slot.a(entityhuman, itemstack1); - } - - return itemstack; - } - - public boolean a(ItemStack itemstack, Slot slot) { - return slot.inventory != this.resultInventory && super.a(itemstack, slot); - } - - // CraftBukkit start - public CraftInventoryView getBukkitView() { - if (bukkitEntity != null) { - return bukkitEntity; - } - - CraftInventoryCrafting inventory = new CraftInventoryCrafting(this.craftInventory, this.resultInventory); - bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), inventory, this); - return bukkitEntity; - } - // CraftBukkit end -} diff --git a/src/main/java/net/minecraft/server/ControllerLook.java b/src/main/java/net/minecraft/server/ControllerLook.java deleted file mode 100644 index f1e8b3dc..00000000 --- a/src/main/java/net/minecraft/server/ControllerLook.java +++ /dev/null @@ -1,87 +0,0 @@ -package net.minecraft.server; - -import org.bukkit.craftbukkit.TrigMath; // CraftBukkit - -public class ControllerLook { - - private EntityInsentient a; - private float b; - private float c; - private boolean d; - private double e; - private double f; - private double g; - - public ControllerLook(EntityInsentient entityinsentient) { - this.a = entityinsentient; - } - - public void a(Entity entity, float f, float f1) { - this.e = entity.locX; - if (entity instanceof EntityLiving) { - this.f = entity.locY + (double) entity.getHeadHeight(); - } else { - this.f = (entity.boundingBox.b + entity.boundingBox.e) / 2.0D; - } - - this.g = entity.locZ; - this.b = f; - this.c = f1; - this.d = true; - } - - public void a(double d0, double d1, double d2, float f, float f1) { - this.e = d0; - this.f = d1; - this.g = d2; - this.b = f; - this.c = f1; - this.d = true; - } - - public void a() { - this.a.pitch = 0.0F; - if (this.d) { - this.d = false; - double d0 = this.e - this.a.locX; - double d1 = this.f - (this.a.locY + (double) this.a.getHeadHeight()); - double d2 = this.g - this.a.locZ; - double d3 = (double) MathHelper.sqrt(d0 * d0 + d2 * d2); - // CraftBukkit start - Math -> TrigMath - float f = (float) (TrigMath.atan2(d2, d0) * 180.0D / 3.1415927410125732D) - 90.0F; - float f1 = (float) (-(TrigMath.atan2(d1, d3) * 180.0D / 3.1415927410125732D)); - // CraftBukkit end - - this.a.pitch = this.a(this.a.pitch, f1, this.c); - this.a.aO = this.a(this.a.aO, f, this.b); - } else { - this.a.aO = this.a(this.a.aO, this.a.aM, 10.0F); - } - - float f2 = MathHelper.g(this.a.aO - this.a.aM); - - if (!this.a.getNavigation().g()) { - if (f2 < -75.0F) { - this.a.aO = this.a.aM - 75.0F; - } - - if (f2 > 75.0F) { - this.a.aO = this.a.aM + 75.0F; - } - } - } - - private float a(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; - } -} diff --git a/src/main/java/net/minecraft/server/ControllerMove.java b/src/main/java/net/minecraft/server/ControllerMove.java deleted file mode 100644 index 525a4d17..00000000 --- a/src/main/java/net/minecraft/server/ControllerMove.java +++ /dev/null @@ -1,71 +0,0 @@ -package net.minecraft.server; - -public class ControllerMove { - - private EntityInsentient a; - private double b; - private double c; - private double d; - private double e; - private boolean f; - - public ControllerMove(EntityInsentient entityinsentient) { - this.a = entityinsentient; - this.b = entityinsentient.locX; - this.c = entityinsentient.locY; - this.d = entityinsentient.locZ; - } - - public boolean a() { - return this.f; - } - - public double b() { - return this.e; - } - - public void a(double d0, double d1, double d2, double d3) { - this.b = d0; - this.c = d1; - this.d = d2; - this.e = d3; - this.f = true; - } - - public void c() { - this.a.n(0.0F); - if (this.f) { - this.f = false; - int i = MathHelper.floor(this.a.boundingBox.b + 0.5D); - double d0 = this.b - this.a.locX; - double d1 = this.d - this.a.locZ; - double d2 = this.c - (double) i; - double d3 = d0 * d0 + d2 * d2 + d1 * d1; - - if (d3 >= 2.500000277905201E-7D) { - // CraftBukkit - Math -> TrigMath - 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.i((float) (this.e * this.a.getAttributeInstance(GenericAttributes.d).getValue())); - if (d2 > 0.0D && d0 * d0 + d1 * d1 < 1.0D) { - this.a.getControllerJump().a(); - } - } - } - } - - private float a(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; - } -} diff --git a/src/main/java/net/minecraft/server/CraftingManager.java b/src/main/java/net/minecraft/server/CraftingManager.java deleted file mode 100644 index 9675edb2..00000000 --- a/src/main/java/net/minecraft/server/CraftingManager.java +++ /dev/null @@ -1,313 +0,0 @@ -package net.minecraft.server; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; - -import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit - -public class CraftingManager { - - private static final CraftingManager a = new CraftingManager(); - // CraftBukkit start - public List recipes = new ArrayList(); // private -> public - public IRecipe lastRecipe; - public org.bukkit.inventory.InventoryView lastCraftView; - // CraftBukkit end - - public static final CraftingManager getInstance() { - return a; - } - - // CraftBukkit - private -> public - public CraftingManager() { - (new RecipesTools()).a(this); - (new RecipesWeapons()).a(this); - (new RecipeIngots()).a(this); - (new RecipesFood()).a(this); - (new RecipesCrafting()).a(this); - (new RecipesArmor()).a(this); - (new RecipesDyes()).a(this); - this.recipes.add(new RecipeArmorDye()); - this.recipes.add(new RecipeBookClone()); - this.recipes.add(new RecipeMapClone()); - this.recipes.add(new RecipeMapExtend()); - this.recipes.add(new RecipeFireworks()); - this.registerShapedRecipe(new ItemStack(Items.PAPER, 3), new Object[] { "###", Character.valueOf('#'), Items.SUGAR_CANE}); - this.registerShapelessRecipe(new ItemStack(Items.BOOK, 1), new Object[] { Items.PAPER, Items.PAPER, Items.PAPER, Items.LEATHER}); - this.registerShapelessRecipe(new ItemStack(Items.BOOK_AND_QUILL, 1), new Object[] { Items.BOOK, new ItemStack(Items.INK_SACK, 1, 0), Items.FEATHER}); - this.registerShapedRecipe(new ItemStack(Blocks.FENCE, 2), new Object[] { "###", "###", Character.valueOf('#'), Items.STICK}); - this.registerShapedRecipe(new ItemStack(Blocks.COBBLE_WALL, 6, 0), new Object[] { "###", "###", Character.valueOf('#'), Blocks.COBBLESTONE}); - this.registerShapedRecipe(new ItemStack(Blocks.COBBLE_WALL, 6, 1), new Object[] { "###", "###", Character.valueOf('#'), Blocks.MOSSY_COBBLESTONE}); - this.registerShapedRecipe(new ItemStack(Blocks.NETHER_FENCE, 6), new Object[] { "###", "###", Character.valueOf('#'), Blocks.NETHER_BRICK}); - this.registerShapedRecipe(new ItemStack(Blocks.FENCE_GATE, 1), new Object[] { "#W#", "#W#", Character.valueOf('#'), Items.STICK, Character.valueOf('W'), Blocks.WOOD}); - this.registerShapedRecipe(new ItemStack(Blocks.JUKEBOX, 1), new Object[] { "###", "#X#", "###", Character.valueOf('#'), Blocks.WOOD, Character.valueOf('X'), Items.DIAMOND}); - this.registerShapedRecipe(new ItemStack(Items.LEASH, 2), new Object[] { "~~ ", "~O ", " ~", Character.valueOf('~'), Items.STRING, Character.valueOf('O'), Items.SLIME_BALL}); - this.registerShapedRecipe(new ItemStack(Blocks.NOTE_BLOCK, 1), new Object[] { "###", "#X#", "###", Character.valueOf('#'), Blocks.WOOD, Character.valueOf('X'), Items.REDSTONE}); - this.registerShapedRecipe(new ItemStack(Blocks.BOOKSHELF, 1), new Object[] { "###", "XXX", "###", Character.valueOf('#'), Blocks.WOOD, Character.valueOf('X'), Items.BOOK}); - this.registerShapedRecipe(new ItemStack(Blocks.SNOW_BLOCK, 1), new Object[] { "##", "##", Character.valueOf('#'), Items.SNOW_BALL}); - this.registerShapedRecipe(new ItemStack(Blocks.SNOW, 6), new Object[] { "###", Character.valueOf('#'), Blocks.SNOW_BLOCK}); - this.registerShapedRecipe(new ItemStack(Blocks.CLAY, 1), new Object[] { "##", "##", Character.valueOf('#'), Items.CLAY_BALL}); - this.registerShapedRecipe(new ItemStack(Blocks.BRICK, 1), new Object[] { "##", "##", Character.valueOf('#'), Items.CLAY_BRICK}); - this.registerShapedRecipe(new ItemStack(Blocks.GLOWSTONE, 1), new Object[] { "##", "##", Character.valueOf('#'), Items.GLOWSTONE_DUST}); - this.registerShapedRecipe(new ItemStack(Blocks.QUARTZ_BLOCK, 1), new Object[] { "##", "##", Character.valueOf('#'), Items.QUARTZ}); - this.registerShapedRecipe(new ItemStack(Blocks.WOOL, 1), new Object[] { "##", "##", Character.valueOf('#'), Items.STRING}); - this.registerShapedRecipe(new ItemStack(Blocks.TNT, 1), new Object[] { "X#X", "#X#", "X#X", Character.valueOf('X'), Items.SULPHUR, Character.valueOf('#'), Blocks.SAND}); - this.registerShapedRecipe(new ItemStack(Blocks.STEP, 6, 3), new Object[] { "###", Character.valueOf('#'), Blocks.COBBLESTONE}); - this.registerShapedRecipe(new ItemStack(Blocks.STEP, 6, 0), new Object[] { "###", Character.valueOf('#'), Blocks.STONE}); - this.registerShapedRecipe(new ItemStack(Blocks.STEP, 6, 1), new Object[] { "###", Character.valueOf('#'), Blocks.SANDSTONE}); - this.registerShapedRecipe(new ItemStack(Blocks.STEP, 6, 4), new Object[] { "###", Character.valueOf('#'), Blocks.BRICK}); - this.registerShapedRecipe(new ItemStack(Blocks.STEP, 6, 5), new Object[] { "###", Character.valueOf('#'), Blocks.SMOOTH_BRICK}); - this.registerShapedRecipe(new ItemStack(Blocks.STEP, 6, 6), new Object[] { "###", Character.valueOf('#'), Blocks.NETHER_BRICK}); - this.registerShapedRecipe(new ItemStack(Blocks.STEP, 6, 7), new Object[] { "###", Character.valueOf('#'), Blocks.QUARTZ_BLOCK}); - this.registerShapedRecipe(new ItemStack(Blocks.WOOD_STEP, 6, 0), new Object[] { "###", Character.valueOf('#'), new ItemStack(Blocks.WOOD, 1, 0)}); - this.registerShapedRecipe(new ItemStack(Blocks.WOOD_STEP, 6, 2), new Object[] { "###", Character.valueOf('#'), new ItemStack(Blocks.WOOD, 1, 2)}); - this.registerShapedRecipe(new ItemStack(Blocks.WOOD_STEP, 6, 1), new Object[] { "###", Character.valueOf('#'), new ItemStack(Blocks.WOOD, 1, 1)}); - this.registerShapedRecipe(new ItemStack(Blocks.WOOD_STEP, 6, 3), new Object[] { "###", Character.valueOf('#'), new ItemStack(Blocks.WOOD, 1, 3)}); - this.registerShapedRecipe(new ItemStack(Blocks.WOOD_STEP, 6, 4), new Object[] { "###", Character.valueOf('#'), new ItemStack(Blocks.WOOD, 1, 4)}); - this.registerShapedRecipe(new ItemStack(Blocks.WOOD_STEP, 6, 5), new Object[] { "###", Character.valueOf('#'), new ItemStack(Blocks.WOOD, 1, 5)}); - this.registerShapedRecipe(new ItemStack(Blocks.LADDER, 3), new Object[] { "# #", "###", "# #", Character.valueOf('#'), Items.STICK}); - this.registerShapedRecipe(new ItemStack(Items.WOOD_DOOR, 1), new Object[] { "##", "##", "##", Character.valueOf('#'), Blocks.WOOD}); - this.registerShapedRecipe(new ItemStack(Blocks.TRAP_DOOR, 2), new Object[] { "###", "###", Character.valueOf('#'), Blocks.WOOD}); - this.registerShapedRecipe(new ItemStack(Items.IRON_DOOR, 1), new Object[] { "##", "##", "##", Character.valueOf('#'), Items.IRON_INGOT}); - this.registerShapedRecipe(new ItemStack(Items.SIGN, 3), new Object[] { "###", "###", " X ", Character.valueOf('#'), Blocks.WOOD, Character.valueOf('X'), Items.STICK}); - this.registerShapedRecipe(new ItemStack(Items.CAKE, 1), new Object[] { "AAA", "BEB", "CCC", Character.valueOf('A'), Items.MILK_BUCKET, Character.valueOf('B'), Items.SUGAR, Character.valueOf('C'), Items.WHEAT, Character.valueOf('E'), Items.EGG}); - this.registerShapedRecipe(new ItemStack(Items.SUGAR, 1), new Object[] { "#", Character.valueOf('#'), Items.SUGAR_CANE}); - this.registerShapedRecipe(new ItemStack(Blocks.WOOD, 4, 0), new Object[] { "#", Character.valueOf('#'), new ItemStack(Blocks.LOG, 1, 0)}); - this.registerShapedRecipe(new ItemStack(Blocks.WOOD, 4, 1), new Object[] { "#", Character.valueOf('#'), new ItemStack(Blocks.LOG, 1, 1)}); - this.registerShapedRecipe(new ItemStack(Blocks.WOOD, 4, 2), new Object[] { "#", Character.valueOf('#'), new ItemStack(Blocks.LOG, 1, 2)}); - this.registerShapedRecipe(new ItemStack(Blocks.WOOD, 4, 3), new Object[] { "#", Character.valueOf('#'), new ItemStack(Blocks.LOG, 1, 3)}); - this.registerShapedRecipe(new ItemStack(Blocks.WOOD, 4, 4), new Object[] { "#", Character.valueOf('#'), new ItemStack(Blocks.LOG2, 1, 0)}); - this.registerShapedRecipe(new ItemStack(Blocks.WOOD, 4, 5), new Object[] { "#", Character.valueOf('#'), new ItemStack(Blocks.LOG2, 1, 1)}); - this.registerShapedRecipe(new ItemStack(Items.STICK, 4), new Object[] { "#", "#", Character.valueOf('#'), Blocks.WOOD}); - this.registerShapedRecipe(new ItemStack(Blocks.TORCH, 4), new Object[] { "X", "#", Character.valueOf('X'), Items.COAL, Character.valueOf('#'), Items.STICK}); - this.registerShapedRecipe(new ItemStack(Blocks.TORCH, 4), new Object[] { "X", "#", Character.valueOf('X'), new ItemStack(Items.COAL, 1, 1), Character.valueOf('#'), Items.STICK}); - this.registerShapedRecipe(new ItemStack(Items.BOWL, 4), new Object[] { "# #", " # ", Character.valueOf('#'), Blocks.WOOD}); - this.registerShapedRecipe(new ItemStack(Items.GLASS_BOTTLE, 3), new Object[] { "# #", " # ", Character.valueOf('#'), Blocks.GLASS}); - this.registerShapedRecipe(new ItemStack(Blocks.RAILS, 16), new Object[] { "X X", "X#X", "X X", Character.valueOf('X'), Items.IRON_INGOT, Character.valueOf('#'), Items.STICK}); - this.registerShapedRecipe(new ItemStack(Blocks.GOLDEN_RAIL, 6), new Object[] { "X X", "X#X", "XRX", Character.valueOf('X'), Items.GOLD_INGOT, Character.valueOf('R'), Items.REDSTONE, Character.valueOf('#'), Items.STICK}); - this.registerShapedRecipe(new ItemStack(Blocks.ACTIVATOR_RAIL, 6), new Object[] { "XSX", "X#X", "XSX", Character.valueOf('X'), Items.IRON_INGOT, Character.valueOf('#'), Blocks.REDSTONE_TORCH_ON, Character.valueOf('S'), Items.STICK}); - this.registerShapedRecipe(new ItemStack(Blocks.DETECTOR_RAIL, 6), new Object[] { "X X", "X#X", "XRX", Character.valueOf('X'), Items.IRON_INGOT, Character.valueOf('R'), Items.REDSTONE, Character.valueOf('#'), Blocks.STONE_PLATE}); - this.registerShapedRecipe(new ItemStack(Items.MINECART, 1), new Object[] { "# #", "###", Character.valueOf('#'), Items.IRON_INGOT}); - this.registerShapedRecipe(new ItemStack(Items.CAULDRON, 1), new Object[] { "# #", "# #", "###", Character.valueOf('#'), Items.IRON_INGOT}); - this.registerShapedRecipe(new ItemStack(Items.BREWING_STAND, 1), new Object[] { " B ", "###", Character.valueOf('#'), Blocks.COBBLESTONE, Character.valueOf('B'), Items.BLAZE_ROD}); - this.registerShapedRecipe(new ItemStack(Blocks.JACK_O_LANTERN, 1), new Object[] { "A", "B", Character.valueOf('A'), Blocks.PUMPKIN, Character.valueOf('B'), Blocks.TORCH}); - this.registerShapedRecipe(new ItemStack(Items.STORAGE_MINECART, 1), new Object[] { "A", "B", Character.valueOf('A'), Blocks.CHEST, Character.valueOf('B'), Items.MINECART}); - this.registerShapedRecipe(new ItemStack(Items.POWERED_MINECART, 1), new Object[] { "A", "B", Character.valueOf('A'), Blocks.FURNACE, Character.valueOf('B'), Items.MINECART}); - this.registerShapedRecipe(new ItemStack(Items.MINECART_TNT, 1), new Object[] { "A", "B", Character.valueOf('A'), Blocks.TNT, Character.valueOf('B'), Items.MINECART}); - this.registerShapedRecipe(new ItemStack(Items.MINECART_HOPPER, 1), new Object[] { "A", "B", Character.valueOf('A'), Blocks.HOPPER, Character.valueOf('B'), Items.MINECART}); - this.registerShapedRecipe(new ItemStack(Items.BOAT, 1), new Object[] { "# #", "###", Character.valueOf('#'), Blocks.WOOD}); - this.registerShapedRecipe(new ItemStack(Items.BUCKET, 1), new Object[] { "# #", " # ", Character.valueOf('#'), Items.IRON_INGOT}); - this.registerShapedRecipe(new ItemStack(Items.FLOWER_POT, 1), new Object[] { "# #", " # ", Character.valueOf('#'), Items.CLAY_BRICK}); - this.registerShapelessRecipe(new ItemStack(Items.FLINT_AND_STEEL, 1), new Object[] { new ItemStack(Items.IRON_INGOT, 1), new ItemStack(Items.FLINT, 1)}); - this.registerShapedRecipe(new ItemStack(Items.BREAD, 1), new Object[] { "###", Character.valueOf('#'), Items.WHEAT}); - this.registerShapedRecipe(new ItemStack(Blocks.WOOD_STAIRS, 4), new Object[] { "# ", "## ", "###", Character.valueOf('#'), new ItemStack(Blocks.WOOD, 1, 0)}); - this.registerShapedRecipe(new ItemStack(Blocks.BIRCH_WOOD_STAIRS, 4), new Object[] { "# ", "## ", "###", Character.valueOf('#'), new ItemStack(Blocks.WOOD, 1, 2)}); - this.registerShapedRecipe(new ItemStack(Blocks.SPRUCE_WOOD_STAIRS, 4), new Object[] { "# ", "## ", "###", Character.valueOf('#'), new ItemStack(Blocks.WOOD, 1, 1)}); - this.registerShapedRecipe(new ItemStack(Blocks.JUNGLE_WOOD_STAIRS, 4), new Object[] { "# ", "## ", "###", Character.valueOf('#'), new ItemStack(Blocks.WOOD, 1, 3)}); - this.registerShapedRecipe(new ItemStack(Blocks.ACACIA_STAIRS, 4), new Object[] { "# ", "## ", "###", Character.valueOf('#'), new ItemStack(Blocks.WOOD, 1, 4)}); - this.registerShapedRecipe(new ItemStack(Blocks.DARK_OAK_STAIRS, 4), new Object[] { "# ", "## ", "###", Character.valueOf('#'), new ItemStack(Blocks.WOOD, 1, 5)}); - this.registerShapedRecipe(new ItemStack(Items.FISHING_ROD, 1), new Object[] { " #", " #X", "# X", Character.valueOf('#'), Items.STICK, Character.valueOf('X'), Items.STRING}); - this.registerShapedRecipe(new ItemStack(Items.CARROT_STICK, 1), new Object[] { "# ", " X", Character.valueOf('#'), Items.FISHING_ROD, Character.valueOf('X'), Items.CARROT}).c(); - this.registerShapedRecipe(new ItemStack(Blocks.COBBLESTONE_STAIRS, 4), new Object[] { "# ", "## ", "###", Character.valueOf('#'), Blocks.COBBLESTONE}); - this.registerShapedRecipe(new ItemStack(Blocks.BRICK_STAIRS, 4), new Object[] { "# ", "## ", "###", Character.valueOf('#'), Blocks.BRICK}); - this.registerShapedRecipe(new ItemStack(Blocks.STONE_STAIRS, 4), new Object[] { "# ", "## ", "###", Character.valueOf('#'), Blocks.SMOOTH_BRICK}); - this.registerShapedRecipe(new ItemStack(Blocks.NETHER_BRICK_STAIRS, 4), new Object[] { "# ", "## ", "###", Character.valueOf('#'), Blocks.NETHER_BRICK}); - this.registerShapedRecipe(new ItemStack(Blocks.SANDSTONE_STAIRS, 4), new Object[] { "# ", "## ", "###", Character.valueOf('#'), Blocks.SANDSTONE}); - this.registerShapedRecipe(new ItemStack(Blocks.QUARTZ_STAIRS, 4), new Object[] { "# ", "## ", "###", Character.valueOf('#'), Blocks.QUARTZ_BLOCK}); - this.registerShapedRecipe(new ItemStack(Items.PAINTING, 1), new Object[] { "###", "#X#", "###", Character.valueOf('#'), Items.STICK, Character.valueOf('X'), Blocks.WOOL}); - this.registerShapedRecipe(new ItemStack(Items.ITEM_FRAME, 1), new Object[] { "###", "#X#", "###", Character.valueOf('#'), Items.STICK, Character.valueOf('X'), Items.LEATHER}); - this.registerShapedRecipe(new ItemStack(Items.GOLDEN_APPLE, 1, 0), new Object[] { "###", "#X#", "###", Character.valueOf('#'), Items.GOLD_INGOT, Character.valueOf('X'), Items.APPLE}); - this.registerShapedRecipe(new ItemStack(Items.GOLDEN_APPLE, 1, 1), new Object[] { "###", "#X#", "###", Character.valueOf('#'), Blocks.GOLD_BLOCK, Character.valueOf('X'), Items.APPLE}); - this.registerShapedRecipe(new ItemStack(Items.CARROT_GOLDEN, 1, 0), new Object[] { "###", "#X#", "###", Character.valueOf('#'), Items.GOLD_NUGGET, Character.valueOf('X'), Items.CARROT}); - this.registerShapedRecipe(new ItemStack(Items.SPECKLED_MELON, 1), new Object[] { "###", "#X#", "###", Character.valueOf('#'), Items.GOLD_NUGGET, Character.valueOf('X'), Items.MELON}); - this.registerShapedRecipe(new ItemStack(Blocks.LEVER, 1), new Object[] { "X", "#", Character.valueOf('#'), Blocks.COBBLESTONE, Character.valueOf('X'), Items.STICK}); - this.registerShapedRecipe(new ItemStack(Blocks.TRIPWIRE_SOURCE, 2), new Object[] { "I", "S", "#", Character.valueOf('#'), Blocks.WOOD, Character.valueOf('S'), Items.STICK, Character.valueOf('I'), Items.IRON_INGOT}); - this.registerShapedRecipe(new ItemStack(Blocks.REDSTONE_TORCH_ON, 1), new Object[] { "X", "#", Character.valueOf('#'), Items.STICK, Character.valueOf('X'), Items.REDSTONE}); - this.registerShapedRecipe(new ItemStack(Items.DIODE, 1), new Object[] { "#X#", "III", Character.valueOf('#'), Blocks.REDSTONE_TORCH_ON, Character.valueOf('X'), Items.REDSTONE, Character.valueOf('I'), Blocks.STONE}); - this.registerShapedRecipe(new ItemStack(Items.REDSTONE_COMPARATOR, 1), new Object[] { " # ", "#X#", "III", Character.valueOf('#'), Blocks.REDSTONE_TORCH_ON, Character.valueOf('X'), Items.QUARTZ, Character.valueOf('I'), Blocks.STONE}); - this.registerShapedRecipe(new ItemStack(Items.WATCH, 1), new Object[] { " # ", "#X#", " # ", Character.valueOf('#'), Items.GOLD_INGOT, Character.valueOf('X'), Items.REDSTONE}); - this.registerShapedRecipe(new ItemStack(Items.COMPASS, 1), new Object[] { " # ", "#X#", " # ", Character.valueOf('#'), Items.IRON_INGOT, Character.valueOf('X'), Items.REDSTONE}); - this.registerShapedRecipe(new ItemStack(Items.MAP_EMPTY, 1), new Object[] { "###", "#X#", "###", Character.valueOf('#'), Items.PAPER, Character.valueOf('X'), Items.COMPASS}); - this.registerShapedRecipe(new ItemStack(Blocks.STONE_BUTTON, 1), new Object[] { "#", Character.valueOf('#'), Blocks.STONE}); - this.registerShapedRecipe(new ItemStack(Blocks.WOOD_BUTTON, 1), new Object[] { "#", Character.valueOf('#'), Blocks.WOOD}); - this.registerShapedRecipe(new ItemStack(Blocks.STONE_PLATE, 1), new Object[] { "##", Character.valueOf('#'), Blocks.STONE}); - this.registerShapedRecipe(new ItemStack(Blocks.WOOD_PLATE, 1), new Object[] { "##", Character.valueOf('#'), Blocks.WOOD}); - this.registerShapedRecipe(new ItemStack(Blocks.IRON_PLATE, 1), new Object[] { "##", Character.valueOf('#'), Items.IRON_INGOT}); - this.registerShapedRecipe(new ItemStack(Blocks.GOLD_PLATE, 1), new Object[] { "##", Character.valueOf('#'), Items.GOLD_INGOT}); - this.registerShapedRecipe(new ItemStack(Blocks.DISPENSER, 1), new Object[] { "###", "#X#", "#R#", Character.valueOf('#'), Blocks.COBBLESTONE, Character.valueOf('X'), Items.BOW, Character.valueOf('R'), Items.REDSTONE}); - this.registerShapedRecipe(new ItemStack(Blocks.DROPPER, 1), new Object[] { "###", "# #", "#R#", Character.valueOf('#'), Blocks.COBBLESTONE, Character.valueOf('R'), Items.REDSTONE}); - this.registerShapedRecipe(new ItemStack(Blocks.PISTON, 1), new Object[] { "TTT", "#X#", "#R#", Character.valueOf('#'), Blocks.COBBLESTONE, Character.valueOf('X'), Items.IRON_INGOT, Character.valueOf('R'), Items.REDSTONE, Character.valueOf('T'), Blocks.WOOD}); - this.registerShapedRecipe(new ItemStack(Blocks.PISTON_STICKY, 1), new Object[] { "S", "P", Character.valueOf('S'), Items.SLIME_BALL, Character.valueOf('P'), Blocks.PISTON}); - this.registerShapedRecipe(new ItemStack(Items.BED, 1), new Object[] { "###", "XXX", Character.valueOf('#'), Blocks.WOOL, Character.valueOf('X'), Blocks.WOOD}); - this.registerShapedRecipe(new ItemStack(Blocks.ENCHANTMENT_TABLE, 1), new Object[] { " B ", "D#D", "###", Character.valueOf('#'), Blocks.OBSIDIAN, Character.valueOf('B'), Items.BOOK, Character.valueOf('D'), Items.DIAMOND}); - this.registerShapedRecipe(new ItemStack(Blocks.ANVIL, 1), new Object[] { "III", " i ", "iii", Character.valueOf('I'), Blocks.IRON_BLOCK, Character.valueOf('i'), Items.IRON_INGOT}); - this.registerShapelessRecipe(new ItemStack(Items.EYE_OF_ENDER, 1), new Object[] { Items.ENDER_PEARL, Items.BLAZE_POWDER}); - this.registerShapelessRecipe(new ItemStack(Items.FIREBALL, 3), new Object[] { Items.SULPHUR, Items.BLAZE_POWDER, Items.COAL}); - this.registerShapelessRecipe(new ItemStack(Items.FIREBALL, 3), new Object[] { Items.SULPHUR, Items.BLAZE_POWDER, new ItemStack(Items.COAL, 1, 1)}); - this.registerShapedRecipe(new ItemStack(Blocks.DAYLIGHT_DETECTOR), new Object[] { "GGG", "QQQ", "WWW", Character.valueOf('G'), Blocks.GLASS, Character.valueOf('Q'), Items.QUARTZ, Character.valueOf('W'), Blocks.WOOD_STEP}); - this.registerShapedRecipe(new ItemStack(Blocks.HOPPER), new Object[] { "I I", "ICI", " I ", Character.valueOf('I'), Items.IRON_INGOT, Character.valueOf('C'), Blocks.CHEST}); - // Collections.sort(this.recipes, new RecipeSorter(this)); // CraftBukkit - moved below - this.sort(); // CraftBukkit - call new sort method - } - - // CraftBukkit start - public void sort() { - Collections.sort(this.recipes, new RecipeSorter(this)); - } - // CraftBukkit end - - // CraftBukkit - default -> public - public ShapedRecipes registerShapedRecipe(ItemStack itemstack, Object... aobject) { - String s = ""; - int i = 0; - int j = 0; - int k = 0; - - if (aobject[i] instanceof String[]) { - String[] astring = (String[]) ((String[]) aobject[i++]); - - for (int l = 0; l < astring.length; ++l) { - String s1 = astring[l]; - - ++k; - j = s1.length(); - s = s + s1; - } - } else { - while (aobject[i] instanceof String) { - String s2 = (String) aobject[i++]; - - ++k; - j = s2.length(); - s = s + s2; - } - } - - HashMap hashmap; - - for (hashmap = new HashMap(); i < aobject.length; i += 2) { - Character character = (Character) aobject[i]; - ItemStack itemstack1 = null; - - if (aobject[i + 1] instanceof Item) { - itemstack1 = new ItemStack((Item) aobject[i + 1]); - } else if (aobject[i + 1] instanceof Block) { - itemstack1 = new ItemStack((Block) aobject[i + 1], 1, 32767); - } else if (aobject[i + 1] instanceof ItemStack) { - itemstack1 = (ItemStack) aobject[i + 1]; - } - - hashmap.put(character, itemstack1); - } - - ItemStack[] aitemstack = new ItemStack[j * k]; - - for (int i1 = 0; i1 < j * k; ++i1) { - char c0 = s.charAt(i1); - - if (hashmap.containsKey(Character.valueOf(c0))) { - aitemstack[i1] = ((ItemStack) hashmap.get(Character.valueOf(c0))).cloneItemStack(); - } else { - aitemstack[i1] = null; - } - } - - ShapedRecipes shapedrecipes = new ShapedRecipes(j, k, aitemstack, itemstack); - - this.recipes.add(shapedrecipes); - return shapedrecipes; - } - - // CraftBukkit - default -> public - public void registerShapelessRecipe(ItemStack itemstack, Object... aobject) { - ArrayList arraylist = new ArrayList(); - Object[] aobject1 = aobject; - int i = aobject.length; - - for (int j = 0; j < i; ++j) { - Object object = aobject1[j]; - - if (object instanceof ItemStack) { - arraylist.add(((ItemStack) object).cloneItemStack()); - } else if (object instanceof Item) { - arraylist.add(new ItemStack((Item) object)); - } else { - if (!(object instanceof Block)) { - throw new RuntimeException("Invalid shapeless recipy!"); - } - - arraylist.add(new ItemStack((Block) object)); - } - } - - this.recipes.add(new ShapelessRecipes(itemstack, arraylist)); - } - - public ItemStack craft(InventoryCrafting inventorycrafting, World world) { - int i = 0; - ItemStack itemstack = null; - ItemStack itemstack1 = null; - - int j; - - for (j = 0; j < inventorycrafting.getSize(); ++j) { - ItemStack itemstack2 = inventorycrafting.getItem(j); - - if (itemstack2 != null) { - if (i == 0) { - itemstack = itemstack2; - } - - if (i == 1) { - itemstack1 = itemstack2; - } - - ++i; - } - } - - if (i == 2 && itemstack.getItem() == itemstack1.getItem() && itemstack.count == 1 && itemstack1.count == 1 && itemstack.getItem().usesDurability()) { - Item item = itemstack.getItem(); - int k = item.getMaxDurability() - itemstack.j(); - int l = item.getMaxDurability() - itemstack1.j(); - int i1 = k + l + item.getMaxDurability() * 5 / 100; - int j1 = item.getMaxDurability() - i1; - - if (j1 < 0) { - j1 = 0; - } - - // CraftBukkit start - Construct a dummy repair recipe - ItemStack result = new ItemStack(itemstack.getItem(), 1, j1); - List<ItemStack> ingredients = new ArrayList<ItemStack>(); - ingredients.add(itemstack.cloneItemStack()); - ingredients.add(itemstack1.cloneItemStack()); - ShapelessRecipes recipe = new ShapelessRecipes(result.cloneItemStack(), ingredients); - inventorycrafting.currentRecipe = recipe; - result = CraftEventFactory.callPreCraftEvent(inventorycrafting, result, lastCraftView, true); - return result; - // CraftBukkit end - } else { - for (j = 0; j < this.recipes.size(); ++j) { - IRecipe irecipe = (IRecipe) this.recipes.get(j); - - if (irecipe.a(inventorycrafting, world)) { - // CraftBukkit start - INVENTORY_PRE_CRAFT event - inventorycrafting.currentRecipe = irecipe; - ItemStack result = irecipe.a(inventorycrafting); - return CraftEventFactory.callPreCraftEvent(inventorycrafting, result, lastCraftView, false); - // CraftBukkit end - } - } - - inventorycrafting.currentRecipe = null; // CraftBukkit - Clear recipe when no recipe is found - return null; - } - } - - public List getRecipes() { - return this.recipes; - } -} diff --git a/src/main/java/net/minecraft/server/CrashReport.java b/src/main/java/net/minecraft/server/CrashReport.java deleted file mode 100644 index 7e060027..00000000 --- a/src/main/java/net/minecraft/server/CrashReport.java +++ /dev/null @@ -1,235 +0,0 @@ -package net.minecraft.server; - -import java.io.File; -import java.io.FileWriter; -import java.io.PrintWriter; -import java.io.StringWriter; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.Iterator; -import java.util.List; -import java.util.concurrent.Callable; - -import net.minecraft.util.org.apache.commons.io.IOUtils; -import net.minecraft.util.org.apache.commons.lang3.ArrayUtils; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -public class CrashReport { - - private static final Logger a = LogManager.getLogger(); - private final String b; - private final Throwable c; - private final CrashReportSystemDetails d = new CrashReportSystemDetails(this, "System Details"); - private final List e = new ArrayList(); - private File f; - private boolean g = true; - private StackTraceElement[] h = new StackTraceElement[0]; - - public CrashReport(String s, Throwable throwable) { - this.b = s; - this.c = throwable; - this.h(); - } - - private void h() { - this.d.a("Minecraft Version", (Callable) (new CrashReportVersion(this))); - this.d.a("Operating System", (Callable) (new CrashReportOperatingSystem(this))); - this.d.a("Java Version", (Callable) (new CrashReportJavaVersion(this))); - this.d.a("Java VM Version", (Callable) (new CrashReportJavaVMVersion(this))); - this.d.a("Memory", (Callable) (new CrashReportMemory(this))); - this.d.a("JVM Flags", (Callable) (new CrashReportJVMFlags(this))); - this.d.a("AABB Pool Size", (Callable) (new CrashReportAABBPoolSize(this))); - this.d.a("IntCache", (Callable) (new CrashReportIntCacheSize(this))); - this.d.a("CraftBukkit Information", (Callable) (new org.bukkit.craftbukkit.CraftCrashReport())); // CraftBukkit - } - - public String a() { - return this.b; - } - - public Throwable b() { - return this.c; - } - - public void a(StringBuilder stringbuilder) { - if ((this.h == null || this.h.length <= 0) && this.e.size() > 0) { - this.h = (StackTraceElement[]) ArrayUtils.subarray(((CrashReportSystemDetails) this.e.get(0)).a(), 0, 1); - } - - if (this.h != null && this.h.length > 0) { - stringbuilder.append("-- Head --\n"); - stringbuilder.append("Stacktrace:\n"); - StackTraceElement[] astacktraceelement = this.h; - int i = astacktraceelement.length; - - for (int j = 0; j < i; ++j) { - StackTraceElement stacktraceelement = astacktraceelement[j]; - - stringbuilder.append("\t").append("at ").append(stacktraceelement.toString()); - stringbuilder.append("\n"); - } - - stringbuilder.append("\n"); - } - - Iterator iterator = this.e.iterator(); - - while (iterator.hasNext()) { - CrashReportSystemDetails crashreportsystemdetails = (CrashReportSystemDetails) iterator.next(); - - crashreportsystemdetails.a(stringbuilder); - stringbuilder.append("\n\n"); - } - - this.d.a(stringbuilder); - } - - public String d() { - StringWriter stringwriter = null; - PrintWriter printwriter = null; - Object object = this.c; - - if (((Throwable) object).getMessage() == null) { - if (object instanceof NullPointerException) { - object = new NullPointerException(this.b); - } else if (object instanceof StackOverflowError) { - object = new StackOverflowError(this.b); - } else if (object instanceof OutOfMemoryError) { - object = new OutOfMemoryError(this.b); - } - - ((Throwable) object).setStackTrace(this.c.getStackTrace()); - } - - String s = ((Throwable) object).toString(); - - try { - stringwriter = new StringWriter(); - printwriter = new PrintWriter(stringwriter); - ((Throwable) object).printStackTrace(printwriter); - s = stringwriter.toString(); - } finally { - IOUtils.closeQuietly(stringwriter); - IOUtils.closeQuietly(printwriter); - } - - return s; - } - - public String e() { - StringBuilder stringbuilder = new StringBuilder(); - - stringbuilder.append("---- Minecraft Crash Report ----\n"); - stringbuilder.append("// "); - stringbuilder.append(i()); - stringbuilder.append("\n\n"); - stringbuilder.append("Time: "); - stringbuilder.append((new SimpleDateFormat()).format(new Date())); - stringbuilder.append("\n"); - stringbuilder.append("Description: "); - stringbuilder.append(this.b); - stringbuilder.append("\n\n"); - stringbuilder.append(this.d()); - stringbuilder.append("\n\nA detailed walkthrough of the error, its code path and all known details is as follows:\n"); - - for (int i = 0; i < 87; ++i) { - stringbuilder.append("-"); - } - - stringbuilder.append("\n\n"); - this.a(stringbuilder); - return stringbuilder.toString(); - } - - public boolean a(File file1) { - if (this.f != null) { - return false; - } else { - if (file1.getParentFile() != null) { - file1.getParentFile().mkdirs(); - } - - try { - FileWriter filewriter = new FileWriter(file1); - - filewriter.write(this.e()); - filewriter.close(); - this.f = file1; - return true; - } catch (Throwable throwable) { - a.error("Could not save crash report to " + file1, throwable); - return false; - } - } - } - - public CrashReportSystemDetails g() { - return this.d; - } - - public CrashReportSystemDetails a(String s) { - return this.a(s, 1); - } - - public CrashReportSystemDetails a(String s, int i) { - CrashReportSystemDetails crashreportsystemdetails = new CrashReportSystemDetails(this, s); - - if (this.g) { - int j = crashreportsystemdetails.a(i); - StackTraceElement[] astacktraceelement = this.c.getStackTrace(); - StackTraceElement stacktraceelement = null; - StackTraceElement stacktraceelement1 = null; - int k = astacktraceelement.length - j; - - if (k < 0) { - System.out.println("Negative index in crash report handler (" + astacktraceelement.length + "/" + j + ")"); - } - - if (astacktraceelement != null && 0 <= k && k < astacktraceelement.length) { - stacktraceelement = astacktraceelement[k]; - if (astacktraceelement.length + 1 - j < astacktraceelement.length) { - stacktraceelement1 = astacktraceelement[astacktraceelement.length + 1 - j]; - } - } - - this.g = crashreportsystemdetails.a(stacktraceelement, stacktraceelement1); - if (j > 0 && !this.e.isEmpty()) { - CrashReportSystemDetails crashreportsystemdetails1 = (CrashReportSystemDetails) this.e.get(this.e.size() - 1); - - crashreportsystemdetails1.b(j); - } else if (astacktraceelement != null && astacktraceelement.length >= j && 0 <= k && k < astacktraceelement.length) { - this.h = new StackTraceElement[astacktraceelement.length - j]; - System.arraycopy(astacktraceelement, 0, this.h, 0, this.h.length); - } else { - this.g = false; - } - } - - this.e.add(crashreportsystemdetails); - return crashreportsystemdetails; - } - - private static String i() { - String[] astring = new String[] { "Who set us up the TNT?", "Everything\'s going to plan. No, really, that was supposed to happen.", "Uh... Did I do that?", "Oops.", "Why did you do that?", "I feel sad now :(", "My bad.", "I\'m sorry, Dave.", "I let you down. Sorry :(", "On the bright side, I bought you a teddy bear!", "Daisy, daisy...", "Oh - I know what I did wrong!", "Hey, that tickles! Hehehe!", "I blame Dinnerbone.", "You should try our sister game, Minceraft!", "Don\'t be sad. I\'ll do better next time, I promise!", "Don\'t be sad, have a hug! <3", "I just don\'t know what went wrong :(", "Shall we play a game?", "Quite honestly, I wouldn\'t worry myself about that.", "I bet Cylons wouldn\'t have this problem.", "Sorry :(", "Surprise! Haha. Well, this is awkward.", "Would you like a cupcake?", "Hi. I\'m Minecraft, and I\'m a crashaholic.", "Ooh. Shiny.", "This doesn\'t make any sense!", "Why is it breaking :(", "Don\'t do that.", "Ouch. That hurt :(", "You\'re mean.", "This is a token for 1 free hug. Redeem at your nearest Mojangsta: [~~HUG~~]", "There are four lights!", "But it works on my machine."}; - - try { - return astring[(int) (System.nanoTime() % (long) astring.length)]; - } catch (Throwable throwable) { - return "Witty comment unavailable :("; - } - } - - public static CrashReport a(Throwable throwable, String s) { - CrashReport crashreport; - - if (throwable instanceof ReportedException) { - crashreport = ((ReportedException) throwable).a(); - } else { - crashreport = new CrashReport(s, throwable); - } - - return crashreport; - } -} diff --git a/src/main/java/net/minecraft/server/DedicatedServer.java b/src/main/java/net/minecraft/server/DedicatedServer.java deleted file mode 100644 index 83f2dad5..00000000 --- a/src/main/java/net/minecraft/server/DedicatedServer.java +++ /dev/null @@ -1,472 +0,0 @@ -package net.minecraft.server; - -import java.io.File; -import java.io.IOException; -import java.net.InetAddress; -import java.net.Proxy; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Random; -import java.util.concurrent.Callable; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -// CraftBukkit start -import java.io.PrintStream; -import org.apache.logging.log4j.Level; - -import org.bukkit.craftbukkit.LoggerOutputStream; -import org.bukkit.event.server.ServerCommandEvent; -// CraftBukkit end - -public class DedicatedServer extends MinecraftServer implements IMinecraftServer { - - private static final Logger i = LogManager.getLogger(); - private final List j = Collections.synchronizedList(new ArrayList()); - private RemoteStatusListener k; - private RemoteControlListener l; - public PropertyManager propertyManager; // CraftBukkit - private -> public - private EULA n; - private boolean generateStructures; - private EnumGamemode p; - private boolean q; - - // CraftBukkit start - Signature changed - public DedicatedServer(joptsimple.OptionSet options) { - super(options, Proxy.NO_PROXY); - // super(file1, Proxy.NO_PROXY); - // CraftBukkit end - new ThreadSleepForever(this, "Server Infinisleeper"); - } - - protected boolean init() throws java.net.UnknownHostException { // CraftBukkit - throws UnknownHostException - ThreadCommandReader threadcommandreader = new ThreadCommandReader(this, "Server console handler"); - - threadcommandreader.setDaemon(true); - threadcommandreader.start(); - - // CraftBukkit start - TODO: handle command-line logging arguments - java.util.logging.Logger global = java.util.logging.Logger.getLogger(""); - global.setUseParentHandlers(false); - for (java.util.logging.Handler handler : global.getHandlers()) { - global.removeHandler(handler); - } - global.addHandler(new org.bukkit.craftbukkit.util.ForwardLogHandler()); - - final org.apache.logging.log4j.core.Logger logger = ((org.apache.logging.log4j.core.Logger) LogManager.getRootLogger()); - for (org.apache.logging.log4j.core.Appender appender : logger.getAppenders().values()) { - if (appender instanceof org.apache.logging.log4j.core.appender.ConsoleAppender) { - logger.removeAppender(appender); - } - } - - new Thread(new org.bukkit.craftbukkit.util.TerminalConsoleWriterThread(System.out, this.reader)).start(); - - System.setOut(new PrintStream(new LoggerOutputStream(logger, Level.INFO), true)); - System.setErr(new PrintStream(new LoggerOutputStream(logger, Level.WARN), true)); - // CraftBukkit end - - i.info("Starting minecraft server version 1.7.10"); - if (Runtime.getRuntime().maxMemory() / 1024L / 1024L < 512L) { - i.warn("To start the server with more ram, launch it as \"java -Xmx1024M -Xms1024M -jar minecraft_server.jar\""); - } - - i.info("Loading properties"); - this.propertyManager = new PropertyManager(this.options); // CraftBukkit - CLI argument support - this.n = new EULA(new File("eula.txt")); - if (!this.n.a()) { - i.info("You need to agree to the EULA in order to run the server. Go to eula.txt for more info."); - this.n.b(); - return false; - } else { - if (this.N()) { - this.c("127.0.0.1"); - } else { - this.setOnlineMode(this.propertyManager.getBoolean("online-mode", true)); - this.c(this.propertyManager.getString("server-ip", "")); - } - - this.setSpawnAnimals(this.propertyManager.getBoolean("spawn-animals", true)); - this.setSpawnNPCs(this.propertyManager.getBoolean("spawn-npcs", true)); - this.setPvP(this.propertyManager.getBoolean("pvp", true)); - this.setAllowFlight(this.propertyManager.getBoolean("allow-flight", false)); - this.setTexturePack(this.propertyManager.getString("resource-pack", "")); - this.setMotd(this.propertyManager.getString("motd", "A Minecraft Server")); - this.setForceGamemode(this.propertyManager.getBoolean("force-gamemode", false)); - this.setIdleTimeout(this.propertyManager.getInt("player-idle-timeout", 0)); - if (this.propertyManager.getInt("difficulty", 1) < 0) { - this.propertyManager.setProperty("difficulty", Integer.valueOf(0)); - } else if (this.propertyManager.getInt("difficulty", 1) > 3) { - this.propertyManager.setProperty("difficulty", Integer.valueOf(3)); - } - - this.generateStructures = this.propertyManager.getBoolean("generate-structures", true); - int gamemode = this.propertyManager.getInt("gamemode", EnumGamemode.SURVIVAL.getId()); // CraftBukkit - Unique name to avoid stomping on logger - - this.p = WorldSettings.a(gamemode); // CraftBukkit - Use new name - i.info("Default game type: " + this.p); - InetAddress inetaddress = null; - - if (this.getServerIp().length() > 0) { - inetaddress = InetAddress.getByName(this.getServerIp()); - } - - if (this.L() < 0) { - this.setPort(this.propertyManager.getInt("server-port", 25565)); - } - - i.info("Generating keypair"); - this.a(MinecraftEncryption.b()); - i.info("Starting Minecraft server on " + (this.getServerIp().length() == 0 ? "*" : this.getServerIp()) + ":" + this.L()); - - try { - this.ai().a(inetaddress, this.L()); - } catch (Throwable ioexception) { // CraftBukkit - IOException -> Throwable - i.warn("**** FAILED TO BIND TO PORT!"); - i.warn("The exception was: {}", new Object[] { ioexception.toString()}); - i.warn("Perhaps a server is already running on that port?"); - return false; - } - - this.a((PlayerList) (new DedicatedPlayerList(this))); // CraftBukkit - - if (!this.getOnlineMode()) { - i.warn("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!"); - i.warn("The server will make no attempt to authenticate usernames. Beware."); - i.warn("While this makes the game possible to play without internet access, it also opens up the ability for hackers to connect with any username they choose."); - i.warn("To change this, set \"online-mode\" to \"true\" in the server.properties file."); - } - - if (this.aE()) { - this.getUserCache().c(); - } - - if (!NameReferencingFileConverter.a(this.propertyManager)) { - return false; - } else { - // this.a((PlayerList) (new DedicatedPlayerList(this))); // CraftBukkit - moved up - this.convertable = new WorldLoaderServer(server.getWorldContainer()); // CraftBukkit - moved from MinecraftServer constructor - long j = System.nanoTime(); - - if (this.O() == null) { - this.k(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) { - try { - long l = Long.parseLong(s); - - if (l != 0L) { - k = l; - } - } catch (NumberFormatException numberformatexception) { - k = (long) s.hashCode(); - } - } - - WorldType worldtype = WorldType.getType(s1); - - if (worldtype == null) { - worldtype = WorldType.NORMAL; - } - - this.at(); - this.getEnableCommandBlock(); - this.l(); - this.getSnooperEnabled(); - this.c(this.propertyManager.getInt("max-build-height", 256)); - this.c((this.getMaxBuildHeight() + 8) / 16 * 16); - this.c(MathHelper.a(this.getMaxBuildHeight(), 64, 256)); - this.propertyManager.setProperty("max-build-height", Integer.valueOf(this.getMaxBuildHeight())); - i.info("Preparing level \"" + this.O() + "\""); - this.a(this.O(), this.O(), k, worldtype, s2); - long i1 = System.nanoTime() - j; - String s3 = String.format("%.3fs", new Object[] { Double.valueOf((double) i1 / 1.0E9D)}); - - i.info("Done (" + s3 + ")! For help, type \"help\" or \"?\""); - if (this.propertyManager.getBoolean("enable-query", false)) { - i.info("Starting GS4 status listener"); - this.k = new RemoteStatusListener(this); - this.k.a(); - } - - if (this.propertyManager.getBoolean("enable-rcon", false)) { - i.info("Starting remote control listener"); - this.l = new RemoteControlListener(this); - this.l.a(); - this.remoteConsole = new org.bukkit.craftbukkit.command.CraftRemoteConsoleCommandSender(); // CraftBukkit - } - - // CraftBukkit start - if (this.server.getBukkitSpawnRadius() > -1) { - i.info("'settings.spawn-radius' in bukkit.yml has been moved to 'spawn-protection' in server.properties. I will move your config for you."); - this.propertyManager.properties.remove("spawn-protection"); - this.propertyManager.getInt("spawn-protection", this.server.getBukkitSpawnRadius()); - this.server.removeBukkitSpawnRadius(); - this.propertyManager.savePropertiesFile(); - } - // CraftBukkit end - - return true; - } - } - } - - // CraftBukkit start - public PropertyManager getPropertyManager() { - return this.propertyManager; - } - // CraftBukkit end - - public boolean getGenerateStructures() { - return this.generateStructures; - } - - public EnumGamemode getGamemode() { - return this.p; - } - - public EnumDifficulty getDifficulty() { - return EnumDifficulty.getById(this.propertyManager.getInt("difficulty", 1)); - } - - public boolean isHardcore() { - return this.propertyManager.getBoolean("hardcore", false); - } - - protected void a(CrashReport crashreport) {} - - public CrashReport b(CrashReport crashreport) { - crashreport = super.b(crashreport); - crashreport.g().a("Is Modded", (Callable) (new CrashReportModded(this))); - crashreport.g().a("Type", (Callable) (new CrashReportType(this))); - return crashreport; - } - - protected void t() { - System.exit(0); - } - - public void v() { // CraftBukkit - protected -> public (decompile error?) - super.v(); - this.aB(); - } - - public boolean getAllowNether() { - return this.propertyManager.getBoolean("allow-nether", true); - } - - public boolean getSpawnMonsters() { - return this.propertyManager.getBoolean("spawn-monsters", true); - } - - public void a(MojangStatisticsGenerator mojangstatisticsgenerator) { - mojangstatisticsgenerator.a("whitelist_enabled", Boolean.valueOf(this.aC().getHasWhitelist())); - mojangstatisticsgenerator.a("whitelist_count", Integer.valueOf(this.aC().getWhitelisted().length)); - super.a(mojangstatisticsgenerator); - } - - public boolean getSnooperEnabled() { - return this.propertyManager.getBoolean("snooper-enabled", true); - } - - public void issueCommand(String s, ICommandListener icommandlistener) { - this.j.add(new ServerCommand(s, icommandlistener)); - } - - public void aB() { - while (!this.j.isEmpty()) { - ServerCommand servercommand = (ServerCommand) this.j.remove(0); - - // CraftBukkit start - ServerCommand for preprocessing - ServerCommandEvent event = new ServerCommandEvent(this.console, servercommand.command); - this.server.getPluginManager().callEvent(event); - servercommand = new ServerCommand(event.getCommand(), servercommand.source); - - // this.getCommandHandler().a(servercommand.source, servercommand.command); // Called in dispatchServerCommand - this.server.dispatchServerCommand(this.console, servercommand); - // CraftBukkit end - } - } - - public boolean X() { - return true; - } - - public DedicatedPlayerList aC() { - return (DedicatedPlayerList) super.getPlayerList(); - } - - public int a(String s, int i) { - return this.propertyManager.getInt(s, i); - } - - public String a(String s, String s1) { - return this.propertyManager.getString(s, s1); - } - - public boolean a(String s, boolean flag) { - return this.propertyManager.getBoolean(s, flag); - } - - public void a(String s, Object object) { - this.propertyManager.setProperty(s, object); - } - - public void a() { - this.propertyManager.savePropertiesFile(); - } - - public String b() { - File file1 = this.propertyManager.c(); - - return file1 != null ? file1.getAbsolutePath() : "No settings file"; - } - - public void aD() { - ServerGUI.a(this); - this.q = true; - } - - public boolean ak() { - return this.q; - } - - public String a(EnumGamemode enumgamemode, boolean flag) { - return ""; - } - - public boolean getEnableCommandBlock() { - return this.propertyManager.getBoolean("enable-command-block", false); - } - - public int getSpawnProtection() { - return this.propertyManager.getInt("spawn-protection", super.getSpawnProtection()); - } - - public boolean a(World world, int i, int j, int k, EntityHuman entityhuman) { - if (world.worldProvider.dimension != 0) { - return false; - } else if (this.aC().getOPs().isEmpty()) { - return false; - } else if (this.aC().isOp(entityhuman.getProfile())) { - return false; - } else if (this.getSpawnProtection() <= 0) { - return false; - } else { - ChunkCoordinates chunkcoordinates = world.getSpawn(); - int l = MathHelper.a(i - chunkcoordinates.x); - int i1 = MathHelper.a(k - chunkcoordinates.z); - int j1 = Math.max(l, i1); - - return j1 <= this.getSpawnProtection(); - } - } - - public int l() { - return this.propertyManager.getInt("op-permission-level", 4); - } - - public void setIdleTimeout(int i) { - super.setIdleTimeout(i); - this.propertyManager.setProperty("player-idle-timeout", Integer.valueOf(i)); - this.a(); - } - - public boolean m() { - return this.propertyManager.getBoolean("broadcast-rcon-to-ops", true); - } - - public boolean at() { - return this.propertyManager.getBoolean("announce-player-achievements", true); - } - - protected boolean aE() { - boolean flag = false; - - int i; - - for (i = 0; !flag && i <= 2; ++i) { - if (i > 0) { - // CraftBukkit - Fix decompiler stomping on field - DedicatedServer.i.warn("Encountered a problem while converting the user banlist, retrying in a few seconds"); - this.aG(); - } - - flag = NameReferencingFileConverter.a((MinecraftServer) this); - } - - boolean flag1 = false; - - for (i = 0; !flag1 && i <= 2; ++i) { - if (i > 0) { - // CraftBukkit - Fix decompiler stomping on field - DedicatedServer.i.warn("Encountered a problem while converting the ip banlist, retrying in a few seconds"); - this.aG(); - } - - flag1 = NameReferencingFileConverter.b((MinecraftServer) this); - } - - boolean flag2 = false; - - for (i = 0; !flag2 && i <= 2; ++i) { - if (i > 0) { - // CraftBukkit - Fix decompiler stomping on field - DedicatedServer.i.warn("Encountered a problem while converting the op list, retrying in a few seconds"); - this.aG(); - } - - flag2 = NameReferencingFileConverter.c((MinecraftServer) this); - } - - boolean flag3 = false; - - for (i = 0; !flag3 && i <= 2; ++i) { - if (i > 0) { - // CraftBukkit - Fix decompiler stomping on field - DedicatedServer.i.warn("Encountered a problem while converting the whitelist, retrying in a few seconds"); - this.aG(); - } - - flag3 = NameReferencingFileConverter.d((MinecraftServer) this); - } - - boolean flag4 = false; - - for (i = 0; !flag4 && i <= 2; ++i) { - if (i > 0) { - // CraftBukkit - Fix decompiler stomping on field - DedicatedServer.i.warn("Encountered a problem while converting the player save files, retrying in a few seconds"); - this.aG(); - } - - flag4 = NameReferencingFileConverter.a(this, this.propertyManager); - } - - return flag || flag1 || flag2 || flag3 || flag4; - } - - private void aG() { - try { - Thread.sleep(5000L); - } catch (InterruptedException interruptedexception) { - ; - } - } - - public PlayerList getPlayerList() { - return this.aC(); - } - - static Logger aF() { - return i; - } -} diff --git a/src/main/java/net/minecraft/server/DispenseBehaviorArmor.java b/src/main/java/net/minecraft/server/DispenseBehaviorArmor.java deleted file mode 100644 index 9df12c0f..00000000 --- a/src/main/java/net/minecraft/server/DispenseBehaviorArmor.java +++ /dev/null @@ -1,67 +0,0 @@ -package net.minecraft.server; - -import java.util.List; - -// CraftBukkit start -import org.bukkit.craftbukkit.inventory.CraftItemStack; -import org.bukkit.event.block.BlockDispenseEvent; -// CraftBukkit end - -final class DispenseBehaviorArmor extends DispenseBehaviorItem { - - DispenseBehaviorArmor() {} - - protected ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) { - EnumFacing enumfacing = BlockDispenser.b(isourceblock.h()); - int i = isourceblock.getBlockX() + enumfacing.getAdjacentX(); - int j = isourceblock.getBlockY() + enumfacing.getAdjacentY(); - int k = isourceblock.getBlockZ() + enumfacing.getAdjacentZ(); - AxisAlignedBB axisalignedbb = AxisAlignedBB.a((double) i, (double) j, (double) k, (double) (i + 1), (double) (j + 1), (double) (k + 1)); - List list = isourceblock.k().a(EntityLiving.class, axisalignedbb, (IEntitySelector) (new EntitySelectorEquipable(itemstack))); - - if (list.size() > 0) { - EntityLiving entityliving = (EntityLiving) list.get(0); - int l = entityliving instanceof EntityHuman ? 1 : 0; - int i1 = EntityInsentient.b(itemstack); - - // CraftBukkit start - ItemStack itemstack1 = itemstack.a(1); - World world = isourceblock.k(); - org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ()); - CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); - - BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0)); - if (!BlockDispenser.eventFired) { - world.getServer().getPluginManager().callEvent(event); - } - - if (event.isCancelled()) { - itemstack.count++; - return itemstack; - } - - if (!event.getItem().equals(craftItem)) { - itemstack.count++; - // Chain to handler for new item - ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); - IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.get(eventStack.getItem()); - if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) { - idispensebehavior.a(isourceblock, eventStack); - return itemstack; - } - } - // CraftBukkit end - - itemstack1.count = 1; - entityliving.setEquipment(i1 - l, itemstack1); - if (entityliving instanceof EntityInsentient) { - ((EntityInsentient) entityliving).a(i1, 2.0F); - } - - // --itemstack.count; // CraftBukkit - handled above - return itemstack; - } else { - return super.b(isourceblock, itemstack); - } - } -} diff --git a/src/main/java/net/minecraft/server/DispenseBehaviorBoat.java b/src/main/java/net/minecraft/server/DispenseBehaviorBoat.java deleted file mode 100644 index 5bd6ec75..00000000 --- a/src/main/java/net/minecraft/server/DispenseBehaviorBoat.java +++ /dev/null @@ -1,73 +0,0 @@ -package net.minecraft.server; - -// CraftBukkit start -import org.bukkit.craftbukkit.inventory.CraftItemStack; -import org.bukkit.event.block.BlockDispenseEvent; -// CraftBukkit end - -final class DispenseBehaviorBoat extends DispenseBehaviorItem { - - private final DispenseBehaviorItem b = new DispenseBehaviorItem(); - - DispenseBehaviorBoat() {} - - public ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) { - EnumFacing enumfacing = BlockDispenser.b(isourceblock.h()); - World world = isourceblock.k(); - double d0 = isourceblock.getX() + (double) ((float) enumfacing.getAdjacentX() * 1.125F); - double d1 = isourceblock.getY() + (double) ((float) enumfacing.getAdjacentY() * 1.125F); - double d2 = isourceblock.getZ() + (double) ((float) enumfacing.getAdjacentZ() * 1.125F); - int i = isourceblock.getBlockX() + enumfacing.getAdjacentX(); - int j = isourceblock.getBlockY() + enumfacing.getAdjacentY(); - int k = isourceblock.getBlockZ() + enumfacing.getAdjacentZ(); - Material material = world.getType(i, j, k).getMaterial(); - double d3; - - if (Material.WATER.equals(material)) { - d3 = 1.0D; - } else { - if (!Material.AIR.equals(material) || !Material.WATER.equals(world.getType(i, j - 1, k).getMaterial())) { - return this.b.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()); - CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); - - BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), 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(craftItem)) { - itemstack.count++; - // Chain to handler for new item - ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); - IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.get(eventStack.getItem()); - if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) { - idispensebehavior.a(isourceblock, eventStack); - 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/DispenseBehaviorBonemeal.java b/src/main/java/net/minecraft/server/DispenseBehaviorBonemeal.java deleted file mode 100644 index b547bc97..00000000 --- a/src/main/java/net/minecraft/server/DispenseBehaviorBonemeal.java +++ /dev/null @@ -1,67 +0,0 @@ -package net.minecraft.server; - -// CraftBukkit start -import org.bukkit.craftbukkit.inventory.CraftItemStack; -import org.bukkit.event.block.BlockDispenseEvent; -// CraftBukkit end - -final class DispenseBehaviorBonemeal extends DispenseBehaviorItem { - - private boolean b = true; - - DispenseBehaviorBonemeal() {} - - protected ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) { - if (itemstack.getData() == 15) { - EnumFacing enumfacing = BlockDispenser.b(isourceblock.h()); - World world = isourceblock.k(); - int i = isourceblock.getBlockX() + enumfacing.getAdjacentX(); - int j = isourceblock.getBlockY() + enumfacing.getAdjacentY(); - int k = isourceblock.getBlockZ() + enumfacing.getAdjacentZ(); - - // CraftBukkit start - org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ()); - CraftItemStack craftItem = CraftItemStack.asNewCraftStack(itemstack.getItem()); - - BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), 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(craftItem)) { - // Chain to handler for new item - ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); - IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.get(eventStack.getItem()); - if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) { - idispensebehavior.a(isourceblock, eventStack); - return itemstack; - } - } - // CraftBukkit end - - if (ItemDye.a(itemstack, world, i, j, k)) { - if (!world.isStatic) { - world.triggerEffect(2005, i, j, k, 0); - } - } else { - this.b = false; - } - - return itemstack; - } else { - return super.b(isourceblock, itemstack); - } - } - - protected void a(ISourceBlock isourceblock) { - if (this.b) { - isourceblock.k().triggerEffect(1000, isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ(), 0); - } else { - isourceblock.k().triggerEffect(1001, 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 deleted file mode 100644 index d7decfce..00000000 --- a/src/main/java/net/minecraft/server/DispenseBehaviorEmptyBucket.java +++ /dev/null @@ -1,68 +0,0 @@ -package net.minecraft.server; - -// CraftBukkit start -import org.bukkit.craftbukkit.inventory.CraftItemStack; -import org.bukkit.event.block.BlockDispenseEvent; -// CraftBukkit end - -final class DispenseBehaviorEmptyBucket extends DispenseBehaviorItem { - - private final DispenseBehaviorItem b = new DispenseBehaviorItem(); - - DispenseBehaviorEmptyBucket() {} - - public ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) { - EnumFacing enumfacing = BlockDispenser.b(isourceblock.h()); - World world = isourceblock.k(); - int i = isourceblock.getBlockX() + enumfacing.getAdjacentX(); - int j = isourceblock.getBlockY() + enumfacing.getAdjacentY(); - int k = isourceblock.getBlockZ() + enumfacing.getAdjacentZ(); - Material material = world.getType(i, j, k).getMaterial(); - int l = world.getData(i, j, k); - Item item; - - if (Material.WATER.equals(material) && l == 0) { - item = Items.WATER_BUCKET; - } else { - if (!Material.LAVA.equals(material) || l != 0) { - return super.b(isourceblock, itemstack); - } - - item = Items.LAVA_BUCKET; - } - - // CraftBukkit start - org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ()); - CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack); - - BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(i, j, k)); - if (!BlockDispenser.eventFired) { - world.getServer().getPluginManager().callEvent(event); - } - - if (event.isCancelled()) { - return itemstack; - } - - if (!event.getItem().equals(craftItem)) { - // Chain to handler for new item - ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); - IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.get(eventStack.getItem()); - if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) { - idispensebehavior.a(isourceblock, eventStack); - return itemstack; - } - } - // CraftBukkit end - - world.setAir(i, j, k); - if (--itemstack.count == 0) { - itemstack.setItem(item); - itemstack.count = 1; - } else if (((TileEntityDispenser) isourceblock.getTileEntity()).addItem(new ItemStack(item)) < 0) { - this.b.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 deleted file mode 100644 index 4a3691a1..00000000 --- a/src/main/java/net/minecraft/server/DispenseBehaviorFilledBucket.java +++ /dev/null @@ -1,69 +0,0 @@ -package net.minecraft.server; - -// CraftBukkit start -import org.bukkit.craftbukkit.inventory.CraftItemStack; -import org.bukkit.event.block.BlockDispenseEvent; -// CraftBukkit end - -final class DispenseBehaviorFilledBucket extends DispenseBehaviorItem { - - private final DispenseBehaviorItem b = new DispenseBehaviorItem(); - - DispenseBehaviorFilledBucket() {} - - 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 = BlockDispenser.b(isourceblock.h()); - - // CraftBukkit start - World world = isourceblock.k(); - int x = i + enumfacing.getAdjacentX(); - int y = j + enumfacing.getAdjacentY(); - int z = k + enumfacing.getAdjacentZ(); - if (world.isEmpty(x, y, z) || !world.getType(x, y, z).getMaterial().isBuildable()) { - org.bukkit.block.Block block = world.getWorld().getBlockAt(i, j, k); - CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack); - - BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(x, y, z)); - if (!BlockDispenser.eventFired) { - world.getServer().getPluginManager().callEvent(event); - } - - if (event.isCancelled()) { - return itemstack; - } - - if (!event.getItem().equals(craftItem)) { - // Chain to handler for new item - ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); - IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.get(eventStack.getItem()); - if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) { - idispensebehavior.a(isourceblock, eventStack); - return itemstack; - } - } - - itembucket = (ItemBucket) CraftItemStack.asNMSCopy(event.getItem()).getItem(); - } - // CraftBukkit end - - if (itembucket.a(isourceblock.k(), i + enumfacing.getAdjacentX(), j + enumfacing.getAdjacentY(), k + enumfacing.getAdjacentZ())) { - // CraftBukkit start - Handle stacked buckets - Item item = Items.BUCKET; - if (--itemstack.count == 0) { - itemstack.setItem(Items.BUCKET); - itemstack.count = 1; - } else if (((TileEntityDispenser) isourceblock.getTileEntity()).addItem(new ItemStack(item)) < 0) { - this.b.a(isourceblock, new ItemStack(item)); - } - // CraftBukkit end - - return itemstack; - } else { - return this.b.a(isourceblock, itemstack); - } - } -} diff --git a/src/main/java/net/minecraft/server/DispenseBehaviorFireball.java b/src/main/java/net/minecraft/server/DispenseBehaviorFireball.java deleted file mode 100644 index d16f035f..00000000 --- a/src/main/java/net/minecraft/server/DispenseBehaviorFireball.java +++ /dev/null @@ -1,65 +0,0 @@ -package net.minecraft.server; - -import java.util.Random; - -// CraftBukkit start -import org.bukkit.craftbukkit.inventory.CraftItemStack; -import org.bukkit.event.block.BlockDispenseEvent; -// CraftBukkit end - -final class DispenseBehaviorFireball extends DispenseBehaviorItem { - - DispenseBehaviorFireball() {} - - public ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) { - EnumFacing enumfacing = BlockDispenser.b(isourceblock.h()); - IPosition iposition = BlockDispenser.a(isourceblock); - double d0 = iposition.getX() + (double) ((float) enumfacing.getAdjacentX() * 0.3F); - double d1 = iposition.getY() + (double) ((float) enumfacing.getAdjacentY() * 0.3F); - double d2 = iposition.getZ() + (double) ((float) enumfacing.getAdjacentZ() * 0.3F); - World world = isourceblock.k(); - Random random = world.random; - double d3 = random.nextGaussian() * 0.05D + (double) enumfacing.getAdjacentX(); - double d4 = random.nextGaussian() * 0.05D + (double) enumfacing.getAdjacentY(); - double d5 = random.nextGaussian() * 0.05D + (double) enumfacing.getAdjacentZ(); - - // CraftBukkit start - ItemStack itemstack1 = itemstack.a(1); - org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ()); - CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); - - BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), 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(craftItem)) { - itemstack.count++; - // Chain to handler for new item - ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); - IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.get(eventStack.getItem()); - if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) { - idispensebehavior.a(isourceblock, eventStack); - return itemstack; - } - } - - EntitySmallFireball entitysmallfireball = new EntitySmallFireball(world, d0, d1, d2, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ()); - entitysmallfireball.projectileSource = new org.bukkit.craftbukkit.projectiles.CraftBlockProjectileSource((TileEntityDispenser) isourceblock.getTileEntity()); - - world.addEntity(entitysmallfireball); - // 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/DispenseBehaviorFireworks.java b/src/main/java/net/minecraft/server/DispenseBehaviorFireworks.java deleted file mode 100644 index 09a0842b..00000000 --- a/src/main/java/net/minecraft/server/DispenseBehaviorFireworks.java +++ /dev/null @@ -1,58 +0,0 @@ -package net.minecraft.server; - -// CraftBukkit start -import org.bukkit.craftbukkit.inventory.CraftItemStack; -import org.bukkit.event.block.BlockDispenseEvent; -// CraftBukkit end - -final class DispenseBehaviorFireworks extends DispenseBehaviorItem { - - DispenseBehaviorFireworks() {} - - public ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) { - EnumFacing enumfacing = BlockDispenser.b(isourceblock.h()); - double d0 = isourceblock.getX() + (double) enumfacing.getAdjacentX(); - double d1 = (double) ((float) isourceblock.getBlockY() + 0.2F); - double d2 = isourceblock.getZ() + (double) enumfacing.getAdjacentZ(); - - // 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()); - CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); - - BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), 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(craftItem)) { - itemstack.count++; - // Chain to handler for new item - ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); - IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.get(eventStack.getItem()); - if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) { - idispensebehavior.a(isourceblock, eventStack); - return itemstack; - } - } - - itemstack1 = CraftItemStack.asNMSCopy(event.getItem()); - EntityFireworks entityfireworks = new EntityFireworks(isourceblock.k(), event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), itemstack1); - - isourceblock.k().addEntity(entityfireworks); - // 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/DispenseBehaviorFlintAndSteel.java b/src/main/java/net/minecraft/server/DispenseBehaviorFlintAndSteel.java deleted file mode 100644 index c4bbd6b3..00000000 --- a/src/main/java/net/minecraft/server/DispenseBehaviorFlintAndSteel.java +++ /dev/null @@ -1,71 +0,0 @@ -package net.minecraft.server; - -// CraftBukkit start -import org.bukkit.craftbukkit.inventory.CraftItemStack; -import org.bukkit.event.block.BlockDispenseEvent; -// CraftBukkit end - -final class DispenseBehaviorFlintAndSteel extends DispenseBehaviorItem { - - private boolean b = true; - - DispenseBehaviorFlintAndSteel() {} - - protected ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) { - EnumFacing enumfacing = BlockDispenser.b(isourceblock.h()); - World world = isourceblock.k(); - int i = isourceblock.getBlockX() + enumfacing.getAdjacentX(); - int j = isourceblock.getBlockY() + enumfacing.getAdjacentY(); - int k = isourceblock.getBlockZ() + enumfacing.getAdjacentZ(); - - // CraftBukkit start - org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ()); - CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack); - - BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), 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(craftItem)) { - // Chain to handler for new item - ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); - IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.get(eventStack.getItem()); - if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) { - idispensebehavior.a(isourceblock, eventStack); - return itemstack; - } - } - // CraftBukkit end - - if (world.isEmpty(i, j, k)) { - // CraftBukkit start - Ignition by dispensing flint and steel - if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, i, j, k, isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ()).isCancelled()) { - world.setTypeUpdate(i, j, k, Blocks.FIRE); - if (itemstack.isDamaged(1, world.random)) { - itemstack.count = 0; - } - } - // CraftBukkit end - } else if (world.getType(i, j, k) == Blocks.TNT) { - Blocks.TNT.postBreak(world, i, j, k, 1); - world.setAir(i, j, k); - } else { - this.b = false; - } - - return itemstack; - } - - protected void a(ISourceBlock isourceblock) { - if (this.b) { - isourceblock.k().triggerEffect(1000, isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ(), 0); - } else { - isourceblock.k().triggerEffect(1001, 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 deleted file mode 100644 index e7196db0..00000000 --- a/src/main/java/net/minecraft/server/DispenseBehaviorItem.java +++ /dev/null @@ -1,98 +0,0 @@ -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, BlockDispenser.b(isourceblock.h())); - return itemstack1; - } - - protected ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) { - EnumFacing enumfacing = BlockDispenser.b(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.getAdjacentX() * d3; - entityitem.motY = 0.20000000298023224D; - entityitem.motZ = (double) enumfacing.getAdjacentZ() * 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()); - CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack); - - BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), 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.setItemStack(CraftItemStack.asNMSCopy(event.getItem())); - entityitem.motX = event.getVelocity().getX(); - entityitem.motY = event.getVelocity().getY(); - entityitem.motZ = event.getVelocity().getZ(); - - if (!event.getItem().equals(craftItem)) { - // Chain to handler for new item - ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); - IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.get(eventStack.getItem()); - if (idispensebehavior != IDispenseBehavior.a && idispensebehavior.getClass() != DispenseBehaviorItem.class) { - idispensebehavior.a(isourceblock, eventStack); - } else { - world.addEntity(entityitem); - } - return false; - } - - world.addEntity(entityitem); - - 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.getAdjacentX() + 1 + (enumfacing.getAdjacentZ() + 1) * 3; - } -} diff --git a/src/main/java/net/minecraft/server/DispenseBehaviorMinecart.java b/src/main/java/net/minecraft/server/DispenseBehaviorMinecart.java deleted file mode 100644 index 3df54aad..00000000 --- a/src/main/java/net/minecraft/server/DispenseBehaviorMinecart.java +++ /dev/null @@ -1,78 +0,0 @@ -package net.minecraft.server; - -// CraftBukkit start -import org.bukkit.craftbukkit.inventory.CraftItemStack; -import org.bukkit.event.block.BlockDispenseEvent; -// CraftBukkit end - -final class DispenseBehaviorMinecart extends DispenseBehaviorItem { - - private final DispenseBehaviorItem b = new DispenseBehaviorItem(); - - DispenseBehaviorMinecart() {} - - public ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) { - EnumFacing enumfacing = BlockDispenser.b(isourceblock.h()); - World world = isourceblock.k(); - double d0 = isourceblock.getX() + (double) ((float) enumfacing.getAdjacentX() * 1.125F); - double d1 = isourceblock.getY() + (double) ((float) enumfacing.getAdjacentY() * 1.125F); - double d2 = isourceblock.getZ() + (double) ((float) enumfacing.getAdjacentZ() * 1.125F); - int i = isourceblock.getBlockX() + enumfacing.getAdjacentX(); - int j = isourceblock.getBlockY() + enumfacing.getAdjacentY(); - int k = isourceblock.getBlockZ() + enumfacing.getAdjacentZ(); - Block block = world.getType(i, j, k); - double d3; - - if (BlockMinecartTrackAbstract.a(block)) { - d3 = 0.0D; - } else { - if (block.getMaterial() != Material.AIR || !BlockMinecartTrackAbstract.a(world.getType(i, j - 1, k))) { - return this.b.a(isourceblock, itemstack); - } - - d3 = -1.0D; - } - - // CraftBukkit start - ItemStack itemstack1 = itemstack.a(1); - org.bukkit.block.Block block2 = world.getWorld().getBlockAt(isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ()); - CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); - - BlockDispenseEvent event = new BlockDispenseEvent(block2, craftItem.clone(), 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(craftItem)) { - itemstack.count++; - // Chain to handler for new item - ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); - IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.get(eventStack.getItem()); - if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) { - idispensebehavior.a(isourceblock, eventStack); - return itemstack; - } - } - - itemstack1 = CraftItemStack.asNMSCopy(event.getItem()); - EntityMinecartAbstract entityminecartabstract = EntityMinecartAbstract.a(world, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), ((ItemMinecart) itemstack1.getItem()).a); - // CraftBukkit end - - if (itemstack.hasName()) { - entityminecartabstract.a(itemstack.getName()); - } - - world.addEntity(entityminecartabstract); - // 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 deleted file mode 100644 index c3454101..00000000 --- a/src/main/java/net/minecraft/server/DispenseBehaviorMonsterEgg.java +++ /dev/null @@ -1,57 +0,0 @@ -package net.minecraft.server; - -// CraftBukkit start -import org.bukkit.craftbukkit.inventory.CraftItemStack; -import org.bukkit.event.block.BlockDispenseEvent; -// CraftBukkit end - -final class DispenseBehaviorMonsterEgg extends DispenseBehaviorItem { - - DispenseBehaviorMonsterEgg() {} - - public ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) { - EnumFacing enumfacing = BlockDispenser.b(isourceblock.h()); - double d0 = isourceblock.getX() + (double) enumfacing.getAdjacentX(); - double d1 = (double) ((float) isourceblock.getBlockY() + 0.2F); - double d2 = isourceblock.getZ() + (double) enumfacing.getAdjacentZ(); - - // 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()); - CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); - - BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), 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(craftItem)) { - itemstack.count++; - // Chain to handler for new item - ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); - IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.get(eventStack.getItem()); - if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) { - idispensebehavior.a(isourceblock, eventStack); - return itemstack; - } - } - - itemstack1 = CraftItemStack.asNMSCopy(event.getItem()); - - Entity entity = ItemMonsterEgg.spawnCreature(isourceblock.k(), itemstack.getData(), event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DISPENSE_EGG); - - if (entity instanceof EntityLiving && itemstack.hasName()) { - ((EntityInsentient) entity).setCustomName(itemstack.getName()); - } - - // itemstack.a(1); // Handled during event processing - // CraftBukkit end - return itemstack; - } -} diff --git a/src/main/java/net/minecraft/server/DispenseBehaviorProjectile.java b/src/main/java/net/minecraft/server/DispenseBehaviorProjectile.java deleted file mode 100644 index b9063735..00000000 --- a/src/main/java/net/minecraft/server/DispenseBehaviorProjectile.java +++ /dev/null @@ -1,66 +0,0 @@ -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 = BlockDispenser.b(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()); - CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); - - BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector((double) enumfacing.getAdjacentX(), (double) ((float) enumfacing.getAdjacentY() + 0.1F), (double) enumfacing.getAdjacentZ())); - if (!BlockDispenser.eventFired) { - world.getServer().getPluginManager().callEvent(event); - } - - if (event.isCancelled()) { - itemstack.count++; - return itemstack; - } - - if (!event.getItem().equals(craftItem)) { - itemstack.count++; - // Chain to handler for new item - ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); - IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.get(eventStack.getItem()); - if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) { - idispensebehavior.a(isourceblock, eventStack); - return itemstack; - } - } - - iprojectile.shoot(event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), this.b(), this.a()); - ((Entity) iprojectile).projectileSource = new org.bukkit.craftbukkit.projectiles.CraftBlockProjectileSource((TileEntityDispenser) isourceblock.getTileEntity()); - // 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/DispenseBehaviorTNT.java b/src/main/java/net/minecraft/server/DispenseBehaviorTNT.java deleted file mode 100644 index d9493393..00000000 --- a/src/main/java/net/minecraft/server/DispenseBehaviorTNT.java +++ /dev/null @@ -1,52 +0,0 @@ -package net.minecraft.server; - -// CraftBukkit start -import org.bukkit.craftbukkit.inventory.CraftItemStack; -import org.bukkit.event.block.BlockDispenseEvent; -// CraftBukkit end - -final class DispenseBehaviorTNT extends DispenseBehaviorItem { - - DispenseBehaviorTNT() {} - - protected ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) { - EnumFacing enumfacing = BlockDispenser.b(isourceblock.h()); - World world = isourceblock.k(); - int i = isourceblock.getBlockX() + enumfacing.getAdjacentX(); - int j = isourceblock.getBlockY() + enumfacing.getAdjacentY(); - int k = isourceblock.getBlockZ() + enumfacing.getAdjacentZ(); - - // CraftBukkit start - ItemStack itemstack1 = itemstack.a(1); - org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ()); - CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); - - BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(i + 0.5, j + 0.5, k + 0.5)); - if (!BlockDispenser.eventFired) { - world.getServer().getPluginManager().callEvent(event); - } - - if (event.isCancelled()) { - itemstack.count++; - return itemstack; - } - - if (!event.getItem().equals(craftItem)) { - itemstack.count++; - // Chain to handler for new item - ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); - IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.get(eventStack.getItem()); - if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) { - idispensebehavior.a(isourceblock, eventStack); - return itemstack; - } - } - - EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), (EntityLiving) null); - // CraftBukkit end - - world.addEntity(entitytntprimed); - // --itemstack.count; // CraftBukkit - handled above - return itemstack; - } -} diff --git a/src/main/java/net/minecraft/server/Enchantment.java b/src/main/java/net/minecraft/server/Enchantment.java deleted file mode 100644 index d96ca7d4..00000000 --- a/src/main/java/net/minecraft/server/Enchantment.java +++ /dev/null @@ -1,122 +0,0 @@ -package net.minecraft.server; - -import java.util.ArrayList; - -public abstract class Enchantment { - - // CraftBukkit - update CraftEnchant.getName(i) if this changes - public static final Enchantment[] byId = new Enchantment[256]; - public static final Enchantment[] c; - public static final Enchantment PROTECTION_ENVIRONMENTAL = new EnchantmentProtection(0, 10, 0); - public static final Enchantment PROTECTION_FIRE = new EnchantmentProtection(1, 5, 1); - public static final Enchantment PROTECTION_FALL = new EnchantmentProtection(2, 5, 2); - public static final Enchantment PROTECTION_EXPLOSIONS = new EnchantmentProtection(3, 2, 3); - public static final Enchantment PROTECTION_PROJECTILE = new EnchantmentProtection(4, 5, 4); - public static final Enchantment OXYGEN = new EnchantmentOxygen(5, 2); - public static final Enchantment WATER_WORKER = new EnchantmentWaterWorker(6, 2); - public static final Enchantment THORNS = new EnchantmentThorns(7, 1); - public static final Enchantment DAMAGE_ALL = new EnchantmentWeaponDamage(16, 10, 0); - public static final Enchantment DAMAGE_UNDEAD = new EnchantmentWeaponDamage(17, 5, 1); - public static final Enchantment DAMAGE_ARTHROPODS = new EnchantmentWeaponDamage(18, 5, 2); - public static final Enchantment KNOCKBACK = new EnchantmentKnockback(19, 5); - public static final Enchantment FIRE_ASPECT = new EnchantmentFire(20, 2); - public static final Enchantment LOOT_BONUS_MOBS = new EnchantmentLootBonus(21, 2, EnchantmentSlotType.WEAPON); - public static final Enchantment DIG_SPEED = new EnchantmentDigging(32, 10); - public static final Enchantment SILK_TOUCH = new EnchantmentSilkTouch(33, 1); - public static final Enchantment DURABILITY = new EnchantmentDurability(34, 5); - public static final Enchantment LOOT_BONUS_BLOCKS = new EnchantmentLootBonus(35, 2, EnchantmentSlotType.DIGGER); - public static final Enchantment ARROW_DAMAGE = new EnchantmentArrowDamage(48, 10); - public static final Enchantment ARROW_KNOCKBACK = new EnchantmentArrowKnockback(49, 2); - public static final Enchantment ARROW_FIRE = new EnchantmentFlameArrows(50, 2); - public static final Enchantment ARROW_INFINITE = new EnchantmentInfiniteArrows(51, 1); - public static final Enchantment LUCK = new EnchantmentLootBonus(61, 2, EnchantmentSlotType.FISHING_ROD); - public static final Enchantment LURE = new EnchantmentLure(62, 2, EnchantmentSlotType.FISHING_ROD); - public final int id; - private final int weight; - public EnchantmentSlotType slot; - protected String name; - - protected Enchantment(int i, int j, EnchantmentSlotType enchantmentslottype) { - this.id = i; - this.weight = j; - this.slot = enchantmentslottype; - if (byId[i] != null) { - throw new IllegalArgumentException("Duplicate enchantment id!"); - } else { - byId[i] = this; - } - - org.bukkit.enchantments.Enchantment.registerEnchantment(new org.bukkit.craftbukkit.enchantments.CraftEnchantment(this)); // CraftBukkit - } - - public int getRandomWeight() { - return this.weight; - } - - public int getStartLevel() { - return 1; - } - - public int getMaxLevel() { - return 1; - } - - public int a(int i) { - return 1 + i * 10; - } - - public int b(int i) { - return this.a(i) + 5; - } - - public int a(int i, DamageSource damagesource) { - return 0; - } - - public float a(int i, EnumMonsterType enummonstertype) { - return 0.0F; - } - - public boolean a(Enchantment enchantment) { - return this != enchantment; - } - - public Enchantment b(String s) { - this.name = s; - return this; - } - - public String a() { - return "enchantment." + this.name; - } - - public String c(int i) { - String s = LocaleI18n.get(this.a()); - - return s + " " + LocaleI18n.get("enchantment.level." + i); - } - - public boolean canEnchant(ItemStack itemstack) { - return this.slot.canEnchant(itemstack.getItem()); - } - - public void a(EntityLiving entityliving, Entity entity, int i) {} - - public void b(EntityLiving entityliving, Entity entity, int i) {} - - static { - ArrayList arraylist = new ArrayList(); - Enchantment[] aenchantment = byId; - int i = aenchantment.length; - - for (int j = 0; j < i; ++j) { - Enchantment enchantment = aenchantment[j]; - - if (enchantment != null) { - arraylist.add(enchantment); - } - } - - c = (Enchantment[]) arraylist.toArray(new Enchantment[0]); - } -} diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java deleted file mode 100644 index 09c9c8ee..00000000 --- a/src/main/java/net/minecraft/server/Entity.java +++ /dev/null @@ -1,1892 +0,0 @@ -package net.minecraft.server; - -import java.util.List; -import java.util.Random; -import java.util.UUID; -import java.util.concurrent.Callable; - -// CraftBukkit start -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.Server; -import org.bukkit.TravelAgent; -import org.bukkit.block.BlockFace; -import org.bukkit.entity.Hanging; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Painting; -import org.bukkit.entity.Vehicle; -import org.bukkit.event.entity.EntityCombustByEntityEvent; -import org.bukkit.event.hanging.HangingBreakByEntityEvent; -import org.bukkit.event.painting.PaintingBreakByEntityEvent; -import org.bukkit.event.vehicle.VehicleBlockCollisionEvent; -import org.bukkit.event.vehicle.VehicleEnterEvent; -import org.bukkit.event.vehicle.VehicleExitEvent; -import org.bukkit.craftbukkit.CraftWorld; -import org.bukkit.craftbukkit.entity.CraftEntity; -import org.bukkit.craftbukkit.entity.CraftPlayer; -import org.bukkit.craftbukkit.event.CraftEventFactory; -import org.bukkit.event.entity.EntityCombustEvent; -import org.bukkit.event.entity.EntityPortalEvent; -import org.bukkit.plugin.PluginManager; -// CraftBukkit end - -public abstract class Entity { - - // CraftBukkit start - private static final int CURRENT_LEVEL = 2; - static boolean isLevelAtLeast(NBTTagCompound tag, int level) { - return tag.hasKey("Bukkit.updateLevel") && tag.getInt("Bukkit.updateLevel") >= level; - } - // CraftBukkit end - - private static int entityCount; - private int id; - public double j; - public boolean k; - public Entity passenger; - public Entity vehicle; - public boolean attachedToPlayer; - public World world; - public double lastX; - public double lastY; - public double lastZ; - public double locX; - public double locY; - public double locZ; - public double motX; - public double motY; - public double motZ; - public float yaw; - public float pitch; - public float lastYaw; - public float lastPitch; - public final AxisAlignedBB boundingBox; - public boolean onGround; - public boolean positionChanged; - public boolean F; - public boolean G; - public boolean velocityChanged; - protected boolean I; - public boolean J; - public boolean dead; - public float height; - public float width; - public float length; - public float O; - public float P; - public float Q; - public float fallDistance; - private int d; - public double S; - public double T; - public double U; - public float V; - public float W; - public boolean X; - public float Y; - public float Z; - protected Random random; - public int ticksLived; - public int maxFireTicks; - public int fireTicks; // CraftBukkit - private -> public - protected boolean inWater; - public int noDamageTicks; - private boolean justCreated; - protected boolean fireProof; - protected DataWatcher datawatcher; - private double g; - private double h; - public boolean ag; - public int ah; - public int ai; - public int aj; - public boolean ak; - public boolean al; - public int portalCooldown; - protected boolean an; - protected int ao; - public int dimension; - protected int aq; - private boolean invulnerable; - public UUID uniqueID; // CraftBukkit - protected -> public - public EnumEntitySize as; - public boolean valid; // CraftBukkit - public org.bukkit.projectiles.ProjectileSource projectileSource; // CraftBukkit - For projectiles only - - public int getId() { - return this.id; - } - - public void d(int i) { - this.id = i; - } - - public Entity(World world) { - this.id = entityCount++; - this.j = 1.0D; - this.boundingBox = AxisAlignedBB.a(0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D); - this.J = true; - this.width = 0.6F; - this.length = 1.8F; - this.d = 1; - this.random = new Random(); - this.maxFireTicks = 1; - this.justCreated = true; - this.uniqueID = UUID.randomUUID(); - this.as = EnumEntitySize.SIZE_2; - this.world = world; - this.setPosition(0.0D, 0.0D, 0.0D); - if (world != null) { - this.dimension = world.worldProvider.dimension; - } - - this.datawatcher = new DataWatcher(this); - this.datawatcher.a(0, Byte.valueOf((byte) 0)); - this.datawatcher.a(1, Short.valueOf((short) 300)); - this.c(); - } - - protected abstract void c(); - - public DataWatcher getDataWatcher() { - return this.datawatcher; - } - - public boolean equals(Object object) { - return object instanceof Entity ? ((Entity) object).id == this.id : false; - } - - public int hashCode() { - return this.id; - } - - public void die() { - this.dead = true; - } - - protected void a(float f, float f1) { - float f2; - - if (f != this.width || f1 != this.length) { - f2 = this.width; - this.width = f; - this.length = f1; - this.boundingBox.d = this.boundingBox.a + (double) this.width; - this.boundingBox.f = this.boundingBox.c + (double) this.width; - this.boundingBox.e = this.boundingBox.b + (double) this.length; - if (this.width > f2 && !this.justCreated && !this.world.isStatic) { - this.move((double) (f2 - this.width), 0.0D, (double) (f2 - this.width)); - } - } - - f2 = f % 2.0F; - if ((double) f2 < 0.375D) { - this.as = EnumEntitySize.SIZE_1; - } else if ((double) f2 < 0.75D) { - this.as = EnumEntitySize.SIZE_2; - } else if ((double) f2 < 1.0D) { - this.as = EnumEntitySize.SIZE_3; - } else if ((double) f2 < 1.375D) { - this.as = EnumEntitySize.SIZE_4; - } else if ((double) f2 < 1.75D) { - this.as = EnumEntitySize.SIZE_5; - } else { - this.as = EnumEntitySize.SIZE_6; - } - } - - protected void b(float f, float f1) { - // CraftBukkit start - yaw was sometimes set to NaN, so we need to set it back to 0 - if (Float.isNaN(f)) { - f = 0; - } - - if ((f == Float.POSITIVE_INFINITY) || (f == Float.NEGATIVE_INFINITY)) { - if (this instanceof EntityPlayer) { - this.world.getServer().getLogger().warning(((CraftPlayer) this.getBukkitEntity()).getName() + " was caught trying to crash the server with an invalid yaw"); - ((CraftPlayer) this.getBukkitEntity()).kickPlayer("Nope"); - } - f = 0; - } - - // pitch was sometimes set to NaN, so we need to set it back to 0. - if (Float.isNaN(f1)) { - f1 = 0; - } - - if ((f1 == Float.POSITIVE_INFINITY) || (f1 == Float.NEGATIVE_INFINITY)) { - if (this instanceof EntityPlayer) { - this.world.getServer().getLogger().warning(((CraftPlayer) this.getBukkitEntity()).getName() + " was caught trying to crash the server with an invalid pitch"); - ((CraftPlayer) this.getBukkitEntity()).kickPlayer("Nope"); - } - f1 = 0; - } - // CraftBukkit end - - this.yaw = f % 360.0F; - this.pitch = f1 % 360.0F; - } - - public void setPosition(double d0, double d1, double d2) { - this.locX = d0; - this.locY = d1; - this.locZ = d2; - 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); - } - - public void h() { - this.C(); - } - - public void C() { - this.world.methodProfiler.a("entityBaseTick"); - if (this.vehicle != null && this.vehicle.dead) { - this.vehicle = null; - } - - this.O = this.P; - this.lastX = this.locX; - this.lastY = this.locY; - this.lastZ = this.locZ; - this.lastPitch = this.pitch; - this.lastYaw = this.yaw; - int i; - - if (!this.world.isStatic && this.world instanceof WorldServer) { - this.world.methodProfiler.a("portal"); - MinecraftServer minecraftserver = ((WorldServer) this.world).getMinecraftServer(); - - i = this.D(); - if (this.an) { - if (true || minecraftserver.getAllowNether()) { // CraftBukkit - if (this.vehicle == null && this.ao++ >= i) { - this.ao = i; - this.portalCooldown = this.ai(); - byte b0; - - if (this.world.worldProvider.dimension == -1) { - b0 = 0; - } else { - b0 = -1; - } - - this.b(b0); - } - - this.an = false; - } - } else { - if (this.ao > 0) { - this.ao -= 4; - } - - if (this.ao < 0) { - this.ao = 0; - } - } - - if (this.portalCooldown > 0) { - --this.portalCooldown; - } - - this.world.methodProfiler.b(); - } - - if (this.isSprinting() && !this.M()) { - int j = MathHelper.floor(this.locX); - - i = MathHelper.floor(this.locY - 0.20000000298023224D - (double) this.height); - int k = MathHelper.floor(this.locZ); - Block block = this.world.getType(j, i, k); - - if (block.getMaterial() != Material.AIR) { - this.world.addParticle("blockcrack_" + Block.getId(block) + "_" + this.world.getData(j, i, k), 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.N(); - if (this.world.isStatic) { - this.fireTicks = 0; - } else if (this.fireTicks > 0) { - if (this.fireProof) { - this.fireTicks -= 4; - if (this.fireTicks < 0) { - this.fireTicks = 0; - } - } else { - if (this.fireTicks % 20 == 0) { - this.damageEntity(DamageSource.BURN, 1.0F); - } - - --this.fireTicks; - } - } - - if (this.P()) { - this.E(); - this.fallDistance *= 0.5F; - } - - if (this.locY < -64.0D) { - this.G(); - } - - if (!this.world.isStatic) { - this.a(0, this.fireTicks > 0); - } - - this.justCreated = false; - this.world.methodProfiler.b(); - } - - public int D() { - return 0; - } - - protected void E() { - if (!this.fireProof) { - this.damageEntity(DamageSource.LAVA, 4); - - // CraftBukkit start - Fallen in lava TODO: this event spams! - if (this instanceof EntityLiving) { - if (this.fireTicks <= 0) { - // not on fire yet - // TODO: shouldn't be sending null for the block. - org.bukkit.block.Block damager = null; // ((WorldServer) this.l).getWorld().getBlockAt(i, j, k); - org.bukkit.entity.Entity damagee = this.getBukkitEntity(); - EntityCombustEvent combustEvent = new org.bukkit.event.entity.EntityCombustByBlockEvent(damager, damagee, 15); - this.world.getServer().getPluginManager().callEvent(combustEvent); - - if (!combustEvent.isCancelled()) { - this.setOnFire(combustEvent.getDuration()); - } - } else { - // This will be called every single tick the entity is in lava, so don't throw an event - this.setOnFire(15); - } - return; - } - // CraftBukkit end - we also don't throw an event unless the object in lava is living, to save on some event calls - - this.setOnFire(15); - } - } - - public void setOnFire(int i) { - int j = i * 20; - - j = EnchantmentProtection.a(this, j); - if (this.fireTicks < j) { - this.fireTicks = j; - } - } - - public void extinguish() { - this.fireTicks = 0; - } - - protected void G() { - this.die(); - } - - public boolean c(double d0, double d1, double d2) { - AxisAlignedBB axisalignedbb = this.boundingBox.c(d0, d1, d2); - List list = this.world.getCubes(this, axisalignedbb); - - return !list.isEmpty() ? false : !this.world.containsLiquid(axisalignedbb); - } - - public void move(double d0, double d1, double d2) { - // CraftBukkit start - Don't do anything if we aren't moving - // We need to do this regardless of whether or not we are moving thanks to portals - try { - this.I(); - } catch (Throwable throwable) { - CrashReport crashreport = CrashReport.a(throwable, "Checking entity block collision"); - CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Entity being checked for collision"); - - this.a(crashreportsystemdetails); - throw new ReportedException(crashreport); - } - // Check if we're moving - if (d0 == 0 && d1 == 0 && d2 == 0 && this.vehicle == null && this.passenger == null) { - return; - } - // CraftBukkit end - if (this.X) { - 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.locZ = (this.boundingBox.c + this.boundingBox.f) / 2.0D; - } else { - this.world.methodProfiler.a("move"); - this.V *= 0.4F; - double d3 = this.locX; - double d4 = this.locY; - double d5 = this.locZ; - - if (this.I) { - this.I = false; - d0 *= 0.25D; - d1 *= 0.05000000074505806D; - d2 *= 0.25D; - this.motX = 0.0D; - this.motY = 0.0D; - this.motZ = 0.0D; - } - - 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 d9; - - 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 -= d9; - } else { - d0 += d9; - } - } - - 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 -= d9; - } else { - d2 += d9; - } - } - - while (d0 != 0.0D && d2 != 0.0D && this.world.getCubes(this, this.boundingBox.c(d0, -1.0D, d2)).isEmpty()) { - if (d0 < d9 && d0 >= -d9) { - d0 = 0.0D; - } else if (d0 > 0.0D) { - d0 -= d9; - } else { - d0 += d9; - } - - if (d2 < d9 && d2 >= -d9) { - d2 = 0.0D; - } else if (d2 > 0.0D) { - d2 -= d9; - } else { - d2 += d9; - } - - d6 = d0; - d8 = d2; - } - } - - List list = this.world.getCubes(this, this.boundingBox.a(d0, d1, d2)); - - for (int i = 0; i < list.size(); ++i) { - d1 = ((AxisAlignedBB) list.get(i)).b(this.boundingBox, d1); - } - - this.boundingBox.d(0.0D, d1, 0.0D); - if (!this.J && d7 != d1) { - d2 = 0.0D; - d1 = 0.0D; - d0 = 0.0D; - } - - boolean flag1 = this.onGround || d7 != d1 && d7 < 0.0D; - - int j; - - for (j = 0; j < list.size(); ++j) { - d0 = ((AxisAlignedBB) list.get(j)).a(this.boundingBox, d0); - } - - this.boundingBox.d(d0, 0.0D, 0.0D); - if (!this.J && d6 != d0) { - d2 = 0.0D; - d1 = 0.0D; - d0 = 0.0D; - } - - for (j = 0; j < list.size(); ++j) { - d2 = ((AxisAlignedBB) list.get(j)).c(this.boundingBox, d2); - } - - this.boundingBox.d(0.0D, 0.0D, d2); - if (!this.J && d8 != d2) { - d2 = 0.0D; - d1 = 0.0D; - d0 = 0.0D; - } - - double d10; - double d11; - double d12; - int k; - - if (this.W > 0.0F && flag1 && (flag || this.V < 0.05F) && (d6 != d0 || d8 != d2)) { - d10 = d0; - d11 = d1; - d12 = d2; - d0 = d6; - d1 = (double) this.W; - d2 = d8; - AxisAlignedBB axisalignedbb1 = this.boundingBox.clone(); - - this.boundingBox.d(axisalignedbb); - list = this.world.getCubes(this, this.boundingBox.a(d6, d1, d8)); - - for (k = 0; k < list.size(); ++k) { - d1 = ((AxisAlignedBB) list.get(k)).b(this.boundingBox, d1); - } - - this.boundingBox.d(0.0D, d1, 0.0D); - if (!this.J && d7 != d1) { - d2 = 0.0D; - d1 = 0.0D; - d0 = 0.0D; - } - - for (k = 0; k < list.size(); ++k) { - d0 = ((AxisAlignedBB) list.get(k)).a(this.boundingBox, d0); - } - - this.boundingBox.d(d0, 0.0D, 0.0D); - if (!this.J && d6 != d0) { - d2 = 0.0D; - d1 = 0.0D; - d0 = 0.0D; - } - - for (k = 0; k < list.size(); ++k) { - d2 = ((AxisAlignedBB) list.get(k)).c(this.boundingBox, d2); - } - - this.boundingBox.d(0.0D, 0.0D, d2); - if (!this.J && d8 != d2) { - d2 = 0.0D; - d1 = 0.0D; - d0 = 0.0D; - } - - if (!this.J && d7 != d1) { - d2 = 0.0D; - d1 = 0.0D; - d0 = 0.0D; - } else { - d1 = (double) (-this.W); - - for (k = 0; k < list.size(); ++k) { - d1 = ((AxisAlignedBB) list.get(k)).b(this.boundingBox, d1); - } - - this.boundingBox.d(0.0D, d1, 0.0D); - } - - if (d10 * d10 + d12 * d12 >= d0 * d0 + d2 * d2) { - d0 = d10; - d1 = d11; - d2 = d12; - this.boundingBox.d(axisalignedbb1); - } - } - - 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.locZ = (this.boundingBox.c + this.boundingBox.f) / 2.0D; - this.positionChanged = d6 != d0 || d8 != d2; - this.F = d7 != d1; - this.onGround = d7 != d1 && d7 < 0.0D; - this.G = this.positionChanged || this.F; - this.a(d1, this.onGround); - if (d6 != d0) { - this.motX = 0.0D; - } - - if (d7 != d1) { - this.motY = 0.0D; - } - - if (d8 != d2) { - this.motZ = 0.0D; - } - - 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 (d6 > d0) { - block = block.getRelative(BlockFace.EAST); - } else if (d6 < d0) { - block = block.getRelative(BlockFace.WEST); - } else if (d8 > d2) { - block = block.getRelative(BlockFace.SOUTH); - } else if (d8 < d2) { - block = block.getRelative(BlockFace.NORTH); - } - - VehicleBlockCollisionEvent event = new VehicleBlockCollisionEvent(vehicle, block); - this.world.getServer().getPluginManager().callEvent(event); - } - // CraftBukkit end - - if (this.g_() && !flag && this.vehicle == null) { - int l = MathHelper.floor(this.locX); - - k = MathHelper.floor(this.locY - 0.20000000298023224D - (double) this.height); - int i1 = MathHelper.floor(this.locZ); - Block block = this.world.getType(l, k, i1); - int j1 = this.world.getType(l, k - 1, i1).b(); - - if (j1 == 11 || j1 == 32 || j1 == 21) { - block = this.world.getType(l, k - 1, i1); - } - - if (block != Blocks.LADDER) { - d11 = 0.0D; - } - - this.P = (float) ((double) this.P + (double) MathHelper.sqrt(d10 * d10 + d12 * d12) * 0.6D); - this.Q = (float) ((double) this.Q + (double) MathHelper.sqrt(d10 * d10 + d11 * d11 + d12 * d12) * 0.6D); - if (this.Q > (float) this.d && block.getMaterial() != Material.AIR) { - this.d = (int) this.Q + 1; - if (this.M()) { - 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.makeSound(this.H(), f, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F); - } - - this.a(l, k, i1, block); - block.b(this.world, l, k, i1, this); - } - } - - // CraftBukkit start - Move to the top of the method - /* - try { - this.I(); - } catch (Throwable throwable) { - CrashReport crashreport = CrashReport.a(throwable, "Checking entity block collision"); - CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Entity being checked for collision"); - - this.a(crashreportsystemdetails); - throw new ReportedException(crashreport); - } - */ - // CraftBukkit end - boolean flag2 = this.L(); - - if (this.world.e(this.boundingBox.shrink(0.001D, 0.001D, 0.001D))) { - this.burn(1); - if (!flag2) { - ++this.fireTicks; - // CraftBukkit start - Not on fire yet - if (this.fireTicks <= 0) { // Only throw events on the first combust, otherwise it spams - EntityCombustEvent event = new EntityCombustEvent(this.getBukkitEntity(), 8); - this.world.getServer().getPluginManager().callEvent(event); - - if (!event.isCancelled()) { - this.setOnFire(event.getDuration()); - } - } else { - // CraftBukkit end - this.setOnFire(8); - } - } - } else if (this.fireTicks <= 0) { - this.fireTicks = -this.maxFireTicks; - } - - if (flag2 && this.fireTicks > 0) { - this.makeSound("random.fizz", 0.7F, 1.6F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F); - this.fireTicks = -this.maxFireTicks; - } - - this.world.methodProfiler.b(); - } - } - - protected String H() { - return "game.neutral.swim"; - } - - protected void I() { - int i = MathHelper.floor(this.boundingBox.a + 0.001D); - int j = MathHelper.floor(this.boundingBox.b + 0.001D); - int k = MathHelper.floor(this.boundingBox.c + 0.001D); - int l = MathHelper.floor(this.boundingBox.d - 0.001D); - int i1 = MathHelper.floor(this.boundingBox.e - 0.001D); - int j1 = MathHelper.floor(this.boundingBox.f - 0.001D); - - if (this.world.b(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) { - Block block = this.world.getType(k1, l1, i2); - - try { - block.a(this.world, k1, l1, i2, this); - } catch (Throwable throwable) { - CrashReport crashreport = CrashReport.a(throwable, "Colliding entity with block"); - CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Block being collided with"); - - CrashReportSystemDetails.a(crashreportsystemdetails, k1, l1, i2, block, this.world.getData(k1, l1, i2)); - throw new ReportedException(crashreport); - } - } - } - } - } - } - - protected void a(int i, int j, int k, Block block) { - StepSound stepsound = block.stepSound; - - if (this.world.getType(i, j + 1, k) == Blocks.SNOW) { - stepsound = Blocks.SNOW.stepSound; - this.makeSound(stepsound.getStepSound(), stepsound.getVolume1() * 0.15F, stepsound.getVolume2()); - } else if (!block.getMaterial().isLiquid()) { - this.makeSound(stepsound.getStepSound(), stepsound.getVolume1() * 0.15F, stepsound.getVolume2()); - } - } - - public void makeSound(String s, float f, float f1) { - this.world.makeSound(this, s, f, f1); - } - - protected boolean g_() { - return true; - } - - protected void a(double d0, boolean flag) { - if (flag) { - if (this.fallDistance > 0.0F) { - this.b(this.fallDistance); - this.fallDistance = 0.0F; - } - } else if (d0 < 0.0D) { - this.fallDistance = (float) ((double) this.fallDistance - d0); - } - } - - public AxisAlignedBB J() { - return null; - } - - protected void burn(float i) { // CraftBukkit - int -> float - if (!this.fireProof) { - this.damageEntity(DamageSource.FIRE, (float) i); - } - } - - public final boolean isFireproof() { - return this.fireProof; - } - - protected void b(float f) { - if (this.passenger != null) { - this.passenger.b(f); - } - } - - public boolean L() { - return this.inWater || this.world.isRainingAt(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ)) || this.world.isRainingAt(MathHelper.floor(this.locX), MathHelper.floor(this.locY + (double) this.length), MathHelper.floor(this.locZ)); - } - - public boolean M() { - return this.inWater; - } - - public boolean N() { - if (this.world.a(this.boundingBox.grow(0.0D, -0.4000000059604645D, 0.0D).shrink(0.001D, 0.001D, 0.001D), Material.WATER, this)) { - if (!this.inWater && !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.makeSound(this.O(), f, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F); - float f1 = (float) MathHelper.floor(this.boundingBox.b); - - int i; - float f2; - float f3; - - for (i = 0; (float) i < 1.0F + this.width * 20.0F; ++i) { - f2 = (this.random.nextFloat() * 2.0F - 1.0F) * this.width; - f3 = (this.random.nextFloat() * 2.0F - 1.0F) * this.width; - this.world.addParticle("bubble", this.locX + (double) f2, (double) (f1 + 1.0F), this.locZ + (double) f3, this.motX, this.motY - (double) (this.random.nextFloat() * 0.2F), this.motZ); - } - - for (i = 0; (float) i < 1.0F + this.width * 20.0F; ++i) { - f2 = (this.random.nextFloat() * 2.0F - 1.0F) * this.width; - f3 = (this.random.nextFloat() * 2.0F - 1.0F) * this.width; - this.world.addParticle("splash", this.locX + (double) f2, (double) (f1 + 1.0F), this.locZ + (double) f3, this.motX, this.motY, this.motZ); - } - } - - this.fallDistance = 0.0F; - this.inWater = true; - this.fireTicks = 0; - } else { - this.inWater = false; - } - - return this.inWater; - } - - protected String O() { - return "game.neutral.swim.splash"; - } - - public boolean a(Material material) { - double d0 = this.locY + (double) this.getHeadHeight(); - int i = MathHelper.floor(this.locX); - int j = MathHelper.d((float) MathHelper.floor(d0)); - int k = MathHelper.floor(this.locZ); - Block block = this.world.getType(i, j, k); - - if (block.getMaterial() == material) { - float f = BlockFluids.b(this.world.getData(i, j, k)) - 0.11111111F; - float f1 = (float) (j + 1) - f; - - return d0 < (double) f1; - } else { - return false; - } - } - - public float getHeadHeight() { - return 0.0F; - } - - public boolean P() { - return this.world.a(this.boundingBox.grow(-0.10000000149011612D, -0.4000000059604645D, -0.10000000149011612D), Material.LAVA); - } - - public void a(float f, float f1, float f2) { - float f3 = f * f + f1 * f1; - - if (f3 >= 1.0E-4F) { - f3 = MathHelper.c(f3); - if (f3 < 1.0F) { - f3 = 1.0F; - } - - f3 = f2 / f3; - f *= f3; - f1 *= f3; - float f4 = MathHelper.sin(this.yaw * 3.1415927F / 180.0F); - float f5 = MathHelper.cos(this.yaw * 3.1415927F / 180.0F); - - this.motX += (double) (f * f5 - f1 * f4); - this.motZ += (double) (f1 * f5 + f * f4); - } - } - - public float d(float f) { - int i = MathHelper.floor(this.locX); - int j = MathHelper.floor(this.locZ); - - if (this.world.isLoaded(i, 0, j)) { - double d0 = (this.boundingBox.e - this.boundingBox.b) * 0.66D; - int k = MathHelper.floor(this.locY - (double) this.height + d0); - - return this.world.n(i, k, j); - } else { - return 0.0F; - } - } - - public void spawnIn(World world) { - // CraftBukkit start - if (world == null) { - this.die(); - this.world = ((CraftWorld) Bukkit.getServer().getWorlds().get(0)).getHandle(); - return; - } - // CraftBukkit end - - this.world = world; - } - - public void setLocation(double d0, double d1, double d2, float f, float f1) { - this.lastX = this.locX = d0; - this.lastY = this.locY = d1; - this.lastZ = this.locZ = d2; - this.lastYaw = this.yaw = f; - this.lastPitch = this.pitch = f1; - this.V = 0.0F; - double d3 = (double) (this.lastYaw - f); - - if (d3 < -180.0D) { - this.lastYaw += 360.0F; - } - - if (d3 >= 180.0D) { - this.lastYaw -= 360.0F; - } - - this.setPosition(this.locX, this.locY, this.locZ); - this.b(f, f1); - } - - 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.yaw = f; - this.pitch = f1; - this.setPosition(this.locX, this.locY, this.locZ); - } - - public float e(Entity entity) { - float f = (float) (this.locX - entity.locX); - float f1 = (float) (this.locY - entity.locY); - float f2 = (float) (this.locZ - entity.locZ); - - return MathHelper.c(f * f + f1 * f1 + f2 * f2); - } - - public double e(double d0, double d1, double d2) { - double d3 = this.locX - d0; - double d4 = this.locY - d1; - double d5 = this.locZ - d2; - - return d3 * d3 + d4 * d4 + d5 * d5; - } - - public double f(double d0, double d1, double d2) { - double d3 = this.locX - d0; - double d4 = this.locY - d1; - double d5 = this.locZ - d2; - - return (double) MathHelper.sqrt(d3 * d3 + d4 * d4 + d5 * d5); - } - - public double f(Entity entity) { - double d0 = this.locX - entity.locX; - double d1 = this.locY - entity.locY; - double d2 = this.locZ - entity.locZ; - - return d0 * d0 + d1 * d1 + d2 * d2; - } - - public void b_(EntityHuman entityhuman) {} - - public void collide(Entity entity) { - if (entity.passenger != this && entity.vehicle != this) { - double d0 = entity.locX - this.locX; - double d1 = entity.locZ - this.locZ; - double d2 = MathHelper.a(d0, d1); - - if (d2 >= 0.009999999776482582D) { - d2 = (double) MathHelper.sqrt(d2); - d0 /= d2; - d1 /= d2; - double d3 = 1.0D / d2; - - if (d3 > 1.0D) { - d3 = 1.0D; - } - - d0 *= d3; - d1 *= d3; - d0 *= 0.05000000074505806D; - d1 *= 0.05000000074505806D; - d0 *= (double) (1.0F - this.Y); - d1 *= (double) (1.0F - this.Y); - this.g(-d0, 0.0D, -d1); - entity.g(d0, 0.0D, d1); - } - } - } - - public void g(double d0, double d1, double d2) { - this.motX += d0; - this.motY += d1; - this.motZ += d2; - this.al = true; - } - - protected void Q() { - this.velocityChanged = true; - } - - public boolean damageEntity(DamageSource damagesource, float f) { - if (this.isInvulnerable()) { - return false; - } else { - this.Q(); - return false; - } - } - - public boolean R() { - return false; - } - - public boolean S() { - return false; - } - - public void b(Entity entity, int i) {} - - public boolean c(NBTTagCompound nbttagcompound) { - String s = this.W(); - - if (!this.dead && s != null) { - nbttagcompound.setString("id", s); - this.e(nbttagcompound); - return true; - } else { - return false; - } - } - - public boolean d(NBTTagCompound nbttagcompound) { - String s = this.W(); - - if (!this.dead && s != null && this.passenger == null) { - nbttagcompound.setString("id", s); - this.e(nbttagcompound); - return true; - } else { - return false; - } - } - - public void e(NBTTagCompound nbttagcompound) { - try { - nbttagcompound.set("Pos", this.a(new double[] { this.locX, this.locY + (double) this.V, 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 - // TODO: make sure this is the best way to address this. - if (Float.isNaN(this.yaw)) { - this.yaw = 0; - } - - if (Float.isNaN(this.pitch)) { - this.pitch = 0; - } - // CraftBukkit end - - nbttagcompound.set("Rotation", this.a(new float[] { this.yaw, this.pitch})); - nbttagcompound.setFloat("FallDistance", this.fallDistance); - nbttagcompound.setShort("Fire", (short) this.fireTicks); - nbttagcompound.setShort("Air", (short) this.getAirTicks()); - nbttagcompound.setBoolean("OnGround", this.onGround); - nbttagcompound.setInt("Dimension", this.dimension); - nbttagcompound.setBoolean("Invulnerable", this.invulnerable); - nbttagcompound.setInt("PortalCooldown", this.portalCooldown); - nbttagcompound.setLong("UUIDMost", this.getUniqueID().getMostSignificantBits()); - nbttagcompound.setLong("UUIDLeast", this.getUniqueID().getLeastSignificantBits()); - // CraftBukkit start - nbttagcompound.setLong("WorldUUIDLeast", this.world.getDataManager().getUUID().getLeastSignificantBits()); - nbttagcompound.setLong("WorldUUIDMost", this.world.getDataManager().getUUID().getMostSignificantBits()); - nbttagcompound.setInt("Bukkit.updateLevel", CURRENT_LEVEL); - // CraftBukkit end - this.b(nbttagcompound); - if (this.vehicle != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - - if (this.vehicle.c(nbttagcompound1)) { - nbttagcompound.set("Riding", nbttagcompound1); - } - } - } catch (Throwable throwable) { - CrashReport crashreport = CrashReport.a(throwable, "Saving entity NBT"); - CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Entity being saved"); - - this.a(crashreportsystemdetails); - throw new ReportedException(crashreport); - } - } - - public void f(NBTTagCompound nbttagcompound) { - try { - NBTTagList nbttaglist = nbttagcompound.getList("Pos", 6); - NBTTagList nbttaglist1 = nbttagcompound.getList("Motion", 6); - NBTTagList nbttaglist2 = nbttagcompound.getList("Rotation", 5); - - this.motX = nbttaglist1.d(0); - this.motY = nbttaglist1.d(1); - this.motZ = nbttaglist1.d(2); - /* CraftBukkit start - Moved section down - if (Math.abs(this.motX) > 10.0D) { - this.motX = 0.0D; - } - - if (Math.abs(this.motY) > 10.0D) { - this.motY = 0.0D; - } - - if (Math.abs(this.motZ) > 10.0D) { - this.motZ = 0.0D; - } - // CraftBukkit end */ - - this.lastX = this.S = this.locX = nbttaglist.d(0); - this.lastY = this.T = this.locY = nbttaglist.d(1); - this.lastZ = this.U = this.locZ = nbttaglist.d(2); - this.lastYaw = this.yaw = nbttaglist2.e(0); - this.lastPitch = this.pitch = nbttaglist2.e(1); - 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.invulnerable = nbttagcompound.getBoolean("Invulnerable"); - this.portalCooldown = nbttagcompound.getInt("PortalCooldown"); - if (nbttagcompound.hasKeyOfType("UUIDMost", 4) && nbttagcompound.hasKeyOfType("UUIDLeast", 4)) { - this.uniqueID = new UUID(nbttagcompound.getLong("UUIDMost"), nbttagcompound.getLong("UUIDLeast")); - } - - this.setPosition(this.locX, this.locY, this.locZ); - this.b(this.yaw, this.pitch); - this.a(nbttagcompound); - if (this.V()) { - this.setPosition(this.locX, this.locY, this.locZ); - } - - // CraftBukkit start - if (this instanceof EntityLiving) { - EntityLiving entity = (EntityLiving) this; - - // Reset the persistence for tamed animals - if (entity instanceof EntityTameableAnimal && !isLevelAtLeast(nbttagcompound, 2) && !nbttagcompound.getBoolean("PersistenceRequired")) { - EntityInsentient entityinsentient = (EntityInsentient) entity; - entityinsentient.persistent = !entityinsentient.isTypeNotPersistent(); - } - } - // CraftBukkit end - - // CraftBukkit start - Exempt Vehicles from notch's sanity check - if (!(this.getBukkitEntity() instanceof Vehicle)) { - if (Math.abs(this.motX) > 10.0D) { - this.motX = 0.0D; - } - - if (Math.abs(this.motY) > 10.0D) { - this.motY = 0.0D; - } - - if (Math.abs(this.motZ) > 10.0D) { - this.motZ = 0.0D; - } - } - // CraftBukkit end - - // CraftBukkit start - Reset world - if (this instanceof EntityPlayer) { - Server server = Bukkit.getServer(); - org.bukkit.World bworld = null; - - // TODO: Remove World related checks, replaced with WorldUID. - String worldName = nbttagcompound.getString("World"); - - if (nbttagcompound.hasKey("WorldUUIDMost") && nbttagcompound.hasKey("WorldUUIDLeast")) { - UUID uid = new UUID(nbttagcompound.getLong("WorldUUIDMost"), nbttagcompound.getLong("WorldUUIDLeast")); - bworld = server.getWorld(uid); - } else { - bworld = server.getWorld(worldName); - } - - if (bworld == null) { - EntityPlayer entityPlayer = (EntityPlayer) this; - bworld = ((org.bukkit.craftbukkit.CraftServer) server).getServer().getWorldServer(entityPlayer.dimension).getWorld(); - } - - this.spawnIn(bworld == null ? null : ((CraftWorld) bworld).getHandle()); - } - // CraftBukkit end - } catch (Throwable throwable) { - CrashReport crashreport = CrashReport.a(throwable, "Loading entity NBT"); - CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Entity being loaded"); - - this.a(crashreportsystemdetails); - throw new ReportedException(crashreport); - } - } - - protected boolean V() { - return true; - } - - protected final String W() { - return EntityTypes.b(this); - } - - protected abstract void a(NBTTagCompound nbttagcompound); - - protected abstract void b(NBTTagCompound nbttagcompound); - - public void X() {} - - protected NBTTagList a(double... adouble) { - NBTTagList nbttaglist = new NBTTagList(); - double[] adouble1 = adouble; - int i = adouble.length; - - for (int j = 0; j < i; ++j) { - double d0 = adouble1[j]; - - nbttaglist.add(new NBTTagDouble(d0)); - } - - return nbttaglist; - } - - protected NBTTagList a(float... afloat) { - NBTTagList nbttaglist = new NBTTagList(); - float[] afloat1 = afloat; - int i = afloat.length; - - for (int j = 0; j < i; ++j) { - float f = afloat1[j]; - - nbttaglist.add(new NBTTagFloat(f)); - } - - return nbttaglist; - } - - public EntityItem a(Item item, int i) { - return this.a(item, i, 0.0F); - } - - public EntityItem a(Item item, int i, float f) { - return this.a(new ItemStack(item, i, 0), f); - } - - public EntityItem a(ItemStack itemstack, float f) { - if (itemstack.count != 0 && itemstack.getItem() != null) { - // CraftBukkit start - Capture drops for death event - if (this instanceof EntityLiving && ((EntityLiving) this).drops != null) { - ((EntityLiving) this).drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemstack)); - return null; - } - // CraftBukkit end - - EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY + (double) f, this.locZ, itemstack); - - entityitem.pickupDelay = 10; - this.world.addEntity(entityitem); - return entityitem; - } else { - return null; - } - } - - public boolean isAlive() { - return !this.dead; - } - - public boolean inBlock() { - for (int i = 0; i < 8; ++i) { - float f = ((float) ((i >> 0) % 2) - 0.5F) * this.width * 0.8F; - float f1 = ((float) ((i >> 1) % 2) - 0.5F) * 0.1F; - float f2 = ((float) ((i >> 2) % 2) - 0.5F) * this.width * 0.8F; - int j = MathHelper.floor(this.locX + (double) f); - int k = MathHelper.floor(this.locY + (double) this.getHeadHeight() + (double) f1); - int l = MathHelper.floor(this.locZ + (double) f2); - - if (this.world.getType(j, k, l).r()) { - return true; - } - } - - return false; - } - - public boolean c(EntityHuman entityhuman) { - return false; - } - - public AxisAlignedBB h(Entity entity) { - return null; - } - - public void ab() { - if (this.vehicle.dead) { - this.vehicle = null; - } else { - this.motX = 0.0D; - this.motY = 0.0D; - this.motZ = 0.0D; - this.h(); - if (this.vehicle != null) { - this.vehicle.ac(); - this.h += (double) (this.vehicle.yaw - this.vehicle.lastYaw); - - for (this.g += (double) (this.vehicle.pitch - this.vehicle.lastPitch); this.h >= 180.0D; this.h -= 360.0D) { - ; - } - - while (this.h < -180.0D) { - this.h += 360.0D; - } - - while (this.g >= 180.0D) { - this.g -= 360.0D; - } - - while (this.g < -180.0D) { - this.g += 360.0D; - } - - double d0 = this.h * 0.5D; - double d1 = this.g * 0.5D; - float f = 10.0F; - - if (d0 > (double) f) { - d0 = (double) f; - } - - if (d0 < (double) (-f)) { - d0 = (double) (-f); - } - - if (d1 > (double) f) { - d1 = (double) f; - } - - if (d1 < (double) (-f)) { - d1 = (double) (-f); - } - - this.h -= d0; - this.g -= d1; - } - } - } - - public void ac() { - if (this.passenger != null) { - this.passenger.setPosition(this.locX, this.locY + this.ad() + this.passenger.ad(), this.locZ); - } - } - - public double ad() { - return (double) this.height; - } - - public double ae() { - return (double) this.length * 0.75D; - } - - public void mount(Entity entity) { - // CraftBukkit start - this.setPassengerOf(entity); - } - - protected CraftEntity bukkitEntity; - - public CraftEntity getBukkitEntity() { - if (this.bukkitEntity == null) { - this.bukkitEntity = CraftEntity.getEntity(this.world.getServer(), this); - } - return this.bukkitEntity; - } - - public void setPassengerOf(Entity entity) { - // b(null) doesn't really fly for overloaded methods, - // so this method is needed - - Entity originalVehicle = this.vehicle; - Entity originalPassenger = this.vehicle == null ? null : this.vehicle.passenger; - PluginManager pluginManager = Bukkit.getPluginManager(); - this.getBukkitEntity(); // make sure bukkitEntity is initialised - // CraftBukkit end - this.g = 0.0D; - this.h = 0.0D; - if (entity == null) { - if (this.vehicle != null) { - // CraftBukkit start - if ((this.bukkitEntity instanceof LivingEntity) && (this.vehicle.getBukkitEntity() instanceof Vehicle)) { - VehicleExitEvent event = new VehicleExitEvent((Vehicle) this.vehicle.getBukkitEntity(), (LivingEntity) this.bukkitEntity); - pluginManager.callEvent(event); - - if (event.isCancelled() || this.vehicle != originalVehicle) { - return; - } - } - // CraftBukkit end - - this.setPositionRotation(this.vehicle.locX, this.vehicle.boundingBox.b + (double) this.vehicle.length, this.vehicle.locZ, this.yaw, this.pitch); - this.vehicle.passenger = null; - } - - this.vehicle = null; - } else { - // CraftBukkit start - if ((this.bukkitEntity instanceof LivingEntity) && (entity.getBukkitEntity() instanceof Vehicle) && entity.world.isChunkLoaded((int) entity.locX >> 4, (int) entity.locZ >> 4)) { - // It's possible to move from one vehicle to another. We need to check if they're already in a vehicle, and fire an exit event if they are. - VehicleExitEvent exitEvent = null; - if (this.vehicle != null && this.vehicle.getBukkitEntity() instanceof Vehicle) { - exitEvent = new VehicleExitEvent((Vehicle) this.vehicle.getBukkitEntity(), (LivingEntity) this.bukkitEntity); - pluginManager.callEvent(exitEvent); - - if (exitEvent.isCancelled() || this.vehicle != originalVehicle || (this.vehicle != null && this.vehicle.passenger != originalPassenger)) { - return; - } - } - - VehicleEnterEvent event = new VehicleEnterEvent((Vehicle) entity.getBukkitEntity(), this.bukkitEntity); - pluginManager.callEvent(event); - - // If a plugin messes with the vehicle or the vehicle's passenger - if (event.isCancelled() || this.vehicle != originalVehicle || (this.vehicle != null && this.vehicle.passenger != originalPassenger)) { - // If we only cancelled the enterevent then we need to put the player in a decent position. - if (exitEvent != null && this.vehicle == originalVehicle && this.vehicle != null && this.vehicle.passenger == originalPassenger) { - this.setPositionRotation(this.vehicle.locX, this.vehicle.boundingBox.b + (double) this.vehicle.length, this.vehicle.locZ, this.yaw, this.pitch); - this.vehicle.passenger = null; - this.vehicle = null; - } - return; - } - } - // CraftBukkit end - - if (this.vehicle != null) { - this.vehicle.passenger = null; - } - - if (entity != null) { - for (Entity entity1 = entity.vehicle; entity1 != null; entity1 = entity1.vehicle) { - if (entity1 == this) { - return; - } - } - } - - this.vehicle = entity; - entity.passenger = this; - } - } - - public float af() { - return 0.1F; - } - - public Vec3D ag() { - return null; - } - - public void ah() { - if (this.portalCooldown > 0) { - this.portalCooldown = this.ai(); - } else { - double d0 = this.lastX - this.locX; - double d1 = this.lastZ - this.locZ; - - if (!this.world.isStatic && !this.an) { - this.aq = Direction.a(d0, d1); - } - - this.an = true; - } - } - - public int ai() { - return 300; - } - - public ItemStack[] getEquipment() { - return null; - } - - public void setEquipment(int i, ItemStack itemstack) {} - - public boolean isBurning() { - boolean flag = this.world != null && this.world.isStatic; - - return !this.fireProof && (this.fireTicks > 0 || flag && this.g(0)); - } - - public boolean am() { - return this.vehicle != null; - } - - public boolean isSneaking() { - return this.g(1); - } - - public void setSneaking(boolean flag) { - this.a(1, flag); - } - - public boolean isSprinting() { - return this.g(3); - } - - public void setSprinting(boolean flag) { - this.a(3, flag); - } - - public boolean isInvisible() { - return this.g(5); - } - - public void setInvisible(boolean flag) { - this.a(5, flag); - } - - public void e(boolean flag) { - this.a(4, flag); - } - - protected boolean g(int i) { - return (this.datawatcher.getByte(0) & 1 << i) != 0; - } - - protected void a(int i, boolean flag) { - byte b0 = this.datawatcher.getByte(0); - - if (flag) { - this.datawatcher.watch(0, Byte.valueOf((byte) (b0 | 1 << i))); - } else { - this.datawatcher.watch(0, Byte.valueOf((byte) (b0 & ~(1 << i)))); - } - } - - public int getAirTicks() { - return this.datawatcher.getShort(1); - } - - public void setAirTicks(int i) { - this.datawatcher.watch(1, Short.valueOf((short) i)); - } - - public void a(EntityLightning entitylightning) { - // CraftBukkit start - final org.bukkit.entity.Entity thisBukkitEntity = this.getBukkitEntity(); - final org.bukkit.entity.Entity stormBukkitEntity = entitylightning.getBukkitEntity(); - final PluginManager pluginManager = Bukkit.getPluginManager(); - - if (thisBukkitEntity instanceof Hanging) { - HangingBreakByEntityEvent hangingEvent = new HangingBreakByEntityEvent((Hanging) thisBukkitEntity, stormBukkitEntity); - PaintingBreakByEntityEvent paintingEvent = null; - - if (thisBukkitEntity instanceof Painting) { - paintingEvent = new PaintingBreakByEntityEvent((Painting) thisBukkitEntity, stormBukkitEntity); - } - - pluginManager.callEvent(hangingEvent); - - if (paintingEvent != null) { - paintingEvent.setCancelled(hangingEvent.isCancelled()); - pluginManager.callEvent(paintingEvent); - } - - if (hangingEvent.isCancelled() || (paintingEvent != null && paintingEvent.isCancelled())) { - return; - } - } - - if (this.fireProof) { - return; - } - CraftEventFactory.entityDamage = entitylightning; - if (!this.damageEntity(DamageSource.FIRE, 5.0F)) { - CraftEventFactory.entityDamage = null; - return; - } - // CraftBukkit end - - ++this.fireTicks; - if (this.fireTicks == 0) { - // CraftBukkit start - Call a combust event when lightning strikes - EntityCombustByEntityEvent entityCombustEvent = new EntityCombustByEntityEvent(stormBukkitEntity, thisBukkitEntity, 8); - pluginManager.callEvent(entityCombustEvent); - if (!entityCombustEvent.isCancelled()) { - this.setOnFire(entityCombustEvent.getDuration()); - } - // CraftBukkit end - } - } - - public void a(EntityLiving entityliving) {} - - protected boolean j(double d0, double d1, double d2) { - int i = MathHelper.floor(d0); - int j = MathHelper.floor(d1); - int k = MathHelper.floor(d2); - double d3 = d0 - (double) i; - double d4 = d1 - (double) j; - double d5 = d2 - (double) k; - List list = this.world.a(this.boundingBox); - - if (list.isEmpty() && !this.world.q(i, j, k)) { - return false; - } else { - boolean flag = !this.world.q(i - 1, j, k); - boolean flag1 = !this.world.q(i + 1, j, k); - boolean flag2 = !this.world.q(i, j - 1, k); - boolean flag3 = !this.world.q(i, j + 1, k); - boolean flag4 = !this.world.q(i, j, k - 1); - boolean flag5 = !this.world.q(i, j, k + 1); - byte b0 = 3; - double d6 = 9999.0D; - - if (flag && d3 < d6) { - d6 = d3; - b0 = 0; - } - - if (flag1 && 1.0D - d3 < d6) { - d6 = 1.0D - d3; - b0 = 1; - } - - if (flag3 && 1.0D - d4 < d6) { - d6 = 1.0D - d4; - b0 = 3; - } - - if (flag4 && d5 < d6) { - d6 = d5; - b0 = 4; - } - - if (flag5 && 1.0D - d5 < d6) { - d6 = 1.0D - d5; - b0 = 5; - } - - float f = this.random.nextFloat() * 0.2F + 0.1F; - - if (b0 == 0) { - this.motX = (double) (-f); - } - - if (b0 == 1) { - this.motX = (double) f; - } - - if (b0 == 2) { - this.motY = (double) (-f); - } - - if (b0 == 3) { - this.motY = (double) f; - } - - if (b0 == 4) { - this.motZ = (double) (-f); - } - - if (b0 == 5) { - this.motZ = (double) f; - } - - return true; - } - } - - public void as() { - this.I = true; - this.fallDistance = 0.0F; - } - - public String getName() { - String s = EntityTypes.b(this); - - if (s == null) { - s = "generic"; - } - - return LocaleI18n.get("entity." + s + ".name"); - } - - public Entity[] at() { - return null; - } - - public boolean i(Entity entity) { - return this == entity; - } - - public float getHeadRotation() { - return 0.0F; - } - - public boolean av() { - return true; - } - - public boolean j(Entity entity) { - return false; - } - - public String toString() { - return String.format("%s[\'%s\'/%d, l=\'%s\', x=%.2f, y=%.2f, z=%.2f]", new Object[] { this.getClass().getSimpleName(), this.getName(), 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 boolean isInvulnerable() { - return this.invulnerable; - } - - public void k(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.e(nbttagcompound); - this.f(nbttagcompound); - this.portalCooldown = entity.portalCooldown; - this.aq = entity.aq; - } - - public void b(int i) { - if (!this.world.isStatic && !this.dead) { - this.world.methodProfiler.a("changeDimension"); - MinecraftServer minecraftserver = MinecraftServer.getServer(); - // CraftBukkit start - Move logic into new function "teleportToLocation" - // int j = this.dimension; - WorldServer exitWorld = null; - if (this.dimension < CraftWorld.CUSTOM_DIMENSION_OFFSET) { // Plugins must specify exit from custom Bukkit worlds - // Only target existing worlds (compensate for allow-nether/allow-end as false) - for (WorldServer world : minecraftserver.worlds) { - if (world.dimension == i) { - exitWorld = world; - } - } - } - - Location enter = this.getBukkitEntity().getLocation(); - Location exit = exitWorld != null ? minecraftserver.getPlayerList().calculateTarget(enter, minecraftserver.getWorldServer(i)) : null; - boolean useTravelAgent = exitWorld != null && !(this.dimension == 1 && exitWorld.dimension == 1); // don't use agent for custom worlds or return from THE_END - - TravelAgent agent = exit != null ? (TravelAgent) ((CraftWorld) exit.getWorld()).getHandle().getTravelAgent() : org.bukkit.craftbukkit.CraftTravelAgent.DEFAULT; // return arbitrary TA to compensate for implementation dependent plugins - EntityPortalEvent event = new EntityPortalEvent(this.getBukkitEntity(), enter, exit, agent); - event.useTravelAgent(useTravelAgent); - event.getEntity().getServer().getPluginManager().callEvent(event); - if (event.isCancelled() || event.getTo() == null || event.getTo().getWorld() == null || !this.isAlive()) { - return; - } - exit = event.useTravelAgent() ? event.getPortalTravelAgent().findOrCreate(event.getTo()) : event.getTo(); - this.teleportTo(exit, true); - } - } - - public void teleportTo(Location exit, boolean portal) { - if (true) { - WorldServer worldserver = ((CraftWorld) this.getBukkitEntity().getLocation().getWorld()).getHandle(); - WorldServer worldserver1 = ((CraftWorld) exit.getWorld()).getHandle(); - int i = worldserver1.dimension; - // CraftBukkit end - - this.dimension = i; - /* CraftBukkit start - TODO: Check if we need this - if (j == 1 && i == 1) { - worldserver1 = minecraftserver.getWorldServer(0); - this.dimension = 0; - } - // CraftBukkit end */ - - this.world.kill(this); - this.dead = false; - this.world.methodProfiler.a("reposition"); - // CraftBukkit start - Ensure chunks are loaded in case TravelAgent is not used which would initially cause chunks to load during find/create - // minecraftserver.getPlayerList().a(this, j, worldserver, worldserver1); - boolean before = worldserver1.chunkProviderServer.forceChunkLoad; - worldserver1.chunkProviderServer.forceChunkLoad = true; - worldserver1.getMinecraftServer().getPlayerList().repositionEntity(this, exit, portal); - worldserver1.chunkProviderServer.forceChunkLoad = before; - // CraftBukkit end - this.world.methodProfiler.c("reloading"); - Entity entity = EntityTypes.createEntityByName(EntityTypes.b(this), worldserver1); - - if (entity != null) { - entity.a(this, true); - /* CraftBukkit start - We need to do this... - if (j == 1 && i == 1) { - ChunkCoordinates chunkcoordinates = worldserver1.getSpawn(); - - chunkcoordinates.y = this.world.i(chunkcoordinates.x, chunkcoordinates.z); - entity.setPositionRotation((double) chunkcoordinates.x, (double) chunkcoordinates.y, (double) chunkcoordinates.z, entity.yaw, entity.pitch); - } - // CraftBukkit end */ - worldserver1.addEntity(entity); - // CraftBukkit start - Forward the CraftEntity to the new entity - this.getBukkitEntity().setHandle(entity); - entity.bukkitEntity = this.getBukkitEntity(); - // CraftBukkit end - } - - this.dead = true; - this.world.methodProfiler.b(); - worldserver.i(); - worldserver1.i(); - this.world.methodProfiler.b(); - } - } - - public float a(Explosion explosion, World world, int i, int j, int k, Block block) { - return block.a(this); - } - - public boolean a(Explosion explosion, World world, int i, int j, int k, Block block, float f) { - return true; - } - - public int ax() { - return 3; - } - - public int ay() { - return this.aq; - } - - public boolean az() { - return false; - } - - public void a(CrashReportSystemDetails crashreportsystemdetails) { - crashreportsystemdetails.a("Entity Type", (Callable) (new CrashReportEntityType(this))); - crashreportsystemdetails.a("Entity ID", Integer.valueOf(this.id)); - crashreportsystemdetails.a("Entity Name", (Callable) (new CrashReportEntityName(this))); - crashreportsystemdetails.a("Entity\'s Exact location", String.format("%.2f, %.2f, %.2f", new Object[] { Double.valueOf(this.locX), Double.valueOf(this.locY), Double.valueOf(this.locZ)})); - crashreportsystemdetails.a("Entity\'s Block location", CrashReportSystemDetails.a(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ))); - crashreportsystemdetails.a("Entity\'s Momentum", String.format("%.2f, %.2f, %.2f", new Object[] { Double.valueOf(this.motX), Double.valueOf(this.motY), Double.valueOf(this.motZ)})); - } - - public UUID getUniqueID() { - return this.uniqueID; - } - - public boolean aC() { - return true; - } - - public IChatBaseComponent getScoreboardDisplayName() { - return new ChatComponentText(this.getName()); - } - - public void i(int i) {} -} diff --git a/src/main/java/net/minecraft/server/EntityAgeable.java b/src/main/java/net/minecraft/server/EntityAgeable.java deleted file mode 100644 index 36ed8316..00000000 --- a/src/main/java/net/minecraft/server/EntityAgeable.java +++ /dev/null @@ -1,124 +0,0 @@ -package net.minecraft.server; - -public abstract class EntityAgeable extends EntityCreature { - - private float bp = -1.0F; - private float bq; - public boolean ageLocked = false; // CraftBukkit - - public EntityAgeable(World world) { - super(world); - } - - public abstract EntityAgeable createChild(EntityAgeable entityageable); - - public boolean a(EntityHuman entityhuman) { - ItemStack itemstack = entityhuman.inventory.getItemInHand(); - - if (itemstack != null && itemstack.getItem() == Items.MONSTER_EGG) { - if (!this.world.isStatic) { - Class oclass = EntityTypes.a(itemstack.getData()); - - if (oclass != null && oclass.isAssignableFrom(this.getClass())) { - EntityAgeable entityageable = this.createChild(this); - - if (entityageable != null) { - entityageable.setAge(-24000); - entityageable.setPositionRotation(this.locX, this.locY, this.locZ, 0.0F, 0.0F); - this.world.addEntity(entityageable, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG); // CraftBukkit - if (itemstack.hasName()) { - entityageable.setCustomName(itemstack.getName()); - } - - if (!entityhuman.abilities.canInstantlyBuild) { - --itemstack.count; - if (itemstack.count == 0) { // CraftBukkit - allow less than 0 stacks as "infinite" - entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, (ItemStack) null); - } - } - } - } - } - - return true; - } else { - return false; - } - } - - protected void c() { - super.c(); - this.datawatcher.a(12, new Integer(0)); - } - - public int getAge() { - return this.datawatcher.getInt(12); - } - - public void a(int i) { - int j = this.getAge(); - - j += i * 20; - if (j > 0) { - j = 0; - } - - this.setAge(j); - } - - public void setAge(int i) { - this.datawatcher.watch(12, Integer.valueOf(i)); - this.a(this.isBaby()); - } - - public void b(NBTTagCompound nbttagcompound) { - super.b(nbttagcompound); - nbttagcompound.setInt("Age", this.getAge()); - nbttagcompound.setBoolean("AgeLocked", this.ageLocked); // CraftBukkit - } - - public void a(NBTTagCompound nbttagcompound) { - super.a(nbttagcompound); - this.setAge(nbttagcompound.getInt("Age")); - this.ageLocked = nbttagcompound.getBoolean("AgeLocked"); // CraftBukkit - } - - public void e() { - super.e(); - if (this.world.isStatic || this.ageLocked) { // CraftBukkit - this.a(this.isBaby()); - } else { - int i = this.getAge(); - - if (i < 0) { - ++i; - this.setAge(i); - } else if (i > 0) { - --i; - this.setAge(i); - } - } - } - - public boolean isBaby() { - return this.getAge() < 0; - } - - public void a(boolean flag) { - this.a(flag ? 0.5F : 1.0F); - } - - protected final void a(float f, float f1) { - boolean flag = this.bp > 0.0F; - - this.bp = f; - this.bq = f1; - if (!flag) { - this.a(1.0F); - } - } - - protected final void a(float f) { - super.a(this.bp * f, this.bq * f); - } -} diff --git a/src/main/java/net/minecraft/server/EntityArrow.java b/src/main/java/net/minecraft/server/EntityArrow.java deleted file mode 100644 index 88b07510..00000000 --- a/src/main/java/net/minecraft/server/EntityArrow.java +++ /dev/null @@ -1,462 +0,0 @@ -package net.minecraft.server; - -import java.util.List; - -// CraftBukkit start -import org.bukkit.entity.LivingEntity; -import org.bukkit.event.entity.EntityCombustByEntityEvent; -import org.bukkit.event.player.PlayerPickupItemEvent; -// CraftBukkit end - -public class EntityArrow extends Entity implements IProjectile { - - private int d = -1; - private int e = -1; - private int f = -1; - private Block g; - private int h; - private boolean inGround; - public int fromPlayer; - public int shake; - public Entity shooter; - private int at; - private int au; - private double damage = 2.0D; - public int knockbackStrength; // CraftBukkit - private -> public - - public EntityArrow(World world) { - super(world); - this.j = 10.0D; - this.a(0.5F, 0.5F); - } - - public EntityArrow(World world, double d0, double d1, double d2) { - super(world); - this.j = 10.0D; - this.a(0.5F, 0.5F); - this.setPosition(d0, d1, d2); - this.height = 0.0F; - } - - public EntityArrow(World world, EntityLiving entityliving, EntityLiving entityliving1, float f, float f1) { - super(world); - this.j = 10.0D; - this.shooter = entityliving; - this.projectileSource = (LivingEntity) entityliving.getBukkitEntity(); // CraftBukkit - if (entityliving instanceof EntityHuman) { - this.fromPlayer = 1; - } - - this.locY = entityliving.locY + (double) entityliving.getHeadHeight() - 0.10000000149011612D; - double d0 = entityliving1.locX - entityliving.locX; - double d1 = entityliving1.boundingBox.b + (double) (entityliving1.length / 3.0F) - this.locY; - double d2 = entityliving1.locZ - entityliving.locZ; - double d3 = (double) MathHelper.sqrt(d0 * d0 + d2 * d2); - - if (d3 >= 1.0E-7D) { - float f2 = (float) (Math.atan2(d2, d0) * 180.0D / 3.1415927410125732D) - 90.0F; - float f3 = (float) (-(Math.atan2(d1, d3) * 180.0D / 3.1415927410125732D)); - double d4 = d0 / d3; - double d5 = d2 / d3; - - this.setPositionRotation(entityliving.locX + d4, this.locY, entityliving.locZ + d5, f2, f3); - this.height = 0.0F; - float f4 = (float) d3 * 0.2F; - - this.shoot(d0, d1 + (double) f4, d2, f, f1); - } - } - - public EntityArrow(World world, EntityLiving entityliving, float f) { - super(world); - this.j = 10.0D; - this.shooter = entityliving; - this.projectileSource = (LivingEntity) entityliving.getBukkitEntity(); // CraftBukkit - if (entityliving instanceof EntityHuman) { - this.fromPlayer = 1; - } - - this.a(0.5F, 0.5F); - this.setPositionRotation(entityliving.locX, entityliving.locY + (double) entityliving.getHeadHeight(), entityliving.locZ, entityliving.yaw, entityliving.pitch); - this.locX -= (double) (MathHelper.cos(this.yaw / 180.0F * 3.1415927F) * 0.16F); - this.locY -= 0.10000000149011612D; - this.locZ -= (double) (MathHelper.sin(this.yaw / 180.0F * 3.1415927F) * 0.16F); - this.setPosition(this.locX, this.locY, this.locZ); - this.height = 0.0F; - this.motX = (double) (-MathHelper.sin(this.yaw / 180.0F * 3.1415927F) * MathHelper.cos(this.pitch / 180.0F * 3.1415927F)); - this.motZ = (double) (MathHelper.cos(this.yaw / 180.0F * 3.1415927F) * MathHelper.cos(this.pitch / 180.0F * 3.1415927F)); - this.motY = (double) (-MathHelper.sin(this.pitch / 180.0F * 3.1415927F)); - this.shoot(this.motX, this.motY, this.motZ, f * 1.5F, 1.0F); - } - - protected void c() { - this.datawatcher.a(16, Byte.valueOf((byte) 0)); - } - - 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; - d1 /= (double) f2; - d2 /= (double) f2; - d0 += this.random.nextGaussian() * (double) (this.random.nextBoolean() ? -1 : 1) * 0.007499999832361937D * (double) f1; - d1 += this.random.nextGaussian() * (double) (this.random.nextBoolean() ? -1 : 1) * 0.007499999832361937D * (double) f1; - d2 += this.random.nextGaussian() * (double) (this.random.nextBoolean() ? -1 : 1) * 0.007499999832361937D * (double) f1; - d0 *= (double) f; - d1 *= (double) f; - d2 *= (double) f; - this.motX = d0; - this.motY = d1; - this.motZ = d2; - float f3 = MathHelper.sqrt(d0 * d0 + d2 * d2); - - this.lastYaw = this.yaw = (float) (Math.atan2(d0, d2) * 180.0D / 3.1415927410125732D); - this.lastPitch = this.pitch = (float) (Math.atan2(d1, (double) f3) * 180.0D / 3.1415927410125732D); - this.at = 0; - } - - public void h() { - super.h(); - if (this.lastPitch == 0.0F && this.lastYaw == 0.0F) { - float f = MathHelper.sqrt(this.motX * this.motX + this.motZ * this.motZ); - - this.lastYaw = this.yaw = (float) (Math.atan2(this.motX, this.motZ) * 180.0D / 3.1415927410125732D); - this.lastPitch = this.pitch = (float) (Math.atan2(this.motY, (double) f) * 180.0D / 3.1415927410125732D); - } - - Block block = this.world.getType(this.d, this.e, this.f); - - if (block.getMaterial() != Material.AIR) { - block.updateShape(this.world, this.d, this.e, this.f); - AxisAlignedBB axisalignedbb = block.a(this.world, this.d, this.e, this.f); - - if (axisalignedbb != null && axisalignedbb.a(Vec3D.a(this.locX, this.locY, this.locZ))) { - this.inGround = true; - } - } - - if (this.shake > 0) { - --this.shake; - } - - if (this.inGround) { - int i = this.world.getData(this.d, this.e, this.f); - - if (block == this.g && i == this.h) { - ++this.at; - if (this.at == 1200) { - this.die(); - } - } else { - this.inGround = false; - this.motX *= (double) (this.random.nextFloat() * 0.2F); - this.motY *= (double) (this.random.nextFloat() * 0.2F); - this.motZ *= (double) (this.random.nextFloat() * 0.2F); - this.at = 0; - this.au = 0; - } - } else { - ++this.au; - Vec3D vec3d = Vec3D.a(this.locX, this.locY, this.locZ); - Vec3D vec3d1 = Vec3D.a(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ); - MovingObjectPosition movingobjectposition = this.world.rayTrace(vec3d, vec3d1, false, true, false); - - vec3d = Vec3D.a(this.locX, this.locY, this.locZ); - vec3d1 = Vec3D.a(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ); - if (movingobjectposition != null) { - vec3d1 = Vec3D.a(movingobjectposition.pos.a, movingobjectposition.pos.b, movingobjectposition.pos.c); - } - - Entity entity = null; - List list = this.world.getEntities(this, this.boundingBox.a(this.motX, this.motY, this.motZ).grow(1.0D, 1.0D, 1.0D)); - double d0 = 0.0D; - - int j; - float f1; - - for (j = 0; j < list.size(); ++j) { - Entity entity1 = (Entity) list.get(j); - - if (entity1.R() && (entity1 != this.shooter || this.au >= 5)) { - f1 = 0.3F; - AxisAlignedBB axisalignedbb1 = entity1.boundingBox.grow((double) f1, (double) f1, (double) f1); - MovingObjectPosition movingobjectposition1 = axisalignedbb1.a(vec3d, vec3d1); - - if (movingobjectposition1 != null) { - double d1 = vec3d.distanceSquared(movingobjectposition1.pos); // CraftBukkit - distance efficiency - - if (d1 < d0 || d0 == 0.0D) { - entity = entity1; - d0 = d1; - } - } - } - } - - if (entity != null) { - movingobjectposition = new MovingObjectPosition(entity); - } - - if (movingobjectposition != null && movingobjectposition.entity != null && movingobjectposition.entity instanceof EntityHuman) { - EntityHuman entityhuman = (EntityHuman) movingobjectposition.entity; - - if (entityhuman.abilities.isInvulnerable || this.shooter instanceof EntityHuman && !((EntityHuman) this.shooter).a(entityhuman)) { - movingobjectposition = null; - } - } - - float f2; - float f3; - - if (movingobjectposition != null) { - org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this); // CraftBukkit - Call event - - if (movingobjectposition.entity != null) { - f2 = MathHelper.sqrt(this.motX * this.motX + this.motY * this.motY + this.motZ * this.motZ); - int k = MathHelper.f((double) f2 * this.damage); - - if (this.isCritical()) { - k += this.random.nextInt(k / 2 + 2); - } - - DamageSource damagesource = null; - - if (this.shooter == null) { - damagesource = DamageSource.arrow(this, this); - } else { - damagesource = DamageSource.arrow(this, this.shooter); - } - - // CraftBukkit start - Moved damage call - if (movingobjectposition.entity.damageEntity(damagesource, k)) { - if (this.isBurning() && !(movingobjectposition.entity instanceof EntityEnderman) && (!(movingobjectposition.entity instanceof EntityPlayer) || !(this.shooter instanceof EntityPlayer) || this.world.pvpMode)) { // CraftBukkit - abide by pvp setting if destination is a player - EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), 5); - org.bukkit.Bukkit.getPluginManager().callEvent(combustEvent); - - if (!combustEvent.isCancelled()) { - movingobjectposition.entity.setOnFire(combustEvent.getDuration()); - } - // CraftBukkit end - } - - // if (movingobjectposition.entity.damageEntity(damagesource, (float) k)) { // CraftBukkit - moved up - if (movingobjectposition.entity instanceof EntityLiving) { - EntityLiving entityliving = (EntityLiving) movingobjectposition.entity; - - if (!this.world.isStatic) { - entityliving.p(entityliving.aZ() + 1); - } - - if (this.knockbackStrength > 0) { - f3 = MathHelper.sqrt(this.motX * this.motX + this.motZ * this.motZ); - if (f3 > 0.0F) { - movingobjectposition.entity.g(this.motX * (double) this.knockbackStrength * 0.6000000238418579D / (double) f3, 0.1D, this.motZ * (double) this.knockbackStrength * 0.6000000238418579D / (double) f3); - } - } - - if (this.shooter != null && this.shooter instanceof EntityLiving) { - EnchantmentManager.a(entityliving, this.shooter); - EnchantmentManager.b((EntityLiving) this.shooter, entityliving); - } - - if (this.shooter != null && movingobjectposition.entity != this.shooter && movingobjectposition.entity instanceof EntityHuman && this.shooter instanceof EntityPlayer) { - ((EntityPlayer) this.shooter).playerConnection.sendPacket(new PacketPlayOutGameStateChange(6, 0.0F)); - } - } - - this.makeSound("random.bowhit", 1.0F, 1.2F / (this.random.nextFloat() * 0.2F + 0.9F)); - if (!(movingobjectposition.entity instanceof EntityEnderman)) { - this.die(); - } - } else { - this.motX *= -0.10000000149011612D; - this.motY *= -0.10000000149011612D; - this.motZ *= -0.10000000149011612D; - this.yaw += 180.0F; - this.lastYaw += 180.0F; - this.au = 0; - } - } else { - this.d = movingobjectposition.b; - this.e = movingobjectposition.c; - this.f = movingobjectposition.d; - this.g = this.world.getType(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)); - 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; - this.locZ -= this.motZ / (double) f2 * 0.05000000074505806D; - this.makeSound("random.bowhit", 1.0F, 1.2F / (this.random.nextFloat() * 0.2F + 0.9F)); - this.inGround = true; - this.shake = 7; - this.setCritical(false); - if (this.g.getMaterial() != Material.AIR) { - this.g.a(this.world, this.d, this.e, this.f, (Entity) this); - } - } - } - - if (this.isCritical()) { - for (j = 0; j < 4; ++j) { - this.world.addParticle("crit", this.locX + this.motX * (double) j / 4.0D, this.locY + this.motY * (double) j / 4.0D, this.locZ + this.motZ * (double) j / 4.0D, -this.motX, -this.motY + 0.2D, -this.motZ); - } - } - - this.locX += this.motX; - this.locY += this.motY; - this.locZ += this.motZ; - f2 = MathHelper.sqrt(this.motX * this.motX + this.motZ * this.motZ); - this.yaw = (float) (Math.atan2(this.motX, this.motZ) * 180.0D / 3.1415927410125732D); - - for (this.pitch = (float) (Math.atan2(this.motY, (double) f2) * 180.0D / 3.1415927410125732D); this.pitch - this.lastPitch < -180.0F; this.lastPitch -= 360.0F) { - ; - } - - while (this.pitch - this.lastPitch >= 180.0F) { - this.lastPitch += 360.0F; - } - - while (this.yaw - this.lastYaw < -180.0F) { - this.lastYaw -= 360.0F; - } - - while (this.yaw - this.lastYaw >= 180.0F) { - this.lastYaw += 360.0F; - } - - this.pitch = this.lastPitch + (this.pitch - this.lastPitch) * 0.2F; - this.yaw = this.lastYaw + (this.yaw - this.lastYaw) * 0.2F; - float f4 = 0.99F; - - f1 = 0.05F; - if (this.M()) { - for (int l = 0; l < 4; ++l) { - f3 = 0.25F; - 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); - } - - f4 = 0.8F; - } - - if (this.L()) { - this.extinguish(); - } - - this.motX *= (double) f4; - this.motY *= (double) f4; - this.motZ *= (double) f4; - this.motY -= (double) f1; - this.setPosition(this.locX, this.locY, this.locZ); - this.I(); - } - } - - public void b(NBTTagCompound nbttagcompound) { - nbttagcompound.setShort("xTile", (short) this.d); - nbttagcompound.setShort("yTile", (short) this.e); - nbttagcompound.setShort("zTile", (short) this.f); - nbttagcompound.setShort("life", (short) this.at); - nbttagcompound.setByte("inTile", (byte) Block.getId(this.g)); - nbttagcompound.setByte("inData", (byte) this.h); - nbttagcompound.setByte("shake", (byte) this.shake); - nbttagcompound.setByte("inGround", (byte) (this.inGround ? 1 : 0)); - nbttagcompound.setByte("pickup", (byte) this.fromPlayer); - nbttagcompound.setDouble("damage", this.damage); - } - - public void a(NBTTagCompound nbttagcompound) { - this.d = nbttagcompound.getShort("xTile"); - this.e = nbttagcompound.getShort("yTile"); - this.f = nbttagcompound.getShort("zTile"); - this.at = nbttagcompound.getShort("life"); - this.g = Block.getById(nbttagcompound.getByte("inTile") & 255); - this.h = nbttagcompound.getByte("inData") & 255; - this.shake = nbttagcompound.getByte("shake") & 255; - this.inGround = nbttagcompound.getByte("inGround") == 1; - if (nbttagcompound.hasKeyOfType("damage", 99)) { - this.damage = nbttagcompound.getDouble("damage"); - } - - if (nbttagcompound.hasKeyOfType("pickup", 99)) { - this.fromPlayer = nbttagcompound.getByte("pickup"); - } else if (nbttagcompound.hasKeyOfType("player", 99)) { - this.fromPlayer = nbttagcompound.getBoolean("player") ? 1 : 0; - } - } - - public void b_(EntityHuman entityhuman) { - if (!this.world.isStatic && this.inGround && this.shake <= 0) { - // CraftBukkit start - ItemStack itemstack = new ItemStack(Items.ARROW); - 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); - // event.setCancelled(!entityhuman.canPickUpLoot); TODO - this.world.getServer().getPluginManager().callEvent(event); - - if (event.isCancelled()) { - return; - } - } - // CraftBukkit end - - boolean flag = this.fromPlayer == 1 || this.fromPlayer == 2 && entityhuman.abilities.canInstantlyBuild; - - if (this.fromPlayer == 1 && !entityhuman.inventory.pickup(new ItemStack(Items.ARROW, 1))) { - flag = false; - } - - if (flag) { - this.makeSound("random.pop", 0.2F, ((this.random.nextFloat() - this.random.nextFloat()) * 0.7F + 1.0F) * 2.0F); - entityhuman.receive(this, 1); - this.die(); - } - } - } - - protected boolean g_() { - return false; - } - - public void b(double d0) { - this.damage = d0; - } - - public double e() { - return this.damage; - } - - public void setKnockbackStrength(int i) { - this.knockbackStrength = i; - } - - public boolean av() { - return false; - } - - public void setCritical(boolean flag) { - byte b0 = this.datawatcher.getByte(16); - - if (flag) { - this.datawatcher.watch(16, Byte.valueOf((byte) (b0 | 1))); - } else { - this.datawatcher.watch(16, Byte.valueOf((byte) (b0 & -2))); - } - } - - public boolean isCritical() { - byte b0 = this.datawatcher.getByte(16); - - return (b0 & 1) != 0; - } - - // CraftBukkit start - public boolean isInGround() { - return inGround; - } - // CraftBukkit end -} diff --git a/src/main/java/net/minecraft/server/EntityBoat.java b/src/main/java/net/minecraft/server/EntityBoat.java deleted file mode 100644 index 8a3ea635..00000000 --- a/src/main/java/net/minecraft/server/EntityBoat.java +++ /dev/null @@ -1,498 +0,0 @@ -package net.minecraft.server; - -import java.util.List; - -// CraftBukkit start -import org.bukkit.Location; -import org.bukkit.craftbukkit.event.CraftEventFactory; -import org.bukkit.entity.Vehicle; -import org.bukkit.event.vehicle.VehicleDamageEvent; -import org.bukkit.event.vehicle.VehicleDestroyEvent; -import org.bukkit.event.vehicle.VehicleEntityCollisionEvent; -import org.bukkit.event.vehicle.VehicleMoveEvent; -// CraftBukkit end - -public class EntityBoat extends Entity { - - private boolean a; - private double b; - private int c; - private double d; - private double e; - private double f; - private double g; - private double h; - - // CraftBukkit start - public double maxSpeed = 0.4D; - public double occupiedDeceleration = 0.2D; - public double unoccupiedDeceleration = -1; - public boolean landBoats = false; - - @Override - public void collide(Entity entity) { - org.bukkit.entity.Entity hitEntity = (entity == null) ? null : entity.getBukkitEntity(); - - VehicleEntityCollisionEvent event = new VehicleEntityCollisionEvent((Vehicle) this.getBukkitEntity(), hitEntity); - this.world.getServer().getPluginManager().callEvent(event); - - if (event.isCancelled()) { - return; - } - - super.collide(entity); - } - // CraftBukkit end - - public EntityBoat(World world) { - super(world); - this.a = true; - this.b = 0.07D; - this.k = true; - this.a(1.5F, 0.6F); - this.height = this.length / 2.0F; - } - - protected boolean g_() { - return false; - } - - protected void c() { - this.datawatcher.a(17, new Integer(0)); - this.datawatcher.a(18, new Integer(1)); - this.datawatcher.a(19, new Float(0.0F)); - } - - public AxisAlignedBB h(Entity entity) { - return entity.boundingBox; - } - - public AxisAlignedBB J() { - return this.boundingBox; - } - - public boolean S() { - return true; - } - - public EntityBoat(World world, double d0, double d1, double d2) { - this(world); - this.setPosition(d0, d1 + (double) this.height, d2); - this.motX = 0.0D; - this.motY = 0.0D; - this.motZ = 0.0D; - this.lastX = d0; - this.lastY = d1; - this.lastZ = d2; - - this.world.getServer().getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleCreateEvent((Vehicle) this.getBukkitEntity())); // CraftBukkit - } - - public double ae() { - return (double) this.length * 0.0D - 0.30000001192092896D; - } - - public boolean damageEntity(DamageSource damagesource, float f) { - if (this.isInvulnerable()) { - return false; - } else if (!this.world.isStatic && !this.dead) { - // CraftBukkit start - Vehicle vehicle = (Vehicle) this.getBukkitEntity(); - org.bukkit.entity.Entity attacker = (damagesource.getEntity() == null) ? null : damagesource.getEntity().getBukkitEntity(); - - VehicleDamageEvent event = new VehicleDamageEvent(vehicle, attacker, (double) f); - this.world.getServer().getPluginManager().callEvent(event); - - if (event.isCancelled()) { - return true; - } - // f = event.getDamage(); // TODO Why don't we do this? - // CraftBukkit end - - this.c(-this.i()); - this.a(10); - this.setDamage(this.getDamage() + f * 10.0F); - this.Q(); - boolean flag = damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).abilities.canInstantlyBuild; - - if (flag || this.getDamage() > 40.0F) { - // CraftBukkit start - VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, attacker); - this.world.getServer().getPluginManager().callEvent(destroyEvent); - - if (destroyEvent.isCancelled()) { - this.setDamage(40F); // Maximize damage so this doesn't get triggered again right away - return true; - } - // CraftBukkit end - - if (this.passenger != null) { - this.passenger.mount(this); - } - - if (!flag) { - this.a(Items.BOAT, 1, 0.0F); - } - - this.die(); - } - - return true; - } else { - return true; - } - } - - public boolean R() { - return !this.dead; - } - - public void h() { - // CraftBukkit start - double prevX = this.locX; - double prevY = this.locY; - double prevZ = this.locZ; - float prevYaw = this.yaw; - float prevPitch = this.pitch; - // CraftBukkit end - - super.h(); - if (this.f() > 0) { - this.a(this.f() - 1); - } - - if (this.getDamage() > 0.0F) { - this.setDamage(this.getDamage() - 1.0F); - } - - this.lastX = this.locX; - this.lastY = this.locY; - this.lastZ = this.locZ; - byte b0 = 5; - double d0 = 0.0D; - - for (int i = 0; i < b0; ++i) { - double d1 = this.boundingBox.b + (this.boundingBox.e - this.boundingBox.b) * (double) (i + 0) / (double) b0 - 0.125D; - double d2 = this.boundingBox.b + (this.boundingBox.e - this.boundingBox.b) * (double) (i + 1) / (double) b0 - 0.125D; - AxisAlignedBB axisalignedbb = AxisAlignedBB.a(this.boundingBox.a, d1, this.boundingBox.c, this.boundingBox.d, d2, this.boundingBox.f); - - if (this.world.b(axisalignedbb, Material.WATER)) { - d0 += 1.0D / (double) b0; - } - } - - double d3 = Math.sqrt(this.motX * this.motX + this.motZ * this.motZ); - double d4; - double d5; - int j; - - if (d3 > 0.26249999999999996D) { - d4 = Math.cos((double) this.yaw * 3.141592653589793D / 180.0D); - d5 = Math.sin((double) this.yaw * 3.141592653589793D / 180.0D); - - for (j = 0; (double) j < 1.0D + d3 * 60.0D; ++j) { - double d6 = (double) (this.random.nextFloat() * 2.0F - 1.0F); - double d7 = (double) (this.random.nextInt(2) * 2 - 1) * 0.7D; - double d8; - double d9; - - if (this.random.nextBoolean()) { - d8 = this.locX - d4 * d6 * 0.8D + d5 * d7; - d9 = this.locZ - d5 * d6 * 0.8D - d4 * d7; - this.world.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.addParticle("splash", d8, this.locY - 0.125D, d9, this.motX, this.motY, this.motZ); - } - } - } - - double d10; - double d11; - - if (this.world.isStatic && this.a) { - if (this.c > 0) { - d4 = this.locX + (this.d - this.locX) / (double) this.c; - d5 = this.locY + (this.e - this.locY) / (double) this.c; - d10 = this.locZ + (this.f - this.locZ) / (double) this.c; - d11 = MathHelper.g(this.g - (double) this.yaw); - this.yaw = (float) ((double) this.yaw + d11 / (double) this.c); - this.pitch = (float) ((double) this.pitch + (this.h - (double) this.pitch) / (double) this.c); - --this.c; - this.setPosition(d4, d5, d10); - this.b(this.yaw, this.pitch); - } else { - d4 = this.locX + this.motX; - d5 = this.locY + this.motY; - d10 = this.locZ + this.motZ; - this.setPosition(d4, d5, d10); - if (this.onGround) { - this.motX *= 0.5D; - this.motY *= 0.5D; - this.motZ *= 0.5D; - } - - this.motX *= 0.9900000095367432D; - this.motY *= 0.949999988079071D; - this.motZ *= 0.9900000095367432D; - } - } else { - if (d0 < 1.0D) { - d4 = d0 * 2.0D - 1.0D; - this.motY += 0.03999999910593033D * d4; - } else { - if (this.motY < 0.0D) { - this.motY /= 2.0D; - } - - this.motY += 0.007000000216066837D; - } - - if (this.passenger != null && this.passenger instanceof EntityLiving) { - EntityLiving entityliving = (EntityLiving) this.passenger; - float f = this.passenger.yaw + -entityliving.bd * 90.0F; - - this.motX += -Math.sin((double) (f * 3.1415927F / 180.0F)) * this.b * (double) entityliving.be * 0.05000000074505806D; - this.motZ += Math.cos((double) (f * 3.1415927F / 180.0F)) * this.b * (double) entityliving.be * 0.05000000074505806D; - } - // CraftBukkit start - Support unoccupied deceleration - else if (unoccupiedDeceleration >= 0) { - this.motX *= unoccupiedDeceleration; - this.motZ *= unoccupiedDeceleration; - // Kill lingering speed - if (motX <= 0.00001) { - motX = 0; - } - if (motZ <= 0.00001) { - motZ = 0; - } - } - // CraftBukkit end - - d4 = Math.sqrt(this.motX * this.motX + this.motZ * this.motZ); - if (d4 > 0.35D) { - d5 = 0.35D / d4; - this.motX *= d5; - this.motZ *= d5; - d4 = 0.35D; - } - - if (d4 > d3 && this.b < 0.35D) { - this.b += (0.35D - this.b) / 35.0D; - if (this.b > 0.35D) { - this.b = 0.35D; - } - } else { - this.b -= (this.b - 0.07D) / 35.0D; - if (this.b < 0.07D) { - this.b = 0.07D; - } - } - - int k; - - for (k = 0; k < 4; ++k) { - int l = MathHelper.floor(this.locX + ((double) (k % 2) - 0.5D) * 0.8D); - - j = MathHelper.floor(this.locZ + ((double) (k / 2) - 0.5D) * 0.8D); - - for (int i1 = 0; i1 < 2; ++i1) { - int j1 = MathHelper.floor(this.locY) + i1; - Block block = this.world.getType(l, j1, j); - - if (block == Blocks.SNOW) { - // CraftBukkit start - if (CraftEventFactory.callEntityChangeBlockEvent(this, l, j1, j, Blocks.AIR, 0).isCancelled()) { - continue; - } - // CraftBukkit end - this.world.setAir(l, j1, j); - this.positionChanged = false; - } else if (block == Blocks.WATER_LILY) { - // CraftBukkit start - if (CraftEventFactory.callEntityChangeBlockEvent(this, l, j1, j, Blocks.AIR, 0).isCancelled()) { - continue; - } - // CraftBukkit end - this.world.setAir(l, j1, j, true); - this.positionChanged = false; - } - } - } - - if (this.onGround && !this.landBoats) { // CraftBukkit - this.motX *= 0.5D; - this.motY *= 0.5D; - this.motZ *= 0.5D; - } - - this.move(this.motX, this.motY, this.motZ); - if (this.positionChanged && d3 > 0.2D) { - if (!this.world.isStatic && !this.dead) { - // CraftBukkit start - Vehicle vehicle = (Vehicle) this.getBukkitEntity(); - VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, null); - this.world.getServer().getPluginManager().callEvent(destroyEvent); - if (!destroyEvent.isCancelled()) { - this.die(); - - for (k = 0; k < 3; ++k) { - this.a(Item.getItemOf(Blocks.WOOD), 1, 0.0F); - } - - for (k = 0; k < 2; ++k) { - this.a(Items.STICK, 1, 0.0F); - } - } - // CraftBukkit end - } - } else { - this.motX *= 0.9900000095367432D; - this.motY *= 0.949999988079071D; - this.motZ *= 0.9900000095367432D; - } - - this.pitch = 0.0F; - d5 = (double) this.yaw; - d10 = this.lastX - this.locX; - d11 = this.lastZ - this.locZ; - if (d10 * d10 + d11 * d11 > 0.001D) { - d5 = (double) ((float) (Math.atan2(d11, d10) * 180.0D / 3.141592653589793D)); - } - - double d12 = MathHelper.g(d5 - (double) this.yaw); - - if (d12 > 20.0D) { - d12 = 20.0D; - } - - if (d12 < -20.0D) { - d12 = -20.0D; - } - - this.yaw = (float) ((double) this.yaw + d12); - this.b(this.yaw, this.pitch); - - // CraftBukkit start - org.bukkit.Server server = this.world.getServer(); - org.bukkit.World bworld = this.world.getWorld(); - - Location from = new Location(bworld, prevX, prevY, prevZ, prevYaw, prevPitch); - Location to = new Location(bworld, this.locX, this.locY, this.locZ, this.yaw, this.pitch); - Vehicle vehicle = (Vehicle) this.getBukkitEntity(); - - server.getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleUpdateEvent(vehicle)); - - if (!from.equals(to)) { - VehicleMoveEvent event = new VehicleMoveEvent(vehicle, from, to); - server.getPluginManager().callEvent(event); - } - // CraftBukkit end - - if (!this.world.isStatic) { - List list = this.world.getEntities(this, this.boundingBox.grow(0.20000000298023224D, 0.0D, 0.20000000298023224D)); - - if (list != null && !list.isEmpty()) { - for (int k1 = 0; k1 < list.size(); ++k1) { - Entity entity = (Entity) list.get(k1); - - if (entity != this.passenger && entity.S() && entity instanceof EntityBoat) { - entity.collide(this); - } - } - } - - if (this.passenger != null && this.passenger.dead) { - this.passenger.vehicle = null; // CraftBukkit - this.passenger = null; - } - } - } - } - - public void ac() { - if (this.passenger != null) { - double d0 = Math.cos((double) this.yaw * 3.141592653589793D / 180.0D) * 0.4D; - double d1 = Math.sin((double) this.yaw * 3.141592653589793D / 180.0D) * 0.4D; - - this.passenger.setPosition(this.locX + d0, this.locY + this.ae() + this.passenger.ad(), this.locZ + d1); - } - } - - protected void b(NBTTagCompound nbttagcompound) {} - - protected void a(NBTTagCompound nbttagcompound) {} - - public boolean c(EntityHuman entityhuman) { - if (this.passenger != null && this.passenger instanceof EntityHuman && this.passenger != entityhuman) { - return true; - } else { - if (!this.world.isStatic) { - entityhuman.mount(this); - } - - return true; - } - } - - protected void a(double d0, boolean flag) { - int i = MathHelper.floor(this.locX); - int j = MathHelper.floor(this.locY); - int k = MathHelper.floor(this.locZ); - - if (flag) { - if (this.fallDistance > 3.0F) { - this.b(this.fallDistance); - if (!this.world.isStatic && !this.dead) { - // CraftBukkit start - Vehicle vehicle = (Vehicle) this.getBukkitEntity(); - VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, null); - this.world.getServer().getPluginManager().callEvent(destroyEvent); - if (!destroyEvent.isCancelled()) { - this.die(); - - int l; - - for (l = 0; l < 3; ++l) { - this.a(Item.getItemOf(Blocks.WOOD), 1, 0.0F); - } - - for (l = 0; l < 2; ++l) { - this.a(Items.STICK, 1, 0.0F); - } - } - // CraftBukkit end - } - - this.fallDistance = 0.0F; - } - } else if (this.world.getType(i, j - 1, k).getMaterial() != Material.WATER && d0 < 0.0D) { - this.fallDistance = (float) ((double) this.fallDistance - d0); - } - } - - public void setDamage(float f) { - this.datawatcher.watch(19, Float.valueOf(f)); - } - - public float getDamage() { - return this.datawatcher.getFloat(19); - } - - public void a(int i) { - this.datawatcher.watch(17, Integer.valueOf(i)); - } - - public int f() { - return this.datawatcher.getInt(17); - } - - public void c(int i) { - this.datawatcher.watch(18, Integer.valueOf(i)); - } - - public int i() { - 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 deleted file mode 100644 index a5a5ab5e..00000000 --- a/src/main/java/net/minecraft/server/EntityChicken.java +++ /dev/null @@ -1,158 +0,0 @@ -package net.minecraft.server; - -public class EntityChicken extends EntityAnimal { - - public float bp; - public float bq; - public float br; - public float bs; - public float bt = 1.0F; - public int bu; - public boolean bv; - - public EntityChicken(World world) { - super(world); - this.a(0.3F, 0.7F); - this.bu = this.random.nextInt(6000) + 6000; - this.goalSelector.a(0, new PathfinderGoalFloat(this)); - this.goalSelector.a(1, new PathfinderGoalPanic(this, 1.4D)); - this.goalSelector.a(2, new PathfinderGoalBreed(this, 1.0D)); - this.goalSelector.a(3, new PathfinderGoalTempt(this, 1.0D, Items.SEEDS, false)); - this.goalSelector.a(4, new PathfinderGoalFollowParent(this, 1.1D)); - this.goalSelector.a(5, new PathfinderGoalRandomStroll(this, 1.0D)); - this.goalSelector.a(6, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 6.0F)); - this.goalSelector.a(7, new PathfinderGoalRandomLookaround(this)); - } - - public boolean bk() { - return true; - } - - protected void aD() { - super.aD(); - this.getAttributeInstance(GenericAttributes.maxHealth).setValue(4.0D); - this.getAttributeInstance(GenericAttributes.d).setValue(0.25D); - } - - public void e() { - // CraftBukkit start - if (this.isChickenJockey()) { - this.persistent = !this.isTypeNotPersistent(); - } - // CraftBukkit end - super.e(); - this.bs = this.bp; - this.br = this.bq; - this.bq = (float) ((double) this.bq + (double) (this.onGround ? -1 : 4) * 0.3D); - if (this.bq < 0.0F) { - this.bq = 0.0F; - } - - if (this.bq > 1.0F) { - this.bq = 1.0F; - } - - if (!this.onGround && this.bt < 1.0F) { - this.bt = 1.0F; - } - - this.bt = (float) ((double) this.bt * 0.9D); - if (!this.onGround && this.motY < 0.0D) { - this.motY *= 0.6D; - } - - this.bp += this.bt * 2.0F; - if (!this.world.isStatic && !this.isBaby() && !this.isChickenJockey() && --this.bu <= 0) { - this.makeSound("mob.chicken.plop", 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); - this.a(Items.EGG, 1); - this.bu = this.random.nextInt(6000) + 6000; - } - } - - protected void b(float f) {} - - protected String t() { - return "mob.chicken.say"; - } - - protected String aT() { - return "mob.chicken.hurt"; - } - - protected String aU() { - return "mob.chicken.hurt"; - } - - protected void a(int i, int j, int k, Block block) { - this.makeSound("mob.chicken.step", 0.15F, 1.0F); - } - - protected Item getLoot() { - return Items.FEATHER; - } - - protected void dropDeathLoot(boolean flag, int i) { - int j = this.random.nextInt(3) + this.random.nextInt(1 + i); - - for (int k = 0; k < j; ++k) { - this.a(Items.FEATHER, 1); - } - - if (this.isBurning()) { - this.a(Items.COOKED_CHICKEN, 1); - } else { - this.a(Items.RAW_CHICKEN, 1); - } - } - - public EntityChicken b(EntityAgeable entityageable) { - return new EntityChicken(this.world); - } - - public boolean c(ItemStack itemstack) { - return itemstack != null && itemstack.getItem() instanceof ItemSeeds; - } - - public void a(NBTTagCompound nbttagcompound) { - super.a(nbttagcompound); - this.bv = nbttagcompound.getBoolean("IsChickenJockey"); - } - - protected int getExpValue(EntityHuman entityhuman) { - return this.isChickenJockey() ? 10 : super.getExpValue(entityhuman); - } - - public void b(NBTTagCompound nbttagcompound) { - super.b(nbttagcompound); - nbttagcompound.setBoolean("IsChickenJockey", this.bv); - } - - protected boolean isTypeNotPersistent() { - return this.isChickenJockey() && this.passenger == null; - } - - public void ac() { - super.ac(); - float f = MathHelper.sin(this.aM * 3.1415927F / 180.0F); - float f1 = MathHelper.cos(this.aM * 3.1415927F / 180.0F); - float f2 = 0.1F; - float f3 = 0.0F; - - this.passenger.setPosition(this.locX + (double) (f2 * f), this.locY + (double) (this.length * 0.5F) + this.passenger.ad() + (double) f3, this.locZ - (double) (f2 * f1)); - if (this.passenger instanceof EntityLiving) { - ((EntityLiving) this.passenger).aM = this.aM; - } - } - - public boolean isChickenJockey() { - return this.bv; - } - - public void i(boolean flag) { - this.bv = flag; - } - - public EntityAgeable createChild(EntityAgeable entityageable) { - return this.b(entityageable); - } -} diff --git a/src/main/java/net/minecraft/server/EntityCow.java b/src/main/java/net/minecraft/server/EntityCow.java deleted file mode 100644 index df21fde2..00000000 --- a/src/main/java/net/minecraft/server/EntityCow.java +++ /dev/null @@ -1,110 +0,0 @@ -package net.minecraft.server; - -// CraftBukkit start -import org.bukkit.craftbukkit.event.CraftEventFactory; -import org.bukkit.craftbukkit.inventory.CraftItemStack; -// CraftBukkit end - -public class EntityCow extends EntityAnimal { - - public EntityCow(World world) { - super(world); - this.a(0.9F, 1.3F); - this.getNavigation().a(true); - this.goalSelector.a(0, new PathfinderGoalFloat(this)); - this.goalSelector.a(1, new PathfinderGoalPanic(this, 2.0D)); - this.goalSelector.a(2, new PathfinderGoalBreed(this, 1.0D)); - this.goalSelector.a(3, new PathfinderGoalTempt(this, 1.25D, Items.WHEAT, false)); - this.goalSelector.a(4, new PathfinderGoalFollowParent(this, 1.25D)); - this.goalSelector.a(5, new PathfinderGoalRandomStroll(this, 1.0D)); - this.goalSelector.a(6, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 6.0F)); - this.goalSelector.a(7, new PathfinderGoalRandomLookaround(this)); - } - - public boolean bk() { - return true; - } - - protected void aD() { - super.aD(); - this.getAttributeInstance(GenericAttributes.maxHealth).setValue(10.0D); - this.getAttributeInstance(GenericAttributes.d).setValue(0.20000000298023224D); - } - - protected String t() { - return "mob.cow.say"; - } - - protected String aT() { - return "mob.cow.hurt"; - } - - protected String aU() { - return "mob.cow.hurt"; - } - - protected void a(int i, int j, int k, Block block) { - this.makeSound("mob.cow.step", 0.15F, 1.0F); - } - - protected float bf() { - return 0.4F; - } - - protected Item getLoot() { - return Items.LEATHER; - } - - protected void dropDeathLoot(boolean flag, int i) { - int j = this.random.nextInt(3) + this.random.nextInt(1 + i); - - int k; - - for (k = 0; k < j; ++k) { - this.a(Items.LEATHER, 1); - } - - j = this.random.nextInt(3) + 1 + this.random.nextInt(1 + i); - - for (k = 0; k < j; ++k) { - if (this.isBurning()) { - this.a(Items.COOKED_BEEF, 1); - } else { - this.a(Items.RAW_BEEF, 1); - } - } - } - - public boolean a(EntityHuman entityhuman) { - ItemStack itemstack = entityhuman.inventory.getItemInHand(); - - if (itemstack != null && itemstack.getItem() == Items.BUCKET && !entityhuman.abilities.canInstantlyBuild) { - // CraftBukkit start - Got milk? - org.bukkit.Location loc = this.getBukkitEntity().getLocation(); - org.bukkit.event.player.PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent(entityhuman, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), -1, itemstack, Items.MILK_BUCKET); - - if (event.isCancelled()) { - return false; - } - - if (--itemstack.count <= 0) { - entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, CraftItemStack.asNMSCopy(event.getItemStack())); - } else if (!entityhuman.inventory.pickup(new ItemStack(Items.MILK_BUCKET))) { - entityhuman.drop(CraftItemStack.asNMSCopy(event.getItemStack()), false); - } - // CraftBukkit end - - return true; - } else { - return super.a(entityhuman); - } - } - - public EntityCow b(EntityAgeable entityageable) { - return new EntityCow(this.world); - } - - public EntityAgeable createChild(EntityAgeable entityageable) { - return this.b(entityageable); - } -} diff --git a/src/main/java/net/minecraft/server/EntityCreature.java b/src/main/java/net/minecraft/server/EntityCreature.java deleted file mode 100644 index 6960b058..00000000 --- a/src/main/java/net/minecraft/server/EntityCreature.java +++ /dev/null @@ -1,313 +0,0 @@ -package net.minecraft.server; - -import java.util.UUID; - -// CraftBukkit start -import org.bukkit.craftbukkit.entity.CraftEntity; -import org.bukkit.event.entity.EntityTargetEvent; -import org.bukkit.event.entity.EntityUnleashEvent; -// CraftBukkit end - -public abstract class EntityCreature extends EntityInsentient { - - public static final UUID h = UUID.fromString("E199AD21-BA8A-4C53-8D13-6182D5C69D3A"); - public static final AttributeModifier i = (new AttributeModifier(h, "Fleeing speed bonus", 2.0D, 2)).a(false); - public PathEntity pathEntity; // CraftBukkit - private -> public - public Entity target; // CraftBukkit - protected -> public - protected boolean bn; - protected int bo; - private ChunkCoordinates bq = new ChunkCoordinates(0, 0, 0); - private float br = -1.0F; - private PathfinderGoal bs = new PathfinderGoalMoveTowardsRestriction(this, 1.0D); - private boolean bt; - - public EntityCreature(World world) { - super(world); - } - - protected boolean bP() { - return false; - } - - protected void bq() { - this.world.methodProfiler.a("ai"); - if (this.bo > 0 && --this.bo == 0) { - AttributeInstance attributeinstance = this.getAttributeInstance(GenericAttributes.d); - - attributeinstance.b(i); - } - - this.bn = this.bP(); - float f11 = 16.0F; - - if (this.target == null) { - // CraftBukkit start - Entity target = this.findTarget(); - if (target != null) { - EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), target.getBukkitEntity(), EntityTargetEvent.TargetReason.CLOSEST_PLAYER); - this.world.getServer().getPluginManager().callEvent(event); - - if (!event.isCancelled()) { - if (event.getTarget() == null) { - this.target = null; - } else { - this.target = ((CraftEntity) event.getTarget()).getHandle(); - } - } - } - // CraftBukkit end - - if (this.target != null) { - this.pathEntity = this.world.findPath(this, this.target, f11, true, false, false, true); - } - } else if (this.target.isAlive()) { - float f1 = this.target.e((Entity) this); - - if (this.hasLineOfSight(this.target)) { - this.a(this.target, f1); - } - } else { - // CraftBukkit start - EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), null, EntityTargetEvent.TargetReason.TARGET_DIED); - this.world.getServer().getPluginManager().callEvent(event); - - if (!event.isCancelled()) { - if (event.getTarget() == null) { - this.target = null; - } else { - this.target = ((CraftEntity) event.getTarget()).getHandle(); - } - } - // CraftBukkit end - } - - if (this.target instanceof EntityPlayer && ((EntityPlayer) this.target).playerInteractManager.isCreative()) { - this.target = null; - } - - this.world.methodProfiler.b(); - if (!this.bn && this.target != null && (this.pathEntity == null || this.random.nextInt(20) == 0)) { - this.pathEntity = this.world.findPath(this, this.target, f11, true, false, false, true); - } else if (!this.bn && (this.pathEntity == null && this.random.nextInt(180) == 0 || this.random.nextInt(120) == 0 || this.bo > 0) && this.aU < 100) { - this.bQ(); - } - - int i = MathHelper.floor(this.boundingBox.b + 0.5D); - boolean flag = this.M(); - boolean flag1 = this.P(); - - this.pitch = 0.0F; - if (this.pathEntity != null && this.random.nextInt(100) != 0) { - this.world.methodProfiler.a("followpath"); - 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) { - this.pathEntity.a(); - if (this.pathEntity.b()) { - vec3d = null; - this.pathEntity = null; - } else { - vec3d = this.pathEntity.a((Entity) this); - } - } - - this.bc = false; - if (vec3d != null) { - double d1 = vec3d.a - this.locX; - double d2 = vec3d.c - this.locZ; - double d3 = vec3d.b - (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.be = (float) this.getAttributeInstance(GenericAttributes.d).getValue(); - if (f3 > 30.0F) { - f3 = 30.0F; - } - - if (f3 < -30.0F) { - f3 = -30.0F; - } - - this.yaw += f3; - if (this.bn && this.target != null) { - double d4 = this.target.locX - this.locX; - double d5 = this.target.locZ - this.locZ; - float f4 = this.yaw; - - this.yaw = (float) (Math.atan2(d5, d4) * 180.0D / 3.1415927410125732D) - 90.0F; - f3 = (f4 - this.yaw + 90.0F) * 3.1415927F / 180.0F; - this.bd = -MathHelper.sin(f3) * this.be * 1.0F; - this.be = MathHelper.cos(f3) * this.be * 1.0F; - } - - if (d3 > 0.0D) { - this.bc = true; - } - } - - if (this.target != null) { - this.a(this.target, 30.0F, 30.0F); - } - - if (this.positionChanged && !this.bS()) { - this.bc = true; - } - - if (this.random.nextFloat() < 0.8F && (flag || flag1)) { - this.bc = true; - } - - this.world.methodProfiler.b(); - } else { - super.bq(); - this.pathEntity = null; - } - } - - protected void bQ() { - this.world.methodProfiler.a("stroll"); - boolean flag = false; - int i = -1; - int j = -1; - int k = -1; - float f = -99999.0F; - - for (int l = 0; l < 10; ++l) { - int i1 = MathHelper.floor(this.locX + (double) this.random.nextInt(13) - 6.0D); - int j1 = MathHelper.floor(this.locY + (double) this.random.nextInt(7) - 3.0D); - int k1 = MathHelper.floor(this.locZ + (double) this.random.nextInt(13) - 6.0D); - float f1 = this.a(i1, j1, k1); - - if (f1 > f) { - f = f1; - i = i1; - j = j1; - k = k1; - flag = true; - } - } - - if (flag) { - this.pathEntity = this.world.a(this, i, j, k, 10.0F, true, false, false, true); - } - - this.world.methodProfiler.b(); - } - - protected void a(Entity entity, float f) {} - - public float a(int i, int j, int k) { - return 0.0F; - } - - protected Entity findTarget() { - return null; - } - - public boolean canSpawn() { - int i = MathHelper.floor(this.locX); - int j = MathHelper.floor(this.boundingBox.b); - int k = MathHelper.floor(this.locZ); - - return super.canSpawn() && this.a(i, j, k) >= 0.0F; - } - - public boolean bS() { - return this.pathEntity != null; - } - - public void setPathEntity(PathEntity pathentity) { - this.pathEntity = pathentity; - } - - public Entity bT() { - return this.target; - } - - public void setTarget(Entity entity) { - this.target = entity; - } - - public boolean bU() { - return this.b(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ)); - } - - public boolean b(int i, int j, int k) { - return this.br == -1.0F ? true : this.bq.e(i, j, k) < this.br * this.br; - } - - public void a(int i, int j, int k, int l) { - this.bq.b(i, j, k); - this.br = (float) l; - } - - public ChunkCoordinates bV() { - return this.bq; - } - - public float bW() { - return this.br; - } - - public void bX() { - this.br = -1.0F; - } - - public boolean bY() { - return this.br != -1.0F; - } - - protected void bL() { - super.bL(); - if (this.bN() && this.getLeashHolder() != null && this.getLeashHolder().world == this.world) { - Entity entity = this.getLeashHolder(); - - this.a((int) entity.locX, (int) entity.locY, (int) entity.locZ, 5); - float f = this.e(entity); - - if (this instanceof EntityTameableAnimal && ((EntityTameableAnimal) this).isSitting()) { - if (f > 10.0F) { - this.world.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE)); // CraftBukkit - this.unleash(true, true); - } - - return; - } - - if (!this.bt) { - this.goalSelector.a(2, this.bs); - this.getNavigation().a(false); - this.bt = true; - } - - this.o(f); - if (f > 4.0F) { - this.getNavigation().a(entity, 1.0D); - } - - if (f > 6.0F) { - double d0 = (entity.locX - this.locX) / (double) f; - double d1 = (entity.locY - this.locY) / (double) f; - double d2 = (entity.locZ - this.locZ) / (double) f; - - this.motX += d0 * Math.abs(d0) * 0.4D; - this.motY += d1 * Math.abs(d1) * 0.4D; - this.motZ += d2 * Math.abs(d2) * 0.4D; - } - - if (f > 10.0F) { - this.world.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE)); // CraftBukkit - this.unleash(true, true); - } - } else if (!this.bN() && this.bt) { - this.bt = false; - this.goalSelector.a(this.bs); - this.getNavigation().a(true); - this.bX(); - } - } - - protected void o(float f) {} -} diff --git a/src/main/java/net/minecraft/server/EntityCreeper.java b/src/main/java/net/minecraft/server/EntityCreeper.java deleted file mode 100644 index a8162c75..00000000 --- a/src/main/java/net/minecraft/server/EntityCreeper.java +++ /dev/null @@ -1,228 +0,0 @@ -package net.minecraft.server; - -// CraftBukkit start -import org.bukkit.craftbukkit.event.CraftEventFactory; -import org.bukkit.event.entity.ExplosionPrimeEvent; -// CraftBukkit end - -public class EntityCreeper extends EntityMonster { - - private int bp; - private int fuseTicks; - private int maxFuseTicks = 30; - private int explosionRadius = 3; - private int record = -1; // CraftBukkit - - public EntityCreeper(World world) { - super(world); - this.goalSelector.a(1, new PathfinderGoalFloat(this)); - this.goalSelector.a(2, new PathfinderGoalSwell(this)); - this.goalSelector.a(3, new PathfinderGoalAvoidPlayer(this, EntityOcelot.class, 6.0F, 1.0D, 1.2D)); - this.goalSelector.a(4, new PathfinderGoalMeleeAttack(this, 1.0D, false)); - this.goalSelector.a(5, new PathfinderGoalRandomStroll(this, 0.8D)); - this.goalSelector.a(6, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 8.0F)); - this.goalSelector.a(6, new PathfinderGoalRandomLookaround(this)); - this.targetSelector.a(1, new PathfinderGoalNearestAttackableTarget(this, EntityHuman.class, 0, true)); - this.targetSelector.a(2, new PathfinderGoalHurtByTarget(this, false)); - } - - protected void aD() { - super.aD(); - this.getAttributeInstance(GenericAttributes.d).setValue(0.25D); - } - - public boolean bk() { - return true; - } - - public int ax() { - return this.getGoalTarget() == null ? 3 : 3 + (int) (this.getHealth() - 1.0F); - } - - protected void b(float f) { - super.b(f); - this.fuseTicks = (int) ((float) this.fuseTicks + f * 1.5F); - if (this.fuseTicks > this.maxFuseTicks - 5) { - this.fuseTicks = this.maxFuseTicks - 5; - } - } - - protected void c() { - super.c(); - this.datawatcher.a(16, Byte.valueOf((byte) -1)); - this.datawatcher.a(17, Byte.valueOf((byte) 0)); - this.datawatcher.a(18, Byte.valueOf((byte) 0)); - } - - public void b(NBTTagCompound nbttagcompound) { - super.b(nbttagcompound); - if (this.datawatcher.getByte(17) == 1) { - nbttagcompound.setBoolean("powered", true); - } - - nbttagcompound.setShort("Fuse", (short) this.maxFuseTicks); - nbttagcompound.setByte("ExplosionRadius", (byte) this.explosionRadius); - nbttagcompound.setBoolean("ignited", this.cc()); - } - - public void a(NBTTagCompound nbttagcompound) { - super.a(nbttagcompound); - this.datawatcher.watch(17, Byte.valueOf((byte) (nbttagcompound.getBoolean("powered") ? 1 : 0))); - if (nbttagcompound.hasKeyOfType("Fuse", 99)) { - this.maxFuseTicks = nbttagcompound.getShort("Fuse"); - } - - if (nbttagcompound.hasKeyOfType("ExplosionRadius", 99)) { - this.explosionRadius = nbttagcompound.getByte("ExplosionRadius"); - } - - if (nbttagcompound.getBoolean("ignited")) { - this.cd(); - } - } - - public void h() { - if (this.isAlive()) { - this.bp = this.fuseTicks; - if (this.cc()) { - this.a(1); - } - - int i = this.cb(); - - if (i > 0 && this.fuseTicks == 0) { - this.makeSound("creeper.primed", 1.0F, 0.5F); - } - - this.fuseTicks += i; - if (this.fuseTicks < 0) { - this.fuseTicks = 0; - } - - if (this.fuseTicks >= this.maxFuseTicks) { - this.fuseTicks = this.maxFuseTicks; - this.ce(); - } - } - - super.h(); - } - - protected String aT() { - return "mob.creeper.say"; - } - - protected String aU() { - return "mob.creeper.death"; - } - - public void die(DamageSource damagesource) { - // super.die(damagesource); // CraftBukkit - Moved to end - if (damagesource.getEntity() instanceof EntitySkeleton) { - int i = Item.getId(Items.RECORD_1); - int j = Item.getId(Items.RECORD_12); - int k = i + this.random.nextInt(j - i + 1); - - // CraftBukkit start - Store record for now, drop in dropDeathLoot - // this.a(Item.getById(k), 1); - this.record = k; - // CraftBukkit end - } - - super.die(damagesource); // CraftBukkit - Moved from above - } - - // CraftBukkit start - Whole method - protected void dropDeathLoot(boolean flag, int i) { - super.dropDeathLoot(flag, i); - - // Drop a music disc? - if (this.record != -1) { - this.a(Item.getById(this.record), 1); - this.record = -1; - } - } - // CraftBukkit end - - public boolean n(Entity entity) { - return true; - } - - public boolean isPowered() { - return this.datawatcher.getByte(17) == 1; - } - - protected Item getLoot() { - return Items.SULPHUR; - } - - public int cb() { - return this.datawatcher.getByte(16); - } - - public void a(int i) { - this.datawatcher.watch(16, Byte.valueOf((byte) i)); - } - - public void a(EntityLightning entitylightning) { - super.a(entitylightning); - // CraftBukkit start - if (CraftEventFactory.callCreeperPowerEvent(this, entitylightning, org.bukkit.event.entity.CreeperPowerEvent.PowerCause.LIGHTNING).isCancelled()) { - return; - } - - this.setPowered(true); - } - - public void setPowered(boolean powered) { - if (!powered) { - this.datawatcher.watch(17, Byte.valueOf((byte) 0)); - } else { - this.datawatcher.watch(17, Byte.valueOf((byte) 1)); - } - // CraftBukkit end - } - - protected boolean a(EntityHuman entityhuman) { - ItemStack itemstack = entityhuman.inventory.getItemInHand(); - - if (itemstack != null && itemstack.getItem() == Items.FLINT_AND_STEEL) { - this.world.makeSound(this.locX + 0.5D, this.locY + 0.5D, this.locZ + 0.5D, "fire.ignite", 1.0F, this.random.nextFloat() * 0.4F + 0.8F); - entityhuman.ba(); - if (!this.world.isStatic) { - this.cd(); - itemstack.damage(1, entityhuman); - return true; - } - } - - return super.a(entityhuman); - } - - private void ce() { - 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(), flag); - this.die(); - } else { - this.fuseTicks = 0; - } - // CraftBukkit end - } - } - - public boolean cc() { - return this.datawatcher.getByte(18) != 0; - } - - public void cd() { - this.datawatcher.watch(18, Byte.valueOf((byte) 1)); - } -} diff --git a/src/main/java/net/minecraft/server/EntityDamageSourceIndirect.java b/src/main/java/net/minecraft/server/EntityDamageSourceIndirect.java deleted file mode 100644 index 8c4670ba..00000000 --- a/src/main/java/net/minecraft/server/EntityDamageSourceIndirect.java +++ /dev/null @@ -1,34 +0,0 @@ -package net.minecraft.server; - -public class EntityDamageSourceIndirect extends EntityDamageSource { - - private Entity owner; - - public EntityDamageSourceIndirect(String s, Entity entity, Entity entity1) { - super(s, entity); - this.owner = entity1; - } - - public Entity i() { - return this.p; - } - - public Entity getEntity() { - return this.owner; - } - - public IChatBaseComponent getLocalizedDeathMessage(EntityLiving entityliving) { - IChatBaseComponent ichatbasecomponent = this.owner == null ? this.p.getScoreboardDisplayName() : this.owner.getScoreboardDisplayName(); - ItemStack itemstack = this.owner instanceof EntityLiving ? ((EntityLiving) this.owner).be() : null; - String s = "death.attack." + this.translationIndex; - String s1 = s + ".item"; - - return itemstack != null && itemstack.hasName() && LocaleI18n.c(s1) ? new ChatMessage(s1, new Object[] { entityliving.getScoreboardDisplayName(), ichatbasecomponent, itemstack.E()}) : new ChatMessage(s, new Object[] { entityliving.getScoreboardDisplayName(), ichatbasecomponent}); - } - - // CraftBukkit start - public Entity getProximateDamageSource() { - return super.getEntity(); - } - // CraftBukkit end -} diff --git a/src/main/java/net/minecraft/server/EntityEgg.java b/src/main/java/net/minecraft/server/EntityEgg.java deleted file mode 100644 index f999ddd6..00000000 --- a/src/main/java/net/minecraft/server/EntityEgg.java +++ /dev/null @@ -1,68 +0,0 @@ -package net.minecraft.server; - -// CraftBukkit start -import org.bukkit.entity.Ageable; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.event.player.PlayerEggThrowEvent; -// CraftBukkit end - -public class EntityEgg extends EntityProjectile { - - public EntityEgg(World world) { - super(world); - } - - public EntityEgg(World world, EntityLiving entityliving) { - super(world, entityliving); - } - - public EntityEgg(World world, double d0, double d1, double d2) { - super(world, d0, d1, d2); - } - - protected void a(MovingObjectPosition movingobjectposition) { - if (movingobjectposition.entity != null) { - movingobjectposition.entity.damageEntity(DamageSource.projectile(this, this.getShooter()), 0.0F); - } - - // CraftBukkit start - Fire PlayerEggThrowEvent - boolean hatching = !this.world.isStatic && this.random.nextInt(8) == 0; - int numHatching = (this.random.nextInt(32) == 0) ? 4 : 1; - if (!hatching) { - numHatching = 0; - } - - EntityType hatchingType = EntityType.CHICKEN; - - Entity shooter = this.getShooter(); - if (shooter instanceof EntityPlayer) { - Player player = (shooter == null) ? null : (Player) shooter.getBukkitEntity(); - - PlayerEggThrowEvent event = new PlayerEggThrowEvent(player, (org.bukkit.entity.Egg) this.getBukkitEntity(), hatching, (byte) numHatching, hatchingType); - this.world.getServer().getPluginManager().callEvent(event); - - hatching = event.isHatching(); - numHatching = event.getNumHatches(); - hatchingType = event.getHatchingType(); - } - - if (hatching) { - for (int k = 0; k < numHatching; k++) { - org.bukkit.entity.Entity entity = world.getWorld().spawn(new org.bukkit.Location(world.getWorld(), this.locX, this.locY, this.locZ, this.yaw, 0.0F), hatchingType.getEntityClass(), org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.EGG); - if (entity instanceof Ageable) { - ((Ageable) entity).setBaby(); - } - } - } - // CraftBukkit end - - for (int j = 0; j < 8; ++j) { - this.world.addParticle("snowballpoof", this.locX, this.locY, this.locZ, 0.0D, 0.0D, 0.0D); - } - - if (!this.world.isStatic) { - this.die(); - } - } -} diff --git a/src/main/java/net/minecraft/server/EntityEnderCrystal.java b/src/main/java/net/minecraft/server/EntityEnderCrystal.java deleted file mode 100644 index cb023e2e..00000000 --- a/src/main/java/net/minecraft/server/EntityEnderCrystal.java +++ /dev/null @@ -1,88 +0,0 @@ -package net.minecraft.server; - -// CraftBukkit start -import org.bukkit.craftbukkit.event.CraftEventFactory; -import org.bukkit.event.entity.ExplosionPrimeEvent; -// CraftBukkit end - -public class EntityEnderCrystal extends Entity { - - public int a; - public int b; - - public EntityEnderCrystal(World world) { - super(world); - this.k = true; - this.a(2.0F, 2.0F); - this.height = this.length / 2.0F; - this.b = 5; - this.a = this.random.nextInt(100000); - } - - protected boolean g_() { - return false; - } - - protected void c() { - this.datawatcher.a(8, Integer.valueOf(this.b)); - } - - public void h() { - this.lastX = this.locX; - this.lastY = this.locY; - this.lastZ = this.locZ; - ++this.a; - this.datawatcher.watch(8, Integer.valueOf(this.b)); - int i = MathHelper.floor(this.locX); - int j = MathHelper.floor(this.locY); - int k = MathHelper.floor(this.locZ); - - if (this.world.worldProvider instanceof WorldProviderTheEnd && this.world.getType(i, j, k) != Blocks.FIRE) { - // CraftBukkit start - if (!CraftEventFactory.callBlockIgniteEvent(this.world, i, j, k, this).isCancelled()) { - this.world.setTypeUpdate(i, j, k, Blocks.FIRE); - } - // CraftBukkit end - } - } - - protected void b(NBTTagCompound nbttagcompound) {} - - protected void a(NBTTagCompound nbttagcompound) {} - - public boolean R() { - return true; - } - - public boolean damageEntity(DamageSource damagesource, float f) { - if (this.isInvulnerable()) { - return false; - } else { - if (!this.dead && !this.world.isStatic) { - // CraftBukkit start - All non-living entities need this - if (CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f)) { - return false; - } - // CraftBukkit end - - this.b = 0; - if (this.b <= 0) { - this.die(); - if (!this.world.isStatic) { - // CraftBukkit start - ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), 6.0F, false); - this.world.getServer().getPluginManager().callEvent(event); - if (event.isCancelled()) { - this.dead = false; - return false; - } - this.world.createExplosion(this, this.locX, this.locY, this.locZ, event.getRadius(), event.getFire(), true); - // CraftBukkit end - } - } - } - - return true; - } - } -} diff --git a/src/main/java/net/minecraft/server/EntityEnderDragon.java b/src/main/java/net/minecraft/server/EntityEnderDragon.java deleted file mode 100644 index 78023c4b..00000000 --- a/src/main/java/net/minecraft/server/EntityEnderDragon.java +++ /dev/null @@ -1,682 +0,0 @@ -package net.minecraft.server; - -import java.util.Iterator; -import java.util.List; - -// CraftBukkit start -import org.bukkit.block.BlockState; -import org.bukkit.craftbukkit.event.CraftEventFactory; -import org.bukkit.craftbukkit.util.BlockStateListPopulator; -import org.bukkit.event.entity.EntityCreatePortalEvent; -import org.bukkit.event.entity.EntityExplodeEvent; -import org.bukkit.event.entity.EntityRegainHealthEvent; -import org.bukkit.event.entity.EntityTargetEvent; -import org.bukkit.Bukkit; -// CraftBukkit end - -public class EntityEnderDragon extends EntityInsentient implements IComplex, IMonster { - - public double h; - public double i; - public double bm; - public double[][] bn = new double[64][3]; - public int bo = -1; - public EntityComplexPart[] children; - public EntityComplexPart bq; - public EntityComplexPart br; - public EntityComplexPart bs; - public EntityComplexPart bt; - public EntityComplexPart bu; - public EntityComplexPart bv; - public EntityComplexPart bw; - public float bx; - public float by; - public boolean bz; - public boolean bA; - private Entity bD; - public int bB; - public EntityEnderCrystal bC; - private Explosion explosionSource = new Explosion(null, this, Double.NaN, Double.NaN, Double.NaN, Float.NaN); // CraftBukkit - reusable source for CraftTNTPrimed.getSource() - - public EntityEnderDragon(World world) { - super(world); - this.children = new EntityComplexPart[] { this.bq = new EntityComplexPart(this, "head", 6.0F, 6.0F), this.br = new EntityComplexPart(this, "body", 8.0F, 8.0F), this.bs = new EntityComplexPart(this, "tail", 4.0F, 4.0F), this.bt = new EntityComplexPart(this, "tail", 4.0F, 4.0F), this.bu = new EntityComplexPart(this, "tail", 4.0F, 4.0F), this.bv = new EntityComplexPart(this, "wing", 4.0F, 4.0F), this.bw = new EntityComplexPart(this, "wing", 4.0F, 4.0F)}; - this.setHealth(this.getMaxHealth()); - this.a(16.0F, 8.0F); - this.X = true; - this.fireProof = true; - this.i = 100.0D; - this.ak = true; - } - - protected void aD() { - super.aD(); - this.getAttributeInstance(GenericAttributes.maxHealth).setValue(200.0D); - } - - protected void c() { - super.c(); - } - - public double[] b(int i, float f) { - if (this.getHealth() <= 0.0F) { - f = 0.0F; - } - - f = 1.0F - f; - int j = this.bo - i * 1 & 63; - int k = this.bo - i * 1 - 1 & 63; - double[] adouble = new double[3]; - double d0 = this.bn[j][0]; - double d1 = MathHelper.g(this.bn[k][0] - d0); - - adouble[0] = d0 + d1 * (double) f; - d0 = this.bn[j][1]; - d1 = this.bn[k][1] - d0; - adouble[1] = d0 + d1 * (double) f; - adouble[2] = this.bn[j][2] + (this.bn[k][2] - this.bn[j][2]) * (double) f; - return adouble; - } - - public void e() { - float f; - float f1; - - if (this.world.isStatic) { - f = MathHelper.cos(this.by * 3.1415927F * 2.0F); - f1 = MathHelper.cos(this.bx * 3.1415927F * 2.0F); - if (f1 <= -0.3F && f >= -0.3F) { - this.world.a(this.locX, this.locY, this.locZ, "mob.enderdragon.wings", 5.0F, 0.8F + this.random.nextFloat() * 0.3F, false); - } - } - - this.bx = this.by; - float f2; - - if (this.getHealth() <= 0.0F) { - f = (this.random.nextFloat() - 0.5F) * 8.0F; - 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.bP(); - 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.bA) { - this.by += f * 0.5F; - } else { - this.by += f; - } - - this.yaw = MathHelper.g(this.yaw); - if (this.bo < 0) { - for (int d05 = 0; d05 < this.bn.length; ++d05) { - this.bn[d05][0] = (double) this.yaw; - this.bn[d05][1] = this.locY; - } - } - - if (++this.bo == this.bn.length) { - this.bo = 0; - } - - this.bn[this.bo][0] = (double) this.yaw; - this.bn[this.bo][1] = this.locY; - double d0; - double d1; - double d2; - double d3; - float f3; - - if (this.world.isStatic) { - if (this.bg > 0) { - d0 = this.locX + (this.bh - this.locX) / (double) this.bg; - d1 = this.locY + (this.bi - this.locY) / (double) this.bg; - d2 = this.locZ + (this.bj - this.locZ) / (double) this.bg; - d3 = MathHelper.g(this.bk - (double) this.yaw); - this.yaw = (float) ((double) this.yaw + d3 / (double) this.bg); - this.pitch = (float) ((double) this.pitch + (this.bl - (double) this.pitch) / (double) this.bg); - --this.bg; - this.setPosition(d0, d1, d2); - this.b(this.yaw, this.pitch); - } - } else { - d0 = this.h - this.locX; - d1 = this.i - this.locY; - d2 = this.bm - this.locZ; - d3 = d0 * d0 + d1 * d1 + d2 * d2; - if (this.bD != null) { - this.h = this.bD.locX; - this.bm = this.bD.locZ; - double d4 = this.h - this.locX; - double d5 = this.bm - this.locZ; - double d6 = Math.sqrt(d4 * d4 + d5 * d5); - double d7 = 0.4000000059604645D + d6 / 80.0D - 1.0D; - - if (d7 > 10.0D) { - d7 = 10.0D; - } - - this.i = this.bD.boundingBox.b + d7; - } else { - this.h += this.random.nextGaussian() * 2.0D; - this.bm += this.random.nextGaussian() * 2.0D; - } - - if (this.bz || d3 < 100.0D || d3 > 22500.0D || this.positionChanged || this.F) { - this.bQ(); - } - - d1 /= (double) MathHelper.sqrt(d0 * d0 + d2 * d2); - f3 = 0.6F; - if (d1 < (double) (-f3)) { - d1 = (double) (-f3); - } - - if (d1 > (double) f3) { - d1 = (double) f3; - } - - this.motY += d1 * 0.10000000149011612D; - this.yaw = MathHelper.g(this.yaw); - double d8 = 180.0D - Math.atan2(d0, d2) * 180.0D / 3.1415927410125732D; - double d9 = MathHelper.g(d8 - (double) this.yaw); - - if (d9 > 50.0D) { - d9 = 50.0D; - } - - if (d9 < -50.0D) { - d9 = -50.0D; - } - - Vec3D vec3d = Vec3D.a(this.h - this.locX, this.i - this.locY, this.bm - this.locZ).a(); - Vec3D vec3d1 = Vec3D.a((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.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; - - if (d10 > 40.0D) { - d10 = 40.0D; - } - - 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.bA) { - 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(this.motX, this.motY, this.motZ).a(); - float f8 = (float) (vec3d2.b(vec3d1) + 1.0D) / 2.0F; - - f8 = 0.8F + 0.15F * f8; - this.motX *= (double) f8; - this.motZ *= (double) f8; - this.motY *= 0.9100000262260437D; - } - - this.aM = this.yaw; - this.bq.width = this.bq.length = 3.0F; - this.bs.width = this.bs.length = 2.0F; - this.bt.width = this.bt.length = 2.0F; - this.bu.width = this.bu.length = 2.0F; - this.br.length = 3.0F; - this.br.width = 5.0F; - this.bv.length = 2.0F; - this.bv.width = 4.0F; - this.bw.length = 3.0F; - this.bw.width = 4.0F; - f1 = (float) (this.b(5, 1.0F)[1] - this.b(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.br.h(); - this.br.setPositionRotation(this.locX + (double) (f11 * 0.5F), this.locY, this.locZ - (double) (f12 * 0.5F), 0.0F, 0.0F); - this.bv.h(); - this.bv.setPositionRotation(this.locX + (double) (f12 * 4.5F), this.locY + 2.0D, this.locZ + (double) (f11 * 4.5F), 0.0F, 0.0F); - this.bw.h(); - this.bw.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.bv.boundingBox.grow(4.0D, 2.0D, 4.0D).d(0.0D, -2.0D, 0.0D))); - this.a(this.world.getEntities(this, this.bw.boundingBox.grow(4.0D, 2.0D, 4.0D).d(0.0D, -2.0D, 0.0D))); - this.b(this.world.getEntities(this, this.bq.boundingBox.grow(1.0D, 1.0D, 1.0D))); - } - - double[] adouble = this.b(5, 1.0F); - double[] adouble1 = this.b(0, 1.0F); - - 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.bq.h(); - this.bq.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.bs; - } - - if (j == 1) { - entitycomplexpart = this.bt; - } - - if (j == 2) { - entitycomplexpart = this.bu; - } - - double[] adouble2 = this.b(12 + j * 2, 1.0F); - float f14 = this.yaw * 3.1415927F / 180.0F + this.b(adouble2[0] - adouble[0]) * 3.1415927F / 180.0F * 1.0F; - float f15 = MathHelper.sin(f14); - float f16 = MathHelper.cos(f14); - float f17 = 1.5F; - float f18 = (float) (j + 1) * 2.0F; - - entitycomplexpart.h(); - 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.bA = this.a(this.bq.boundingBox) | this.a(this.br.boundingBox); - } - } - } - - private void bP() { - if (this.bC != null) { - if (this.bC.dead) { - if (!this.world.isStatic) { - CraftEventFactory.entityDamage = this.bC; // CraftBukkit - this.a(this.bq, DamageSource.explosion((Explosion) null), 10.0F); - CraftEventFactory.entityDamage = null; // CraftBukkit - } - - this.bC = null; - } else if (this.ticksLived % 10 == 0 && this.getHealth() < this.getMaxHealth()) { - // CraftBukkit start - EntityRegainHealthEvent event = new EntityRegainHealthEvent(this.getBukkitEntity(), 1.0D, EntityRegainHealthEvent.RegainReason.ENDER_CRYSTAL); - this.world.getServer().getPluginManager().callEvent(event); - - if (!event.isCancelled()) { - this.setHealth((float) (this.getHealth() + event.getAmount())); - } - // CraftBukkit end - } - } - - if (this.random.nextInt(10) == 0) { - float f = 32.0F; - List list = this.world.a(EntityEnderCrystal.class, this.boundingBox.grow((double) f, (double) f, (double) f)); - EntityEnderCrystal entityendercrystal = null; - double d0 = Double.MAX_VALUE; - Iterator iterator = list.iterator(); - - while (iterator.hasNext()) { - EntityEnderCrystal entityendercrystal1 = (EntityEnderCrystal) iterator.next(); - double d1 = entityendercrystal1.f(this); - - if (d1 < d0) { - d0 = d1; - entityendercrystal = entityendercrystal1; - } - } - - this.bC = entityendercrystal; - } - } - - private void a(List list) { - double d0 = (this.br.boundingBox.a + this.br.boundingBox.d) / 2.0D; - double d1 = (this.br.boundingBox.c + this.br.boundingBox.f) / 2.0D; - Iterator iterator = list.iterator(); - - while (iterator.hasNext()) { - Entity entity = (Entity) iterator.next(); - - if (entity instanceof EntityLiving) { - double d2 = entity.locX - d0; - double d3 = entity.locZ - d1; - double d4 = d2 * d2 + d3 * d3; - - entity.g(d2 / d4 * 4.0D, 0.20000000298023224D, d3 / d4 * 4.0D); - } - } - } - - private void b(List list) { - for (int i = 0; i < list.size(); ++i) { - Entity entity = (Entity) list.get(i); - - if (entity instanceof EntityLiving) { - entity.damageEntity(DamageSource.mobAttack(this), 10.0F); - } - } - } - - private void bQ() { - this.bz = false; - if (this.random.nextInt(2) == 0 && !this.world.players.isEmpty()) { - // CraftBukkit start - Entity target = (Entity) this.world.players.get(this.random.nextInt(this.world.players.size())); - EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), target.getBukkitEntity(), EntityTargetEvent.TargetReason.RANDOM_TARGET); - this.world.getServer().getPluginManager().callEvent(event); - - if (!event.isCancelled()) { - if (event.getTarget() == null) { - this.bD = null; - } else { - this.bD = ((org.bukkit.craftbukkit.entity.CraftEntity) event.getTarget()).getHandle(); - } - } - // CraftBukkit end - } else { - boolean flag = false; - - do { - this.h = 0.0D; - this.i = (double) (70.0F + this.random.nextFloat() * 50.0F); - this.bm = 0.0D; - this.h += (double) (this.random.nextFloat() * 120.0F - 60.0F); - this.bm += (double) (this.random.nextFloat() * 120.0F - 60.0F); - double d0 = this.locX - this.h; - double d1 = this.locY - this.i; - double d2 = this.locZ - this.bm; - - flag = d0 * d0 + d1 * d1 + d2 * d2 > 100.0D; - } while (!flag); - - this.bD = null; - } - } - - private float b(double d0) { - return (float) MathHelper.g(d0); - } - - private boolean a(AxisAlignedBB axisalignedbb) { - int i = MathHelper.floor(axisalignedbb.a); - int j = MathHelper.floor(axisalignedbb.b); - int k = MathHelper.floor(axisalignedbb.c); - int l = MathHelper.floor(axisalignedbb.d); - int i1 = MathHelper.floor(axisalignedbb.e); - int j1 = MathHelper.floor(axisalignedbb.f); - boolean flag = false; - boolean flag1 = false; - - // CraftBukkit start - Create a list to hold all the destroyed blocks - List<org.bukkit.block.Block> destroyedBlocks = new java.util.ArrayList<org.bukkit.block.Block>(); - org.bukkit.craftbukkit.CraftWorld craftWorld = this.world.getWorld(); - // CraftBukkit end - - for (int k1 = i; k1 <= l; ++k1) { - for (int l1 = j; l1 <= i1; ++l1) { - for (int i2 = k; i2 <= j1; ++i2) { - Block block = this.world.getType(k1, l1, i2); - - if (block.getMaterial() != Material.AIR) { - if (block != Blocks.OBSIDIAN && block != Blocks.WHITESTONE && block != Blocks.BEDROCK && this.world.getGameRules().getBoolean("mobGriefing")) { - // CraftBukkit start - Add blocks to list rather than destroying them - // flag1 = this.world.setAir(k1, l1, i2) || flag1; - flag1 = true; - destroyedBlocks.add(craftWorld.getBlockAt(k1, l1, i2)); - // CraftBukkit end - } else { - flag = true; - } - } - } - } - } - - if (flag1) { - // CraftBukkit start - Set off an EntityExplodeEvent for the dragon exploding all these blocks - org.bukkit.entity.Entity bukkitEntity = this.getBukkitEntity(); - EntityExplodeEvent event = new EntityExplodeEvent(bukkitEntity, bukkitEntity.getLocation(), destroyedBlocks, 0F); - Bukkit.getPluginManager().callEvent(event); - if (event.isCancelled()) { - // This flag literally means 'Dragon hit something hard' (Obsidian, White Stone or Bedrock) and will cause the dragon to slow down. - // We should consider adding an event extension for it, or perhaps returning true if the event is cancelled. - return flag; - } else if (event.getYield() == 0F) { - // Yield zero ==> no drops - for (org.bukkit.block.Block block : event.blockList()) { - this.world.setAir(block.getX(), block.getY(), block.getZ()); - } - } else { - for (org.bukkit.block.Block block : event.blockList()) { - org.bukkit.Material blockId = block.getType(); - if (blockId == org.bukkit.Material.AIR) { - continue; - } - - int blockX = block.getX(); - int blockY = block.getY(); - int blockZ = block.getZ(); - - Block nmsBlock = org.bukkit.craftbukkit.util.CraftMagicNumbers.getBlock(blockId); - if (nmsBlock.a(explosionSource)) { - nmsBlock.dropNaturally(this.world, blockX, blockY, blockZ, block.getData(), event.getYield(), 0); - } - nmsBlock.wasExploded(world, blockX, blockY, blockZ, explosionSource); - - this.world.setAir(blockX, blockY, blockZ); - } - } - // CraftBukkit end - - double d0 = axisalignedbb.a + (axisalignedbb.d - axisalignedbb.a) * (double) this.random.nextFloat(); - 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.addParticle("largeexplode", d0, d1, d2, 0.0D, 0.0D, 0.0D); - } - - return flag; - } - - public boolean a(EntityComplexPart entitycomplexpart, DamageSource damagesource, float f) { - if (entitycomplexpart != this.bq) { - f = f / 4.0F + 1.0F; - } - - float f1 = this.yaw * 3.1415927F / 180.0F; - float f2 = MathHelper.sin(f1); - float f3 = MathHelper.cos(f1); - - this.h = this.locX + (double) (f2 * 5.0F) + (double) ((this.random.nextFloat() - 0.5F) * 2.0F); - this.i = this.locY + (double) (this.random.nextFloat() * 3.0F) + 1.0D; - this.bm = this.locZ - (double) (f3 * 5.0F) + (double) ((this.random.nextFloat() - 0.5F) * 2.0F); - this.bD = null; - if (damagesource.getEntity() instanceof EntityHuman || damagesource.isExplosion()) { - this.dealDamage(damagesource, f); - } - - return true; - } - - public boolean damageEntity(DamageSource damagesource, float f) { - return false; - } - - public boolean dealDamage(DamageSource damagesource, float f) { // CraftBukkit - protected -> public - return super.damageEntity(damagesource, f); - } - - protected void aF() { - if (this.dead) return; // CraftBukkit - can't kill what's already dead - ++this.bB; - if (this.bB >= 180 && this.bB <= 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.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) { - if (this.bB > 150 && this.bB % 5 == 0) { - i = this.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)); - } - } - - if (this.bB == 1) { - // CraftBukkit start - Use relative location for far away sounds - //this.world.b(1018, (int) this.locX, (int) this.locY, (int) this.locZ, 0); - int viewDistance = ((WorldServer) this.world).getServer().getViewDistance() * 16; - for (EntityPlayer player : (List<EntityPlayer>) this.world.players) { - double deltaX = this.locX - player.locX; - double deltaZ = this.locZ - player.locZ; - double distanceSquared = deltaX * deltaX + deltaZ * deltaZ; - if (distanceSquared > viewDistance * viewDistance) { - double deltaLength = Math.sqrt(distanceSquared); - double relativeX = player.locX + (deltaX / deltaLength) * viewDistance; - double relativeZ = player.locZ + (deltaZ / deltaLength) * viewDistance; - player.playerConnection.sendPacket(new PacketPlayOutWorldEvent(1018, (int) relativeX, (int) this.locY, (int) relativeZ, 0, true)); - } else { - player.playerConnection.sendPacket(new PacketPlayOutWorldEvent(1018, (int) this.locX, (int) this.locY, (int) this.locZ, 0, true)); - } - } - // CraftBukkit end - } - } - - this.move(0.0D, 0.10000000149011612D, 0.0D); - this.aM = this.yaw += 20.0F; - if (this.bB == 200 && !this.world.isStatic) { - i = this.expToDrop - (10 * this.expToDrop / 12); // CraftBukkit - drop the remaining experience - - while (i > 0) { - j = EntityExperienceOrb.getOrbValue(i); - i -= j; - this.world.addEntity(new EntityExperienceOrb(this.world, this.locX, this.locY, this.locZ, j)); - } - - this.b(MathHelper.floor(this.locX), MathHelper.floor(this.locZ)); - this.die(); - } - } - - private void b(int i, int j) { - byte b0 = 64; - - BlockEnderPortal.a = true; - byte b1 = 4; - - // CraftBukkit start - Replace any "this.world" in the following with just "world"! - BlockStateListPopulator world = new BlockStateListPopulator(this.world.getWorld()); - - for (int k = b0 - 1; k <= b0 + 32; ++k) { - for (int l = i - b1; l <= i + b1; ++l) { - for (int i1 = j - b1; i1 <= j + b1; ++i1) { - double d0 = (double) (l - i); - double d1 = (double) (i1 - j); - double d2 = d0 * d0 + d1 * d1; - - if (d2 <= ((double) b1 - 0.5D) * ((double) b1 - 0.5D)) { - if (k < b0) { - if (d2 <= ((double) (b1 - 1) - 0.5D) * ((double) (b1 - 1) - 0.5D)) { - world.setTypeUpdate(l, k, i1, Blocks.BEDROCK); - } - } else if (k > b0) { - world.setTypeUpdate(l, k, i1, Blocks.AIR); - } else if (d2 > ((double) (b1 - 1) - 0.5D) * ((double) (b1 - 1) - 0.5D)) { - world.setTypeUpdate(l, k, i1, Blocks.BEDROCK); - } else { - world.setTypeUpdate(l, k, i1, Blocks.ENDER_PORTAL); - } - } - } - } - } - - world.setType(i, b0 + 0, j, Blocks.BEDROCK); - world.setType(i, b0 + 1, j, Blocks.BEDROCK); - world.setType(i, b0 + 2, j, Blocks.BEDROCK); - world.setTypeAndData(i - 1, b0 + 2, j, Blocks.TORCH, 2, 0); - world.setTypeAndData(i + 1, b0 + 2, j, Blocks.TORCH, 1, 0); - world.setTypeAndData(i, b0 + 2, j - 1, Blocks.TORCH, 4, 0); - world.setTypeAndData(i, b0 + 2, j + 1, Blocks.TORCH, 3, 0); - world.setType(i, b0 + 3, j, Blocks.BEDROCK); - world.setType(i, b0 + 4, j, Blocks.DRAGON_EGG); - - EntityCreatePortalEvent event = new EntityCreatePortalEvent((org.bukkit.entity.LivingEntity) this.getBukkitEntity(), java.util.Collections.unmodifiableList(world.getList()), org.bukkit.PortalType.ENDER); - this.world.getServer().getPluginManager().callEvent(event); - - if (!event.isCancelled()) { - for (BlockState state : event.getBlocks()) { - state.update(true); - } - } else { - for (BlockState state : event.getBlocks()) { - PacketPlayOutBlockChange packet = new PacketPlayOutBlockChange(state.getX(), state.getY(), state.getZ(), this.world); - for (Iterator it = this.world.players.iterator(); it.hasNext();) { - EntityHuman entity = (EntityHuman) it.next(); - if (entity instanceof EntityPlayer) { - ((EntityPlayer) entity).playerConnection.sendPacket(packet); - } - } - } - } - // CraftBukkit end - - BlockEnderPortal.a = false; - } - - protected void w() {} - - public Entity[] at() { - return this.children; - } - - public boolean R() { - return false; - } - - public World a() { - return this.world; - } - - protected String t() { - return "mob.enderdragon.growl"; - } - - protected String aT() { - return "mob.enderdragon.hit"; - } - - protected float bf() { - 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) - // plus what is dropped when the dragon hits the ground (2000) - return 12000; - } - // CraftBukkit end -} diff --git a/src/main/java/net/minecraft/server/EntityEnderPearl.java b/src/main/java/net/minecraft/server/EntityEnderPearl.java deleted file mode 100644 index 336b6b07..00000000 --- a/src/main/java/net/minecraft/server/EntityEnderPearl.java +++ /dev/null @@ -1,60 +0,0 @@ -package net.minecraft.server; - -// CraftBukkit start -import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.event.CraftEventFactory; -import org.bukkit.event.player.PlayerTeleportEvent; -// CraftBukkit end - -public class EntityEnderPearl extends EntityProjectile { - - public EntityEnderPearl(World world) { - super(world); - } - - public EntityEnderPearl(World world, EntityLiving entityliving) { - super(world, entityliving); - } - - protected void a(MovingObjectPosition movingobjectposition) { - if (movingobjectposition.entity != null) { - movingobjectposition.entity.damageEntity(DamageSource.projectile(this, this.getShooter()), 0.0F); - } - - for (int i = 0; i < 32; ++i) { - 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) { - if (this.getShooter() != null && this.getShooter() instanceof EntityPlayer) { - EntityPlayer entityplayer = (EntityPlayer) this.getShooter(); - - if (entityplayer.playerConnection.b().isConnected() && entityplayer.world == this.world) { - // CraftBukkit start - Fire PlayerTeleportEvent - org.bukkit.craftbukkit.entity.CraftPlayer player = entityplayer.getBukkitEntity(); - org.bukkit.Location location = getBukkitEntity().getLocation(); - location.setPitch(player.getLocation().getPitch()); - location.setYaw(player.getLocation().getYaw()); - - PlayerTeleportEvent teleEvent = new PlayerTeleportEvent(player, player.getLocation(), location, PlayerTeleportEvent.TeleportCause.ENDER_PEARL); - Bukkit.getPluginManager().callEvent(teleEvent); - - if (!teleEvent.isCancelled() && !entityplayer.playerConnection.isDisconnected()) { - if (this.getShooter().am()) { - this.getShooter().mount((Entity) null); - } - - entityplayer.playerConnection.teleport(teleEvent.getTo()); - this.getShooter().fallDistance = 0.0F; - CraftEventFactory.entityDamage = this; - this.getShooter().damageEntity(DamageSource.FALL, 5.0F); - CraftEventFactory.entityDamage = null; - } - // CraftBukkit end - } - } - - this.die(); - } - } -} diff --git a/src/main/java/net/minecraft/server/EntityEnderman.java b/src/main/java/net/minecraft/server/EntityEnderman.java deleted file mode 100644 index fa6670bc..00000000 --- a/src/main/java/net/minecraft/server/EntityEnderman.java +++ /dev/null @@ -1,382 +0,0 @@ -package net.minecraft.server; - -import java.util.UUID; - -// CraftBukkit start -import org.bukkit.Location; -import org.bukkit.craftbukkit.event.CraftEventFactory; -import org.bukkit.event.entity.EntityTeleportEvent; -// CraftBukkit end - -public class EntityEnderman extends EntityMonster { - - private static final UUID bp = UUID.fromString("020E0DFB-87AE-4653-9556-831010E291A0"); - private static final AttributeModifier bq = (new AttributeModifier(bp, "Attacking speed boost", 6.199999809265137D, 0)).a(false); - private static boolean[] br = new boolean[256]; - private int bs; - private int bt; - private Entity bu; - private boolean bv; - - public EntityEnderman(World world) { - super(world); - this.a(0.6F, 2.9F); - this.W = 1.0F; - } - - protected void aD() { - super.aD(); - this.getAttributeInstance(GenericAttributes.maxHealth).setValue(40.0D); - this.getAttributeInstance(GenericAttributes.d).setValue(0.30000001192092896D); - this.getAttributeInstance(GenericAttributes.e).setValue(7.0D); - } - - protected void c() { - super.c(); - this.datawatcher.a(16, new Byte((byte) 0)); - this.datawatcher.a(17, new Byte((byte) 0)); - this.datawatcher.a(18, new Byte((byte) 0)); - } - - public void b(NBTTagCompound nbttagcompound) { - super.b(nbttagcompound); - nbttagcompound.setShort("carried", (short) Block.getId(this.getCarried())); - nbttagcompound.setShort("carriedData", (short) this.getCarriedData()); - } - - public void a(NBTTagCompound nbttagcompound) { - super.a(nbttagcompound); - this.setCarried(Block.getById(nbttagcompound.getShort("carried"))); - this.setCarriedData(nbttagcompound.getShort("carriedData")); - } - - protected Entity findTarget() { - EntityHuman entityhuman = this.world.findNearbyVulnerablePlayer(this, 64.0D); - - if (entityhuman != null) { - if (this.f(entityhuman)) { - this.bv = true; - if (this.bt == 0) { - this.world.makeSound(entityhuman.locX, entityhuman.locY, entityhuman.locZ, "mob.endermen.stare", 1.0F, 1.0F); - } - - if (this.bt++ == 5) { - this.bt = 0; - this.a(true); - return entityhuman; - } - } else { - this.bt = 0; - } - } - - return null; - } - - private boolean f(EntityHuman entityhuman) { - ItemStack itemstack = entityhuman.inventory.armor[3]; - - if (itemstack != null && itemstack.getItem() == Item.getItemOf(Blocks.PUMPKIN)) { - return false; - } else { - Vec3D vec3d = entityhuman.j(1.0F).a(); - Vec3D vec3d1 = Vec3D.a(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.a(); - double d1 = vec3d.b(vec3d1); - - return d1 > 1.0D - 0.025D / d0 && entityhuman.hasLineOfSight(this); - } - } - - public void e() { - if (this.L()) { - this.damageEntity(DamageSource.DROWN, 1.0F); - } - - if (this.bu != this.target) { - AttributeInstance attributeinstance = this.getAttributeInstance(GenericAttributes.d); - - attributeinstance.b(bq); - if (this.target != null) { - attributeinstance.a(bq); - } - } - - this.bu = this.target; - int i; - - if (!this.world.isStatic && this.world.getGameRules().getBoolean("mobGriefing")) { - int j; - int k; - Block block; - - if (this.getCarried().getMaterial() == Material.AIR) { - if (this.random.nextInt(20) == 0) { - i = MathHelper.floor(this.locX - 2.0D + this.random.nextDouble() * 4.0D); - j = MathHelper.floor(this.locY + this.random.nextDouble() * 3.0D); - k = MathHelper.floor(this.locZ - 2.0D + this.random.nextDouble() * 4.0D); - block = this.world.getType(i, j, k); - if (br[Block.getId(block)]) { - // CraftBukkit start - Pickup event - if (!CraftEventFactory.callEntityChangeBlockEvent(this, this.world.getWorld().getBlockAt(i, j, k), org.bukkit.Material.AIR).isCancelled()) { - this.setCarried(block); - this.setCarriedData(this.world.getData(i, j, k)); - this.world.setTypeUpdate(i, j, k, Blocks.AIR); - } - // CraftBukkit end - } - } - } else if (this.random.nextInt(2000) == 0) { - i = MathHelper.floor(this.locX - 1.0D + this.random.nextDouble() * 2.0D); - j = MathHelper.floor(this.locY + this.random.nextDouble() * 2.0D); - k = MathHelper.floor(this.locZ - 1.0D + this.random.nextDouble() * 2.0D); - block = this.world.getType(i, j, k); - Block block1 = this.world.getType(i, j - 1, k); - - if (block.getMaterial() == Material.AIR && block1.getMaterial() != Material.AIR && block1.d()) { - // CraftBukkit start - Place event - if (!CraftEventFactory.callEntityChangeBlockEvent(this, i, j, k, this.getCarried(), this.getCarriedData()).isCancelled()) { - this.world.setTypeAndData(i, j, k, this.getCarried(), this.getCarriedData(), 3); - this.setCarried(Blocks.AIR); - } - // CraftBukkit end - } - } - } - - for (i = 0; i < 2; ++i) { - 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.w() && !this.world.isStatic) { - float f = this.d(1.0F); - - if (f > 0.5F && this.world.i(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.a(false); - this.bv = false; - this.bZ(); - } - } - - if (this.L() || this.isBurning()) { - this.target = null; - this.a(false); - this.bv = false; - this.bZ(); - } - - if (this.cd() && !this.bv && this.random.nextInt(100) == 0) { - this.a(false); - } - - this.bc = false; - if (this.target != null) { - this.a(this.target, 100.0F, 100.0F); - } - - if (!this.world.isStatic && this.isAlive()) { - if (this.target != null) { - if (this.target instanceof EntityHuman && this.f((EntityHuman) this.target)) { - if (this.target.f((Entity) this) < 16.0D) { - this.bZ(); - } - - this.bs = 0; - } else if (this.target.f((Entity) this) > 256.0D && this.bs++ >= 30 && this.c(this.target)) { - this.bs = 0; - } - } else { - this.a(false); - this.bs = 0; - } - } - - super.e(); - } - - protected boolean bZ() { - double d0 = this.locX + (this.random.nextDouble() - 0.5D) * 64.0D; - double d1 = this.locY + (double) (this.random.nextInt(64) - 32); - double d2 = this.locZ + (this.random.nextDouble() - 0.5D) * 64.0D; - - return this.k(d0, d1, d2); - } - - protected boolean c(Entity entity) { - Vec3D vec3d = Vec3D.a(this.locX - entity.locX, this.boundingBox.b + (double) (this.length / 2.0F) - entity.locY + (double) entity.getHeadHeight(), this.locZ - entity.locZ); - - 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; - - return this.k(d1, d2, d3); - } - - protected boolean k(double d0, double d1, double d2) { - double d3 = this.locX; - double d4 = this.locY; - double d5 = this.locZ; - - this.locX = d0; - this.locY = d1; - this.locZ = d2; - boolean flag = false; - int i = MathHelper.floor(this.locX); - int j = MathHelper.floor(this.locY); - int k = MathHelper.floor(this.locZ); - - if (this.world.isLoaded(i, j, k)) { - boolean flag1 = false; - - while (!flag1 && j > 0) { - Block block = this.world.getType(i, j - 1, k); - - if (block.getMaterial().isSolid()) { - flag1 = true; - } else { - --this.locY; - --j; - } - } - - if (flag1) { - // CraftBukkit start - Teleport event - EntityTeleportEvent teleport = new EntityTeleportEvent(this.getBukkitEntity(), new Location(this.world.getWorld(), d3, d4, d5), new Location(this.world.getWorld(), this.locX, this.locY, this.locZ)); - this.world.getServer().getPluginManager().callEvent(teleport); - if (teleport.isCancelled()) { - return false; - } - - Location to = teleport.getTo(); - this.setPosition(to.getX(), to.getY(), to.getZ()); - // CraftBukkit end - - if (this.world.getCubes(this, this.boundingBox).isEmpty() && !this.world.containsLiquid(this.boundingBox)) { - flag = true; - } - } - } - - if (!flag) { - this.setPosition(d3, d4, d5); - return false; - } else { - short short1 = 128; - - for (int l = 0; l < short1; ++l) { - double d6 = (double) l / ((double) short1 - 1.0D); - float f = (this.random.nextFloat() - 0.5F) * 0.2F; - float f1 = (this.random.nextFloat() - 0.5F) * 0.2F; - float f2 = (this.random.nextFloat() - 0.5F) * 0.2F; - double d7 = d3 + (this.locX - d3) * d6 + (this.random.nextDouble() - 0.5D) * (double) this.width * 2.0D; - 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.addParticle("portal", d7, d8, d9, (double) f, (double) f1, (double) f2); - } - - this.world.makeSound(d3, d4, d5, "mob.endermen.portal", 1.0F, 1.0F); - this.makeSound("mob.endermen.portal", 1.0F, 1.0F); - return true; - } - } - - protected String t() { - return this.cd() ? "mob.endermen.scream" : "mob.endermen.idle"; - } - - protected String aT() { - return "mob.endermen.hit"; - } - - protected String aU() { - return "mob.endermen.death"; - } - - protected Item getLoot() { - return Items.ENDER_PEARL; - } - - protected void dropDeathLoot(boolean flag, int i) { - Item item = this.getLoot(); - - if (item != null) { - int j = this.random.nextInt(2 + i); - - for (int k = 0; k < j; ++k) { - this.a(item, 1); - } - } - } - - public void setCarried(Block block) { - this.datawatcher.watch(16, Byte.valueOf((byte) (Block.getId(block) & 255))); - } - - public Block getCarried() { - return Block.getById(this.datawatcher.getByte(16)); - } - - public void setCarriedData(int i) { - this.datawatcher.watch(17, Byte.valueOf((byte) (i & 255))); - } - - public int getCarriedData() { - return this.datawatcher.getByte(17); - } - - public boolean damageEntity(DamageSource damagesource, float f) { - if (this.isInvulnerable()) { - return false; - } else { - this.a(true); - if (damagesource instanceof EntityDamageSource && damagesource.getEntity() instanceof EntityHuman) { - this.bv = true; - } - - if (damagesource instanceof EntityDamageSourceIndirect) { - this.bv = false; - - for (int i = 0; i < 64; ++i) { - if (this.bZ()) { - return true; - } - } - - return false; - } else { - return super.damageEntity(damagesource, f); - } - } - } - - public boolean cd() { - return this.datawatcher.getByte(18) > 0; - } - - public void a(boolean flag) { - this.datawatcher.watch(18, Byte.valueOf((byte) (flag ? 1 : 0))); - } - - static { - br[Block.getId(Blocks.GRASS)] = true; - br[Block.getId(Blocks.DIRT)] = true; - br[Block.getId(Blocks.SAND)] = true; - br[Block.getId(Blocks.GRAVEL)] = true; - br[Block.getId(Blocks.YELLOW_FLOWER)] = true; - br[Block.getId(Blocks.RED_ROSE)] = true; - br[Block.getId(Blocks.BROWN_MUSHROOM)] = true; - br[Block.getId(Blocks.RED_MUSHROOM)] = true; - br[Block.getId(Blocks.TNT)] = true; - br[Block.getId(Blocks.CACTUS)] = true; - br[Block.getId(Blocks.CLAY)] = true; - br[Block.getId(Blocks.PUMPKIN)] = true; - br[Block.getId(Blocks.MELON)] = true; - br[Block.getId(Blocks.MYCEL)] = true; - } -} diff --git a/src/main/java/net/minecraft/server/EntityExperienceOrb.java b/src/main/java/net/minecraft/server/EntityExperienceOrb.java deleted file mode 100644 index 57507603..00000000 --- a/src/main/java/net/minecraft/server/EntityExperienceOrb.java +++ /dev/null @@ -1,188 +0,0 @@ -package net.minecraft.server; - -// CraftBukkit start -import org.bukkit.craftbukkit.event.CraftEventFactory; -import org.bukkit.event.entity.EntityTargetEvent; -// CraftBukkit end - -public class EntityExperienceOrb extends Entity { - - public int a; - public int b; - public int c; - private int d = 5; - public int value; // CraftBukkit - private -> public - private EntityHuman targetPlayer; - private int targetTime; - - public EntityExperienceOrb(World world, double d0, double d1, double d2, int i) { - super(world); - this.a(0.5F, 0.5F); - this.height = this.length / 2.0F; - this.setPosition(d0, d1, d2); - this.yaw = (float) (Math.random() * 360.0D); - this.motX = (double) ((float) (Math.random() * 0.20000000298023224D - 0.10000000149011612D) * 2.0F); - this.motY = (double) ((float) (Math.random() * 0.2D) * 2.0F); - this.motZ = (double) ((float) (Math.random() * 0.20000000298023224D - 0.10000000149011612D) * 2.0F); - this.value = i; - } - - protected boolean g_() { - return false; - } - - public EntityExperienceOrb(World world) { - super(world); - this.a(0.25F, 0.25F); - this.height = this.length / 2.0F; - } - - protected void c() {} - - public void h() { - super.h(); - if (this.c > 0) { - --this.c; - } - - this.lastX = this.locX; - this.lastY = this.locY; - this.lastZ = this.locZ; - this.motY -= 0.029999999329447746D; - if (this.world.getType(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ)).getMaterial() == Material.LAVA) { - this.motY = 0.20000000298023224D; - this.motX = (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F); - this.motZ = (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F); - this.makeSound("random.fizz", 0.4F, 2.0F + this.random.nextFloat() * 0.4F); - } - - this.j(this.locX, (this.boundingBox.b + this.boundingBox.e) / 2.0D, this.locZ); - double d0 = 8.0D; - - if (this.targetTime < this.a - 20 + this.getId() % 100) { - if (this.targetPlayer == null || this.targetPlayer.f(this) > d0 * d0) { - this.targetPlayer = this.world.findNearbyPlayer(this, d0); - } - - this.targetTime = this.a; - } - - if (this.targetPlayer != null) { - // CraftBukkit start - EntityTargetEvent event = CraftEventFactory.callEntityTargetEvent(this, targetPlayer, EntityTargetEvent.TargetReason.CLOSEST_PLAYER); - Entity target = event.getTarget() == null ? null : ((org.bukkit.craftbukkit.entity.CraftEntity) event.getTarget()).getHandle(); - - if (!event.isCancelled() && target != null) { - double d1 = (target.locX - this.locX) / d0; - double d2 = (target.locY + (double) target.getHeadHeight() - this.locY) / d0; - double d3 = (target.locZ - this.locZ) / d0; - double d4 = Math.sqrt(d1 * d1 + d2 * d2 + d3 * d3); - double d5 = 1.0D - d4; - if (d5 > 0.0D) { - d5 *= d5; - this.motX += d1 / d4 * d5 * 0.1D; - this.motY += d2 / d4 * d5 * 0.1D; - this.motZ += d3 / d4 * d5 * 0.1D; - } - // CraftBukkit end - } - } - - this.move(this.motX, this.motY, this.motZ); - float f = 0.98F; - - if (this.onGround) { - f = this.world.getType(MathHelper.floor(this.locX), MathHelper.floor(this.boundingBox.b) - 1, MathHelper.floor(this.locZ)).frictionFactor * 0.98F; - } - - this.motX *= (double) f; - this.motY *= 0.9800000190734863D; - this.motZ *= (double) f; - if (this.onGround) { - this.motY *= -0.8999999761581421D; - } - - ++this.a; - ++this.b; - if (this.b >= 6000) { - this.die(); - } - } - - public boolean N() { - return this.world.a(this.boundingBox, Material.WATER, (Entity) this); - } - - protected void burn(int i) { - this.damageEntity(DamageSource.FIRE, (float) i); - } - - public boolean damageEntity(DamageSource damagesource, float f) { - if (this.isInvulnerable()) { - return false; - } else { - this.Q(); - this.d = (int) ((float) this.d - f); - if (this.d <= 0) { - this.die(); - } - - return false; - } - } - - public void b(NBTTagCompound nbttagcompound) { - nbttagcompound.setShort("Health", (short) ((byte) this.d)); - nbttagcompound.setShort("Age", (short) this.b); - nbttagcompound.setShort("Value", (short) this.value); - } - - public void a(NBTTagCompound nbttagcompound) { - this.d = nbttagcompound.getShort("Health") & 255; - this.b = nbttagcompound.getShort("Age"); - this.value = nbttagcompound.getShort("Value"); - } - - public void b_(EntityHuman entityhuman) { - if (!this.world.isStatic) { - if (this.c == 0 && entityhuman.bt == 0) { - entityhuman.bt = 2; - this.world.makeSound(entityhuman, "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 -> event.getAmount() - this.die(); - } - } - } - - public int e() { - return this.value; - } - - public static int getOrbValue(int i) { - // CraftBukkit start - if (i > 162670129) return i - 100000; - if (i > 81335063) return 81335063; - if (i > 40667527) return 40667527; - if (i > 20333759) return 20333759; - if (i > 10166857) return 10166857; - if (i > 5083423) return 5083423; - if (i > 2541701) return 2541701; - if (i > 1270849) return 1270849; - if (i > 635413) return 635413; - if (i > 317701) return 317701; - if (i > 158849) return 158849; - if (i > 79423) return 79423; - if (i > 39709) return 39709; - if (i > 19853) return 19853; - if (i > 9923) return 9923; - if (i > 4957) return 4957; - // CraftBukkit end - - 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 av() { - return false; - } -} diff --git a/src/main/java/net/minecraft/server/EntityFallingBlock.java b/src/main/java/net/minecraft/server/EntityFallingBlock.java deleted file mode 100644 index 5576f151..00000000 --- a/src/main/java/net/minecraft/server/EntityFallingBlock.java +++ /dev/null @@ -1,233 +0,0 @@ -package net.minecraft.server; - -import java.util.ArrayList; -import java.util.Iterator; - -import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit - -public class EntityFallingBlock extends Entity { - - public Block id; // CraftBukkit - private -> public - public int data; - public int ticksLived; - public boolean dropItem; - private boolean f; - private boolean hurtEntities; - private int fallHurtMax; - private float fallHurtAmount; - public NBTTagCompound tileEntityData; - - public EntityFallingBlock(World world) { - super(world); - this.dropItem = true; - this.fallHurtMax = 40; - this.fallHurtAmount = 2.0F; - } - - public EntityFallingBlock(World world, double d0, double d1, double d2, Block block) { - this(world, d0, d1, d2, block, 0); - } - - public EntityFallingBlock(World world, double d0, double d1, double d2, Block block, int i) { - super(world); - this.dropItem = true; - this.fallHurtMax = 40; - this.fallHurtAmount = 2.0F; - this.id = block; - this.data = i; - this.k = true; - this.a(0.98F, 0.98F); - this.height = this.length / 2.0F; - this.setPosition(d0, d1, d2); - this.motX = 0.0D; - this.motY = 0.0D; - this.motZ = 0.0D; - this.lastX = d0; - this.lastY = d1; - this.lastZ = d2; - } - - protected boolean g_() { - return false; - } - - protected void c() {} - - public boolean R() { - return !this.dead; - } - - public void h() { - if (this.id.getMaterial() == Material.AIR) { - this.die(); - } else { - this.lastX = this.locX; - this.lastY = this.locY; - this.lastZ = this.locZ; - ++this.ticksLived; - this.motY -= 0.03999999910593033D; - this.move(this.motX, this.motY, this.motZ); - this.motX *= 0.9800000190734863D; - this.motY *= 0.9800000190734863D; - this.motZ *= 0.9800000190734863D; - if (!this.world.isStatic) { - int i = MathHelper.floor(this.locX); - int j = MathHelper.floor(this.locY); - int k = MathHelper.floor(this.locZ); - - if (this.ticksLived == 1) { - // CraftBukkit - compare data and call event - if (this.ticksLived != 1 || this.world.getType(i, j, k) != this.id || this.world.getData(i, j, k) != this.data || CraftEventFactory.callEntityChangeBlockEvent(this, i, j, k, Blocks.AIR, 0).isCancelled()) { - this.die(); - return; - } - - this.world.setAir(i, j, k); - } - - if (this.onGround) { - this.motX *= 0.699999988079071D; - this.motZ *= 0.699999988079071D; - this.motY *= -0.5D; - if (this.world.getType(i, j, k) != Blocks.PISTON_MOVING) { - this.die(); - // CraftBukkit start - fire EntityChangeBlockEvent - if (!this.f && this.world.mayPlace(this.id, i, j, k, true, 1, (Entity) null, (ItemStack) null) && !BlockFalling.canFall(this.world, i, j - 1, k) /* mimic the false conditions of setTypeIdAndData */ && i >= -30000000 && k >= -30000000 && i < 30000000 && k < 30000000 && j > 0 && j < 256 && !(this.world.getType(i, j, k) == this.id && this.world.getData(i, j, k) == this.data)) { - if (CraftEventFactory.callEntityChangeBlockEvent(this, i, j, k, this.id, this.data).isCancelled()) { - return; - } - this.world.setTypeAndData(i, j, k, this.id, this.data, 3); - // CraftBukkit end - - if (this.id instanceof BlockFalling) { - ((BlockFalling) this.id).a(this.world, i, j, k, this.data); - } - - if (this.tileEntityData != null && this.id instanceof IContainer) { - TileEntity tileentity = this.world.getTileEntity(i, j, k); - - if (tileentity != null) { - NBTTagCompound nbttagcompound = new NBTTagCompound(); - - tileentity.b(nbttagcompound); - Iterator iterator = this.tileEntityData.c().iterator(); - - while (iterator.hasNext()) { - String s = (String) iterator.next(); - NBTBase nbtbase = this.tileEntityData.get(s); - - if (!s.equals("x") && !s.equals("y") && !s.equals("z")) { - nbttagcompound.set(s, nbtbase.clone()); - } - } - - tileentity.a(nbttagcompound); - tileentity.update(); - } - } - } else if (this.dropItem && !this.f) { - this.a(new ItemStack(this.id, 1, this.id.getDropData(this.data)), 0.0F); - } - } - } else if (this.ticksLived > 100 && !this.world.isStatic && (j < 1 || j > 256) || this.ticksLived > 600) { - if (this.dropItem) { - this.a(new ItemStack(this.id, 1, this.id.getDropData(this.data)), 0.0F); - } - - this.die(); - } - } - } - } - - protected void b(float f) { - if (this.hurtEntities) { - int i = MathHelper.f(f - 1.0F); - - if (i > 0) { - ArrayList arraylist = new ArrayList(this.world.getEntities(this, this.boundingBox)); - boolean flag = this.id == Blocks.ANVIL; - DamageSource damagesource = flag ? DamageSource.ANVIL : DamageSource.FALLING_BLOCK; - Iterator iterator = arraylist.iterator(); - - while (iterator.hasNext()) { - Entity entity = (Entity) iterator.next(); - - CraftEventFactory.entityDamage = this; // CraftBukkit - entity.damageEntity(damagesource, (float) Math.min(MathHelper.d((float) i * this.fallHurtAmount), this.fallHurtMax)); - CraftEventFactory.entityDamage = null; // CraftBukkit - } - - if (flag && (double) this.random.nextFloat() < 0.05000000074505806D + (double) i * 0.05D) { - int j = this.data >> 2; - int k = this.data & 3; - - ++j; - if (j > 2) { - this.f = true; - } else { - this.data = k | j << 2; - } - } - } - } - } - - protected void b(NBTTagCompound nbttagcompound) { - nbttagcompound.setByte("Tile", (byte) Block.getId(this.id)); - nbttagcompound.setInt("TileID", Block.getId(this.id)); - nbttagcompound.setByte("Data", (byte) this.data); - nbttagcompound.setByte("Time", (byte) this.ticksLived); - nbttagcompound.setBoolean("DropItem", this.dropItem); - nbttagcompound.setBoolean("HurtEntities", this.hurtEntities); - nbttagcompound.setFloat("FallHurtAmount", this.fallHurtAmount); - nbttagcompound.setInt("FallHurtMax", this.fallHurtMax); - if (this.tileEntityData != null) { - nbttagcompound.set("TileEntityData", this.tileEntityData); - } - } - - protected void a(NBTTagCompound nbttagcompound) { - if (nbttagcompound.hasKeyOfType("TileID", 99)) { - this.id = Block.getById(nbttagcompound.getInt("TileID")); - } else { - this.id = Block.getById(nbttagcompound.getByte("Tile") & 255); - } - - this.data = nbttagcompound.getByte("Data") & 255; - this.ticksLived = nbttagcompound.getByte("Time") & 255; - if (nbttagcompound.hasKeyOfType("HurtEntities", 99)) { - this.hurtEntities = nbttagcompound.getBoolean("HurtEntities"); - this.fallHurtAmount = nbttagcompound.getFloat("FallHurtAmount"); - this.fallHurtMax = nbttagcompound.getInt("FallHurtMax"); - } else if (this.id == Blocks.ANVIL) { - this.hurtEntities = true; - } - - if (nbttagcompound.hasKeyOfType("DropItem", 99)) { - this.dropItem = nbttagcompound.getBoolean("DropItem"); - } - - if (nbttagcompound.hasKeyOfType("TileEntityData", 10)) { - this.tileEntityData = nbttagcompound.getCompound("TileEntityData"); - } - - if (this.id.getMaterial() == Material.AIR) { - this.id = Blocks.SAND; - } - } - - public void a(boolean flag) { - this.hurtEntities = flag; - } - - public void a(CrashReportSystemDetails crashreportsystemdetails) { - super.a(crashreportsystemdetails); - crashreportsystemdetails.a("Immitating block ID", Integer.valueOf(Block.getId(this.id))); - crashreportsystemdetails.a("Immitating block data", Integer.valueOf(this.data)); - } - - public Block f() { - return this.id; - } -} diff --git a/src/main/java/net/minecraft/server/EntityFireball.java b/src/main/java/net/minecraft/server/EntityFireball.java deleted file mode 100644 index 02d90aa2..00000000 --- a/src/main/java/net/minecraft/server/EntityFireball.java +++ /dev/null @@ -1,269 +0,0 @@ -package net.minecraft.server; - -import java.util.List; - -import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit - -public abstract class EntityFireball extends Entity { - - private int e = -1; - private int f = -1; - private int g = -1; - private Block h; - private boolean i; - public EntityLiving shooter; - private int at; - private int au; - public double dirX; - public double dirY; - public double dirZ; - public float bukkitYield = 1; // CraftBukkit - public boolean isIncendiary = true; // CraftBukkit - - public EntityFireball(World world) { - super(world); - this.a(1.0F, 1.0F); - } - - protected void c() {} - - public EntityFireball(World world, double d0, double d1, double d2, double d3, double d4, double d5) { - super(world); - this.a(1.0F, 1.0F); - this.setPositionRotation(d0, d1, d2, this.yaw, this.pitch); - this.setPosition(d0, d1, d2); - double d6 = (double) MathHelper.sqrt(d3 * d3 + d4 * d4 + d5 * d5); - - this.dirX = d3 / d6 * 0.1D; - this.dirY = d4 / d6 * 0.1D; - this.dirZ = d5 / d6 * 0.1D; - } - - public EntityFireball(World world, EntityLiving entityliving, double d0, double d1, double d2) { - super(world); - this.shooter = entityliving; - this.projectileSource = (org.bukkit.entity.LivingEntity) entityliving.getBukkitEntity(); // CraftBukkit - this.a(1.0F, 1.0F); - this.setPositionRotation(entityliving.locX, entityliving.locY, entityliving.locZ, entityliving.yaw, entityliving.pitch); - this.setPosition(this.locX, this.locY, this.locZ); - this.height = 0.0F; - this.motX = this.motY = this.motZ = 0.0D; - // CraftBukkit start - Added setDirection method - this.setDirection(d0, d1, d2); - } - - public void setDirection(double d0, double d1, double d2) { - // CraftBukkit end - d0 += this.random.nextGaussian() * 0.4D; - d1 += this.random.nextGaussian() * 0.4D; - d2 += this.random.nextGaussian() * 0.4D; - double d3 = (double) MathHelper.sqrt(d0 * d0 + d1 * d1 + d2 * d2); - - this.dirX = d0 / d3 * 0.1D; - this.dirY = d1 / d3 * 0.1D; - this.dirZ = d2 / d3 * 0.1D; - } - - public void h() { - 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(); - this.setOnFire(1); - if (this.i) { - if (this.world.getType(this.e, this.f, this.g) == this.h) { - ++this.at; - if (this.at == 600) { - this.die(); - } - - return; - } - - this.i = false; - this.motX *= (double) (this.random.nextFloat() * 0.2F); - this.motY *= (double) (this.random.nextFloat() * 0.2F); - this.motZ *= (double) (this.random.nextFloat() * 0.2F); - this.at = 0; - this.au = 0; - } else { - ++this.au; - } - - Vec3D vec3d = Vec3D.a(this.locX, this.locY, this.locZ); - Vec3D vec3d1 = Vec3D.a(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ); - MovingObjectPosition movingobjectposition = this.world.a(vec3d, vec3d1); - - vec3d = Vec3D.a(this.locX, this.locY, this.locZ); - vec3d1 = Vec3D.a(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ); - if (movingobjectposition != null) { - vec3d1 = Vec3D.a(movingobjectposition.pos.a, movingobjectposition.pos.b, movingobjectposition.pos.c); - } - - Entity entity = null; - List list = this.world.getEntities(this, this.boundingBox.a(this.motX, this.motY, this.motZ).grow(1.0D, 1.0D, 1.0D)); - double d0 = 0.0D; - - for (int i = 0; i < list.size(); ++i) { - Entity entity1 = (Entity) list.get(i); - - if (entity1.R() && (!entity1.i(this.shooter) || this.au >= 25)) { - float f = 0.3F; - AxisAlignedBB axisalignedbb = entity1.boundingBox.grow((double) f, (double) f, (double) f); - MovingObjectPosition movingobjectposition1 = axisalignedbb.a(vec3d, vec3d1); - - if (movingobjectposition1 != null) { - double d1 = vec3d.distanceSquared(movingobjectposition1.pos); // CraftBukkit - distance efficiency - - if (d1 < d0 || d0 == 0.0D) { - entity = entity1; - d0 = d1; - } - } - } - } - - if (entity != null) { - movingobjectposition = new MovingObjectPosition(entity); - } - - if (movingobjectposition != null) { - this.a(movingobjectposition); - - // CraftBukkit start - Fire ProjectileHitEvent - if (this.dead) { - CraftEventFactory.callProjectileHitEvent(this); - } - // CraftBukkit end - } - - this.locX += this.motX; - this.locY += this.motY; - this.locZ += this.motZ; - float f1 = MathHelper.sqrt(this.motX * this.motX + this.motZ * this.motZ); - - this.yaw = (float) (Math.atan2(this.motZ, this.motX) * 180.0D / 3.1415927410125732D) + 90.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) { - ; - } - - while (this.pitch - this.lastPitch >= 180.0F) { - this.lastPitch += 360.0F; - } - - while (this.yaw - this.lastYaw < -180.0F) { - this.lastYaw -= 360.0F; - } - - while (this.yaw - this.lastYaw >= 180.0F) { - this.lastYaw += 360.0F; - } - - this.pitch = this.lastPitch + (this.pitch - this.lastPitch) * 0.2F; - this.yaw = this.lastYaw + (this.yaw - this.lastYaw) * 0.2F; - float f2 = this.e(); - - if (this.M()) { - for (int j = 0; j < 4; ++j) { - float f3 = 0.25F; - - 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; - } - - this.motX += this.dirX; - this.motY += this.dirY; - this.motZ += this.dirZ; - this.motX *= (double) f2; - this.motY *= (double) f2; - this.motZ *= (double) f2; - 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 float e() { - 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); - nbttagcompound.setShort("zTile", (short) this.g); - nbttagcompound.setByte("inTile", (byte) Block.getId(this.h)); - nbttagcompound.setByte("inGround", (byte) (this.i ? 1 : 0)); - // CraftBukkit - Fix direction being mismapped to invalid variables - nbttagcompound.set("power", this.a(new double[] { this.dirX, this.dirY, this.dirZ})); - } - - public void a(NBTTagCompound nbttagcompound) { - this.e = nbttagcompound.getShort("xTile"); - this.f = nbttagcompound.getShort("yTile"); - this.g = nbttagcompound.getShort("zTile"); - this.h = Block.getById(nbttagcompound.getByte("inTile") & 255); - this.i = nbttagcompound.getByte("inGround") == 1; - // CraftBukkit start - direction -> power - if (nbttagcompound.hasKeyOfType("power", 9)) { - NBTTagList nbttaglist = nbttagcompound.getList("power", 6); - - this.dirX = nbttaglist.d(0); - this.dirY = nbttaglist.d(1); - this.dirZ = nbttaglist.d(2); - // CraftBukkit end - } else { - this.die(); - } - } - - public boolean R() { - return true; - } - - public float af() { - return 1.0F; - } - - public boolean damageEntity(DamageSource damagesource, float f) { - if (this.isInvulnerable()) { - return false; - } else { - this.Q(); - if (damagesource.getEntity() != null) { - // CraftBukkit start - if (CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f)) { - return false; - } - // CraftBukkit end - - Vec3D vec3d = damagesource.getEntity().ag(); - - if (vec3d != null) { - this.motX = vec3d.a; - this.motY = vec3d.b; - this.motZ = vec3d.c; - this.dirX = this.motX * 0.1D; - this.dirY = this.motY * 0.1D; - this.dirZ = this.motZ * 0.1D; - } - - if (damagesource.getEntity() instanceof EntityLiving) { - this.shooter = (EntityLiving) damagesource.getEntity(); - this.projectileSource = (org.bukkit.projectiles.ProjectileSource) this.shooter.getBukkitEntity(); - } - - return true; - } else { - return false; - } - } - } - - public float d(float f) { - return 1.0F; - } -} diff --git a/src/main/java/net/minecraft/server/EntityFireworks.java b/src/main/java/net/minecraft/server/EntityFireworks.java deleted file mode 100644 index 759d46c4..00000000 --- a/src/main/java/net/minecraft/server/EntityFireworks.java +++ /dev/null @@ -1,121 +0,0 @@ -package net.minecraft.server; - -public class EntityFireworks extends Entity { - - private int ticksFlown; - public int expectedLifespan; // CraftBukkit - private -> public - - public EntityFireworks(World world) { - super(world); - this.a(0.25F, 0.25F); - } - - protected void c() { - this.datawatcher.add(8, 5); - } - - public EntityFireworks(World world, double d0, double d1, double d2, ItemStack itemstack) { - super(world); - this.ticksFlown = 0; - this.a(0.25F, 0.25F); - this.setPosition(d0, d1, d2); - this.height = 0.0F; - int i = 1; - - if (itemstack != null && itemstack.hasTag()) { - this.datawatcher.watch(8, itemstack); - NBTTagCompound nbttagcompound = itemstack.getTag(); - NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("Fireworks"); - - if (nbttagcompound1 != null) { - i += nbttagcompound1.getByte("Flight"); - } - } - - this.motX = this.random.nextGaussian() * 0.001D; - this.motZ = this.random.nextGaussian() * 0.001D; - this.motY = 0.05D; - this.expectedLifespan = 10 * i + this.random.nextInt(6) + this.random.nextInt(7); - } - - public void h() { - this.S = this.locX; - this.T = this.locY; - this.U = this.locZ; - super.h(); - this.motX *= 1.15D; - this.motZ *= 1.15D; - this.motY += 0.04D; - this.move(this.motX, this.motY, this.motZ); - float f = MathHelper.sqrt(this.motX * this.motX + this.motZ * this.motZ); - - this.yaw = (float) (Math.atan2(this.motX, this.motZ) * 180.0D / 3.1415927410125732D); - - for (this.pitch = (float) (Math.atan2(this.motY, (double) f) * 180.0D / 3.1415927410125732D); this.pitch - this.lastPitch < -180.0F; this.lastPitch -= 360.0F) { - ; - } - - while (this.pitch - this.lastPitch >= 180.0F) { - this.lastPitch += 360.0F; - } - - while (this.yaw - this.lastYaw < -180.0F) { - this.lastYaw -= 360.0F; - } - - while (this.yaw - this.lastYaw >= 180.0F) { - this.lastYaw += 360.0F; - } - - this.pitch = this.lastPitch + (this.pitch - this.lastPitch) * 0.2F; - this.yaw = this.lastYaw + (this.yaw - this.lastYaw) * 0.2F; - if (this.ticksFlown == 0) { - this.world.makeSound(this, "fireworks.launch", 3.0F, 1.0F); - } - - ++this.ticksFlown; - if (this.world.isStatic && this.ticksFlown % 2 < 2) { - this.world.addParticle("fireworksSpark", this.locX, this.locY - 0.3D, this.locZ, this.random.nextGaussian() * 0.05D, -this.motY * 0.5D, this.random.nextGaussian() * 0.05D); - } - - if (!this.world.isStatic && this.ticksFlown > this.expectedLifespan) { - this.world.broadcastEntityEffect(this, (byte) 17); - this.die(); - } - } - - public void b(NBTTagCompound nbttagcompound) { - nbttagcompound.setInt("Life", this.ticksFlown); - nbttagcompound.setInt("LifeTime", this.expectedLifespan); - ItemStack itemstack = this.datawatcher.getItemStack(8); - - if (itemstack != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - - itemstack.save(nbttagcompound1); - nbttagcompound.set("FireworksItem", nbttagcompound1); - } - } - - public void a(NBTTagCompound nbttagcompound) { - this.ticksFlown = nbttagcompound.getInt("Life"); - this.expectedLifespan = nbttagcompound.getInt("LifeTime"); - NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("FireworksItem"); - - if (nbttagcompound1 != null) { - ItemStack itemstack = ItemStack.createStack(nbttagcompound1); - - if (itemstack != null) { - this.datawatcher.watch(8, itemstack); - } - } - } - - public float d(float f) { - return super.d(f); - } - - public boolean au() { - return false; - } -} diff --git a/src/main/java/net/minecraft/server/EntityFishingHook.java b/src/main/java/net/minecraft/server/EntityFishingHook.java deleted file mode 100644 index 9d4ea60f..00000000 --- a/src/main/java/net/minecraft/server/EntityFishingHook.java +++ /dev/null @@ -1,475 +0,0 @@ -package net.minecraft.server; - -import java.util.Arrays; -import java.util.Collection; -import java.util.List; - -// CraftBukkit start -import org.bukkit.entity.Player; -import org.bukkit.entity.Fish; -import org.bukkit.event.player.PlayerFishEvent; -// CraftBukkit end - -public class EntityFishingHook extends Entity { - - private static final List d = Arrays.asList(new PossibleFishingResult[] { (new PossibleFishingResult(new ItemStack(Items.LEATHER_BOOTS), 10)).a(0.9F), new PossibleFishingResult(new ItemStack(Items.LEATHER), 10), new PossibleFishingResult(new ItemStack(Items.BONE), 10), new PossibleFishingResult(new ItemStack(Items.POTION), 10), new PossibleFishingResult(new ItemStack(Items.STRING), 5), (new PossibleFishingResult(new ItemStack(Items.FISHING_ROD), 2)).a(0.9F), new PossibleFishingResult(new ItemStack(Items.BOWL), 10), new PossibleFishingResult(new ItemStack(Items.STICK), 5), new PossibleFishingResult(new ItemStack(Items.INK_SACK, 10, 0), 1), new PossibleFishingResult(new ItemStack(Blocks.TRIPWIRE_SOURCE), 10), new PossibleFishingResult(new ItemStack(Items.ROTTEN_FLESH), 10)}); - private static final List e = Arrays.asList(new PossibleFishingResult[] { new PossibleFishingResult(new ItemStack(Blocks.WATER_LILY), 1), new PossibleFishingResult(new ItemStack(Items.NAME_TAG), 1), new PossibleFishingResult(new ItemStack(Items.SADDLE), 1), (new PossibleFishingResult(new ItemStack(Items.BOW), 1)).a(0.25F).a(), (new PossibleFishingResult(new ItemStack(Items.FISHING_ROD), 1)).a(0.25F).a(), (new PossibleFishingResult(new ItemStack(Items.BOOK), 1)).a()}); - private static final List f = Arrays.asList(new PossibleFishingResult[] { new PossibleFishingResult(new ItemStack(Items.RAW_FISH, 1, EnumFish.COD.a()), 60), new PossibleFishingResult(new ItemStack(Items.RAW_FISH, 1, EnumFish.SALMON.a()), 25), new PossibleFishingResult(new ItemStack(Items.RAW_FISH, 1, EnumFish.CLOWNFISH.a()), 2), new PossibleFishingResult(new ItemStack(Items.RAW_FISH, 1, EnumFish.PUFFERFISH.a()), 13)}); - private int g = -1; - private int h = -1; - private int i = -1; - private Block at; - private boolean au; - public int a; - public EntityHuman owner; - private int av; - private int aw; - private int ax; - private int ay; - private int az; - private float aA; - public Entity hooked; - private int aB; - private double aC; - private double aD; - private double aE; - private double aF; - private double aG; - - public EntityFishingHook(World world) { - super(world); - this.a(0.25F, 0.25F); - this.ak = true; - } - - public EntityFishingHook(World world, EntityHuman entityhuman) { - super(world); - this.ak = true; - this.owner = entityhuman; - this.owner.hookedFish = this; - this.a(0.25F, 0.25F); - this.setPositionRotation(entityhuman.locX, entityhuman.locY + 1.62D - (double) entityhuman.height, entityhuman.locZ, entityhuman.yaw, entityhuman.pitch); - this.locX -= (double) (MathHelper.cos(this.yaw / 180.0F * 3.1415927F) * 0.16F); - this.locY -= 0.10000000149011612D; - this.locZ -= (double) (MathHelper.sin(this.yaw / 180.0F * 3.1415927F) * 0.16F); - this.setPosition(this.locX, this.locY, this.locZ); - this.height = 0.0F; - float f = 0.4F; - - this.motX = (double) (-MathHelper.sin(this.yaw / 180.0F * 3.1415927F) * MathHelper.cos(this.pitch / 180.0F * 3.1415927F) * f); - this.motZ = (double) (MathHelper.cos(this.yaw / 180.0F * 3.1415927F) * MathHelper.cos(this.pitch / 180.0F * 3.1415927F) * f); - this.motY = (double) (-MathHelper.sin(this.pitch / 180.0F * 3.1415927F) * f); - this.c(this.motX, this.motY, this.motZ, 1.5F, 1.0F); - } - - protected void c() {} - - public void c(double d0, double d1, double d2, float f, float f1) { - float f2 = MathHelper.sqrt(d0 * d0 + d1 * d1 + d2 * d2); - - d0 /= (double) f2; - d1 /= (double) f2; - d2 /= (double) f2; - d0 += this.random.nextGaussian() * 0.007499999832361937D * (double) f1; - d1 += this.random.nextGaussian() * 0.007499999832361937D * (double) f1; - d2 += this.random.nextGaussian() * 0.007499999832361937D * (double) f1; - d0 *= (double) f; - d1 *= (double) f; - d2 *= (double) f; - this.motX = d0; - this.motY = d1; - this.motZ = d2; - float f3 = MathHelper.sqrt(d0 * d0 + d2 * d2); - - this.lastYaw = this.yaw = (float) (Math.atan2(d0, d2) * 180.0D / 3.1415927410125732D); - this.lastPitch = this.pitch = (float) (Math.atan2(d1, (double) f3) * 180.0D / 3.1415927410125732D); - this.av = 0; - } - - public void h() { - super.h(); - if (this.aB > 0) { - double d0 = this.locX + (this.aC - this.locX) / (double) this.aB; - double d1 = this.locY + (this.aD - this.locY) / (double) this.aB; - double d2 = this.locZ + (this.aE - this.locZ) / (double) this.aB; - double d3 = MathHelper.g(this.aF - (double) this.yaw); - - this.yaw = (float) ((double) this.yaw + d3 / (double) this.aB); - this.pitch = (float) ((double) this.pitch + (this.aG - (double) this.pitch) / (double) this.aB); - --this.aB; - this.setPosition(d0, d1, d2); - this.b(this.yaw, this.pitch); - } else { - if (!this.world.isStatic) { - ItemStack itemstack = this.owner.bF(); - - if (this.owner.dead || !this.owner.isAlive() || itemstack == null || itemstack.getItem() != Items.FISHING_ROD || this.f(this.owner) > 1024.0D) { - this.die(); - this.owner.hookedFish = null; - return; - } - - if (this.hooked != null) { - if (!this.hooked.dead) { - this.locX = this.hooked.locX; - this.locY = this.hooked.boundingBox.b + (double) this.hooked.length * 0.8D; - this.locZ = this.hooked.locZ; - return; - } - - this.hooked = null; - } - } - - if (this.a > 0) { - --this.a; - } - - if (this.au) { - if (this.world.getType(this.g, this.h, this.i) == this.at) { - ++this.av; - if (this.av == 1200) { - this.die(); - } - - return; - } - - this.au = false; - this.motX *= (double) (this.random.nextFloat() * 0.2F); - this.motY *= (double) (this.random.nextFloat() * 0.2F); - this.motZ *= (double) (this.random.nextFloat() * 0.2F); - this.av = 0; - this.aw = 0; - } else { - ++this.aw; - } - - Vec3D vec3d = Vec3D.a(this.locX, this.locY, this.locZ); - Vec3D vec3d1 = Vec3D.a(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ); - MovingObjectPosition movingobjectposition = this.world.a(vec3d, vec3d1); - - vec3d = Vec3D.a(this.locX, this.locY, this.locZ); - vec3d1 = Vec3D.a(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ); - if (movingobjectposition != null) { - vec3d1 = Vec3D.a(movingobjectposition.pos.a, movingobjectposition.pos.b, movingobjectposition.pos.c); - } - - Entity entity = null; - List list = this.world.getEntities(this, this.boundingBox.a(this.motX, this.motY, this.motZ).grow(1.0D, 1.0D, 1.0D)); - double d4 = 0.0D; - - double d5; - - for (int i = 0; i < list.size(); ++i) { - Entity entity1 = (Entity) list.get(i); - - if (entity1.R() && (entity1 != this.owner || this.aw >= 5)) { - float f = 0.3F; - AxisAlignedBB axisalignedbb = entity1.boundingBox.grow((double) f, (double) f, (double) f); - MovingObjectPosition movingobjectposition1 = axisalignedbb.a(vec3d, vec3d1); - - if (movingobjectposition1 != null) { - d5 = vec3d.distanceSquared(movingobjectposition1.pos); // CraftBukkit - distance efficiency - if (d5 < d4 || d4 == 0.0D) { - entity = entity1; - d4 = d5; - } - } - } - } - - if (entity != null) { - movingobjectposition = new MovingObjectPosition(entity); - } - - if (movingobjectposition != null) { - org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this); // Craftbukkit - Call event - if (movingobjectposition.entity != null) { - if (movingobjectposition.entity.damageEntity(DamageSource.projectile(this, this.owner), 0.0F)) { - this.hooked = movingobjectposition.entity; - } - } else { - this.au = true; - } - } - - if (!this.au) { - this.move(this.motX, this.motY, 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); - - for (this.pitch = (float) (Math.atan2(this.motY, (double) f1) * 180.0D / 3.1415927410125732D); this.pitch - this.lastPitch < -180.0F; this.lastPitch -= 360.0F) { - ; - } - - while (this.pitch - this.lastPitch >= 180.0F) { - this.lastPitch += 360.0F; - } - - while (this.yaw - this.lastYaw < -180.0F) { - this.lastYaw -= 360.0F; - } - - while (this.yaw - this.lastYaw >= 180.0F) { - this.lastYaw += 360.0F; - } - - this.pitch = this.lastPitch + (this.pitch - this.lastPitch) * 0.2F; - this.yaw = this.lastYaw + (this.yaw - this.lastYaw) * 0.2F; - float f2 = 0.92F; - - if (this.onGround || this.positionChanged) { - f2 = 0.5F; - } - - byte b0 = 5; - double d6 = 0.0D; - - for (int j = 0; j < b0; ++j) { - double d7 = this.boundingBox.b + (this.boundingBox.e - this.boundingBox.b) * (double) (j + 0) / (double) b0 - 0.125D + 0.125D; - double d8 = this.boundingBox.b + (this.boundingBox.e - this.boundingBox.b) * (double) (j + 1) / (double) b0 - 0.125D + 0.125D; - AxisAlignedBB axisalignedbb1 = AxisAlignedBB.a(this.boundingBox.a, d7, this.boundingBox.c, this.boundingBox.d, d8, this.boundingBox.f); - - if (this.world.b(axisalignedbb1, Material.WATER)) { - d6 += 1.0D / (double) b0; - } - } - - if (!this.world.isStatic && d6 > 0.0D) { - WorldServer worldserver = (WorldServer) this.world; - int k = 1; - - if (this.random.nextFloat() < 0.25F && this.world.isRainingAt(MathHelper.floor(this.locX), MathHelper.floor(this.locY) + 1, MathHelper.floor(this.locZ))) { - k = 2; - } - - if (this.random.nextFloat() < 0.5F && !this.world.i(MathHelper.floor(this.locX), MathHelper.floor(this.locY) + 1, MathHelper.floor(this.locZ))) { - --k; - } - - if (this.ax > 0) { - --this.ax; - if (this.ax <= 0) { - this.ay = 0; - this.az = 0; - } - } else { - float f3; - double d9; - float f4; - float f5; - double d10; - double d11; - - if (this.az > 0) { - this.az -= k; - if (this.az <= 0) { - this.motY -= 0.20000000298023224D; - this.makeSound("random.splash", 0.25F, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F); - f4 = (float) MathHelper.floor(this.boundingBox.b); - worldserver.a("bubble", this.locX, (double) (f4 + 1.0F), this.locZ, (int) (1.0F + this.width * 20.0F), (double) this.width, 0.0D, (double) this.width, 0.20000000298023224D); - worldserver.a("wake", this.locX, (double) (f4 + 1.0F), this.locZ, (int) (1.0F + this.width * 20.0F), (double) this.width, 0.0D, (double) this.width, 0.20000000298023224D); - this.ax = MathHelper.nextInt(this.random, 10, 30); - } else { - this.aA = (float) ((double) this.aA + this.random.nextGaussian() * 4.0D); - f4 = this.aA * 0.017453292F; - f5 = MathHelper.sin(f4); - f3 = MathHelper.cos(f4); - d9 = this.locX + (double) (f5 * (float) this.az * 0.1F); - d11 = (double) ((float) MathHelper.floor(this.boundingBox.b) + 1.0F); - d10 = this.locZ + (double) (f3 * (float) this.az * 0.1F); - if (this.random.nextFloat() < 0.15F) { - worldserver.a("bubble", d9, d11 - 0.10000000149011612D, d10, 1, (double) f5, 0.1D, (double) f3, 0.0D); - } - - float f6 = f5 * 0.04F; - float f7 = f3 * 0.04F; - - worldserver.a("wake", d9, d11, d10, 0, (double) f7, 0.01D, (double) (-f6), 1.0D); - worldserver.a("wake", d9, d11, d10, 0, (double) (-f7), 0.01D, (double) f6, 1.0D); - } - } else if (this.ay > 0) { - this.ay -= k; - f4 = 0.15F; - if (this.ay < 20) { - f4 = (float) ((double) f4 + (double) (20 - this.ay) * 0.05D); - } else if (this.ay < 40) { - f4 = (float) ((double) f4 + (double) (40 - this.ay) * 0.02D); - } else if (this.ay < 60) { - f4 = (float) ((double) f4 + (double) (60 - this.ay) * 0.01D); - } - - if (this.random.nextFloat() < f4) { - f5 = MathHelper.a(this.random, 0.0F, 360.0F) * 0.017453292F; - f3 = MathHelper.a(this.random, 25.0F, 60.0F); - d9 = this.locX + (double) (MathHelper.sin(f5) * f3 * 0.1F); - d11 = (double) ((float) MathHelper.floor(this.boundingBox.b) + 1.0F); - d10 = this.locZ + (double) (MathHelper.cos(f5) * f3 * 0.1F); - worldserver.a("splash", d9, d11, d10, 2 + this.random.nextInt(2), 0.10000000149011612D, 0.0D, 0.10000000149011612D, 0.0D); - } - - if (this.ay <= 0) { - this.aA = MathHelper.a(this.random, 0.0F, 360.0F); - this.az = MathHelper.nextInt(this.random, 20, 80); - } - } else { - this.ay = MathHelper.nextInt(this.random, 100, 900); - this.ay -= EnchantmentManager.getLureEnchantmentLevel(this.owner) * 20 * 5; - } - } - - if (this.ax > 0) { - this.motY -= (double) (this.random.nextFloat() * this.random.nextFloat() * this.random.nextFloat()) * 0.2D; - } - } - - d5 = d6 * 2.0D - 1.0D; - this.motY += 0.03999999910593033D * d5; - if (d6 > 0.0D) { - f2 = (float) ((double) f2 * 0.9D); - this.motY *= 0.8D; - } - - this.motX *= (double) f2; - this.motY *= (double) f2; - this.motZ *= (double) f2; - this.setPosition(this.locX, this.locY, this.locZ); - } - } - } - - public void b(NBTTagCompound nbttagcompound) { - nbttagcompound.setShort("xTile", (short) this.g); - nbttagcompound.setShort("yTile", (short) this.h); - nbttagcompound.setShort("zTile", (short) this.i); - nbttagcompound.setByte("inTile", (byte) Block.getId(this.at)); - nbttagcompound.setByte("shake", (byte) this.a); - nbttagcompound.setByte("inGround", (byte) (this.au ? 1 : 0)); - } - - public void a(NBTTagCompound nbttagcompound) { - this.g = nbttagcompound.getShort("xTile"); - this.h = nbttagcompound.getShort("yTile"); - this.i = nbttagcompound.getShort("zTile"); - this.at = Block.getById(nbttagcompound.getByte("inTile") & 255); - this.a = nbttagcompound.getByte("shake") & 255; - this.au = nbttagcompound.getByte("inGround") == 1; - } - - public int e() { - if (this.world.isStatic) { - return 0; - } else { - byte b0 = 0; - - if (this.hooked != null) { - // CraftBukkit start - PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), this.hooked.getBukkitEntity(), (Fish) this.getBukkitEntity(), PlayerFishEvent.State.CAUGHT_ENTITY); - this.world.getServer().getPluginManager().callEvent(playerFishEvent); - - if (playerFishEvent.isCancelled()) { - return 0; - } - // CraftBukkit end - - double d0 = this.owner.locX - this.locX; - double d1 = this.owner.locY - this.locY; - double d2 = this.owner.locZ - this.locZ; - double d3 = (double) MathHelper.sqrt(d0 * d0 + d1 * d1 + d2 * d2); - double d4 = 0.1D; - - this.hooked.motX += d0 * d4; - this.hooked.motY += d1 * d4 + (double) MathHelper.sqrt(d3) * 0.08D; - this.hooked.motZ += d2 * d4; - b0 = 3; - } else if (this.ax > 0) { - EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY, this.locZ, this.f()); - // CraftBukkit start - PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), entityitem.getBukkitEntity(), (Fish) this.getBukkitEntity(), PlayerFishEvent.State.CAUGHT_FISH); - playerFishEvent.setExpToDrop(this.random.nextInt(6) + 1); - this.world.getServer().getPluginManager().callEvent(playerFishEvent); - - if (playerFishEvent.isCancelled()) { - return 0; - } - // CraftBukkit end - - double d5 = this.owner.locX - this.locX; - double d6 = this.owner.locY - this.locY; - double d7 = this.owner.locZ - this.locZ; - double d8 = (double) MathHelper.sqrt(d5 * d5 + d6 * d6 + d7 * d7); - double d9 = 0.1D; - - entityitem.motX = d5 * d9; - entityitem.motY = d6 * d9 + (double) MathHelper.sqrt(d8) * 0.08D; - entityitem.motZ = d7 * d9; - this.world.addEntity(entityitem); - // CraftBukkit - this.random.nextInt(6) + 1 -> playerFishEvent.getExpToDrop() - this.owner.world.addEntity(new EntityExperienceOrb(this.owner.world, this.owner.locX, this.owner.locY + 0.5D, this.owner.locZ + 0.5D, playerFishEvent.getExpToDrop())); - b0 = 1; - } - - if (this.au) { - // CraftBukkit start - PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), null, (Fish) this.getBukkitEntity(), PlayerFishEvent.State.IN_GROUND); - this.world.getServer().getPluginManager().callEvent(playerFishEvent); - - if (playerFishEvent.isCancelled()) { - return 0; - } - // CraftBukkit end - - b0 = 2; - } - - // CraftBukkit start - if (b0 == 0) { - PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), null, (Fish) this.getBukkitEntity(), PlayerFishEvent.State.FAILED_ATTEMPT); - this.world.getServer().getPluginManager().callEvent(playerFishEvent); - if (playerFishEvent.isCancelled()) { - return 0; - } - } - // CraftBukkit end - - this.die(); - this.owner.hookedFish = null; - return b0; - } - } - - private ItemStack f() { - float f = this.world.random.nextFloat(); - int i = EnchantmentManager.getLuckEnchantmentLevel(this.owner); - int j = EnchantmentManager.getLureEnchantmentLevel(this.owner); - float f1 = 0.1F - (float) i * 0.025F - (float) j * 0.01F; - float f2 = 0.05F + (float) i * 0.01F - (float) j * 0.01F; - - f1 = MathHelper.a(f1, 0.0F, 1.0F); - f2 = MathHelper.a(f2, 0.0F, 1.0F); - if (f < f1) { - this.owner.a(StatisticList.A, 1); - return ((PossibleFishingResult) WeightedRandom.a(this.random, (Collection) d)).a(this.random); - } else { - f -= f1; - if (f < f2) { - this.owner.a(StatisticList.B, 1); - return ((PossibleFishingResult) WeightedRandom.a(this.random, (Collection) e)).a(this.random); - } else { - float f3 = f - f2; - - this.owner.a(StatisticList.z, 1); - return ((PossibleFishingResult) WeightedRandom.a(this.random, (Collection) EntityFishingHook.f)).a(this.random); // CraftBukkit - fix static reference to fish list - } - } - } - - public void die() { - super.die(); - if (this.owner != null) { - this.owner.hookedFish = null; - } - } -} diff --git a/src/main/java/net/minecraft/server/EntityGhast.java b/src/main/java/net/minecraft/server/EntityGhast.java deleted file mode 100644 index d543fcae..00000000 --- a/src/main/java/net/minecraft/server/EntityGhast.java +++ /dev/null @@ -1,238 +0,0 @@ -package net.minecraft.server; - -// CraftBukkit start -import org.bukkit.craftbukkit.entity.CraftEntity; -import org.bukkit.event.entity.EntityTargetEvent; -// CraftBukkit end - -public class EntityGhast extends EntityFlying implements IMonster { - - public int h; - public double i; - public double bm; - public double bn; - private Entity target; - private int br; - public int bo; - public int bp; - private int explosionPower = 1; - - public EntityGhast(World world) { - super(world); - this.a(4.0F, 4.0F); - this.fireProof = true; - this.b = 5; - } - - public boolean damageEntity(DamageSource damagesource, float f) { - if (this.isInvulnerable()) { - return false; - } else if ("fireball".equals(damagesource.p()) && damagesource.getEntity() instanceof EntityHuman) { - super.damageEntity(damagesource, 1000.0F); - ((EntityHuman) damagesource.getEntity()).a((Statistic) AchievementList.z); - return true; - } else { - return super.damageEntity(damagesource, f); - } - } - - protected void c() { - super.c(); - this.datawatcher.a(16, Byte.valueOf((byte) 0)); - } - - protected void aD() { - super.aD(); - this.getAttributeInstance(GenericAttributes.maxHealth).setValue(10.0D); - } - - protected void bq() { - if (!this.world.isStatic && this.world.difficulty == EnumDifficulty.PEACEFUL) { - this.die(); - } - - this.w(); - this.bo = this.bp; - double d0 = this.i - this.locX; - double d1 = this.bm - this.locY; - double d2 = this.bn - this.locZ; - double d3 = d0 * d0 + d1 * d1 + d2 * d2; - - if (d3 < 1.0D || d3 > 3600.0D) { - this.i = this.locX + (double) ((this.random.nextFloat() * 2.0F - 1.0F) * 16.0F); - this.bm = this.locY + (double) ((this.random.nextFloat() * 2.0F - 1.0F) * 16.0F); - this.bn = this.locZ + (double) ((this.random.nextFloat() * 2.0F - 1.0F) * 16.0F); - } - - if (this.h-- <= 0) { - this.h += this.random.nextInt(5) + 2; - d3 = (double) MathHelper.sqrt(d3); - if (this.a(this.i, this.bm, this.bn, d3)) { - this.motX += d0 / d3 * 0.1D; - this.motY += d1 / d3 * 0.1D; - this.motZ += d2 / d3 * 0.1D; - } else { - this.i = this.locX; - this.bm = this.locY; - this.bn = this.locZ; - } - } - - if (this.target != null && this.target.dead) { - // CraftBukkit start - fire EntityTargetEvent - EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), null, EntityTargetEvent.TargetReason.TARGET_DIED); - this.world.getServer().getPluginManager().callEvent(event); - - if (!event.isCancelled()) { - if (event.getTarget() == null) { - this.target = null; - } else { - this.target = ((CraftEntity) event.getTarget()).getHandle(); - } - } - // CraftBukkit end - } - - if (this.target == null || this.br-- <= 0) { - // CraftBukkit start - fire EntityTargetEvent - Entity target = this.world.findNearbyVulnerablePlayer(this, 100.0D); - if (target != null) { - EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), target.getBukkitEntity(), EntityTargetEvent.TargetReason.CLOSEST_PLAYER); - this.world.getServer().getPluginManager().callEvent(event); - - if (!event.isCancelled()) { - if (event.getTarget() == null) { - this.target = null; - } else { - this.target = ((CraftEntity) event.getTarget()).getHandle(); - } - } - } - // CraftBukkit end - - if (this.target != null) { - this.br = 20; - } - } - - double d4 = 64.0D; - - if (this.target != null && this.target.f((Entity) this) < d4 * d4) { - double d5 = this.target.locX - this.locX; - 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.aM = this.yaw = -((float) Math.atan2(d5, d7)) * 180.0F / 3.1415927F; - if (this.hasLineOfSight(this.target)) { - if (this.bp == 10) { - this.world.a((EntityHuman) null, 1007, (int) this.locX, (int) this.locY, (int) this.locZ, 0); - } - - ++this.bp; - if (this.bp == 20) { - this.world.a((EntityHuman) null, 1008, (int) this.locX, (int) this.locY, (int) this.locZ, 0); - EntityLargeFireball entitylargefireball = new EntityLargeFireball(this.world, this, d5, d6, d7); - - // CraftBukkit - set bukkitYield when setting explosionpower - entitylargefireball.bukkitYield = entitylargefireball.yield = this.explosionPower; - double d8 = 4.0D; - Vec3D vec3d = this.j(1.0F); - - entitylargefireball.locX = this.locX + vec3d.a * d8; - entitylargefireball.locY = this.locY + (double) (this.length / 2.0F) + 0.5D; - entitylargefireball.locZ = this.locZ + vec3d.c * d8; - this.world.addEntity(entitylargefireball); - this.bp = -40; - } - } else if (this.bp > 0) { - --this.bp; - } - } else { - this.aM = this.yaw = -((float) Math.atan2(this.motX, this.motZ)) * 180.0F / 3.1415927F; - if (this.bp > 0) { - --this.bp; - } - } - - if (!this.world.isStatic) { - byte b0 = this.datawatcher.getByte(16); - byte b1 = (byte) (this.bp > 10 ? 1 : 0); - - if (b0 != b1) { - this.datawatcher.watch(16, Byte.valueOf(b1)); - } - } - } - - private boolean a(double d0, double d1, double d2, double d3) { - double d4 = (this.i - this.locX) / d3; - double d5 = (this.bm - this.locY) / d3; - double d6 = (this.bn - this.locZ) / d3; - AxisAlignedBB axisalignedbb = this.boundingBox.clone(); - - for (int i = 1; (double) i < d3; ++i) { - axisalignedbb.d(d4, d5, d6); - if (!this.world.getCubes(this, axisalignedbb).isEmpty()) { - return false; - } - } - - return true; - } - - protected String t() { - return "mob.ghast.moan"; - } - - protected String aT() { - return "mob.ghast.scream"; - } - - protected String aU() { - return "mob.ghast.death"; - } - - protected Item getLoot() { - return Items.SULPHUR; - } - - protected void dropDeathLoot(boolean flag, int i) { - int j = this.random.nextInt(2) + this.random.nextInt(1 + i); - - int k; - - for (k = 0; k < j; ++k) { - this.a(Items.GHAST_TEAR, 1); - } - - j = this.random.nextInt(3) + this.random.nextInt(1 + i); - - for (k = 0; k < j; ++k) { - this.a(Items.SULPHUR, 1); - } - } - - protected float bf() { - return 10.0F; - } - - public boolean canSpawn() { - return this.random.nextInt(20) == 0 && super.canSpawn() && this.world.difficulty != EnumDifficulty.PEACEFUL; - } - - public int bB() { - return 1; - } - - public void b(NBTTagCompound nbttagcompound) { - super.b(nbttagcompound); - nbttagcompound.setInt("ExplosionPower", this.explosionPower); - } - - public void a(NBTTagCompound nbttagcompound) { - super.a(nbttagcompound); - if (nbttagcompound.hasKeyOfType("ExplosionPower", 99)) { - this.explosionPower = nbttagcompound.getInt("ExplosionPower"); - } - } -} diff --git a/src/main/java/net/minecraft/server/EntityHanging.java b/src/main/java/net/minecraft/server/EntityHanging.java deleted file mode 100644 index eec465b4..00000000 --- a/src/main/java/net/minecraft/server/EntityHanging.java +++ /dev/null @@ -1,340 +0,0 @@ -package net.minecraft.server; - -import java.util.Iterator; -import java.util.List; - -// CraftBukkit start -import org.bukkit.entity.Hanging; -import org.bukkit.entity.Painting; -import org.bukkit.event.hanging.HangingBreakEvent; -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.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 c() {} - - public void setDirection(int i) { - this.direction = i; - this.lastYaw = this.yaw = (float) (i * 90); - float f = (float) this.f(); - float f1 = (float) this.i(); - float f2 = (float) this.f(); - - 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.c(this.f()); - } - - if (i == 1) { - f5 += this.c(this.f()); - } - - if (i == 0) { - f3 += this.c(this.f()); - } - - if (i == 3) { - f5 -= this.c(this.f()); - } - - f4 += this.c(this.i()); - 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 c(int i) { - return i == 32 ? 0.5F : (i == 64 ? 0.5F : 0.0F); - } - - public void h() { - this.lastX = this.locX; - this.lastY = this.locY; - this.lastZ = this.locZ; - if (this.e++ == 100 && !this.world.isStatic) { - this.e = 0; - if (!this.dead && !this.survives()) { - // CraftBukkit start - fire break events - Material material = this.world.getType((int) this.locX, (int) this.locY, (int) this.locZ).getMaterial(); - HangingBreakEvent.RemoveCause cause; - - if (!material.equals(Material.AIR)) { - // TODO: This feels insufficient to catch 100% of suffocation cases - cause = HangingBreakEvent.RemoveCause.OBSTRUCTION; - } else { - cause = HangingBreakEvent.RemoveCause.PHYSICS; - } - - HangingBreakEvent event = new HangingBreakEvent((Hanging) this.getBukkitEntity(), cause); - this.world.getServer().getPluginManager().callEvent(event); - - PaintingBreakEvent paintingEvent = null; - if (this instanceof EntityPainting) { - // Fire old painting event until it can be removed - paintingEvent = new PaintingBreakEvent((Painting) this.getBukkitEntity(), PaintingBreakEvent.RemoveCause.valueOf(cause.name())); - paintingEvent.setCancelled(event.isCancelled()); - this.world.getServer().getPluginManager().callEvent(paintingEvent); - } - - if (dead || event.isCancelled() || (paintingEvent != null && paintingEvent.isCancelled())) { - return; - } - // CraftBukkit end - - this.die(); - this.b((Entity) null); - } - } - } - - public boolean survives() { - if (!this.world.getCubes(this, this.boundingBox).isEmpty()) { - return false; - } else { - int i = Math.max(1, this.f() / 16); - int j = Math.max(1, this.i() / 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.f() / 32.0F)); - } - - if (this.direction == 1) { - i1 = MathHelper.floor(this.locZ - (double) ((float) this.f() / 32.0F)); - } - - if (this.direction == 0) { - k = MathHelper.floor(this.locX - (double) ((float) this.f() / 32.0F)); - } - - if (this.direction == 3) { - i1 = MathHelper.floor(this.locZ - (double) ((float) this.f() / 32.0F)); - } - - l = MathHelper.floor(this.locY - (double) ((float) this.i() / 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.getType(this.x, l + k1, i1 + j1).getMaterial(); - } else { - material = this.world.getType(k + j1, l + k1, this.z).getMaterial(); - } - - 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 R() { - return true; - } - - public boolean j(Entity entity) { - return entity instanceof EntityHuman ? this.damageEntity(DamageSource.playerAttack((EntityHuman) entity), 0.0F) : false; - } - - public void i(int i) { - this.world.X(); - } - - public boolean damageEntity(DamageSource damagesource, float f) { - if (this.isInvulnerable()) { - return false; - } else { - if (!this.dead && !this.world.isStatic) { - // CraftBukkit start - fire break events - HangingBreakEvent event = new HangingBreakEvent((Hanging) this.getBukkitEntity(), HangingBreakEvent.RemoveCause.DEFAULT); - PaintingBreakEvent paintingEvent = null; - if (damagesource.getEntity() != null) { - event = new org.bukkit.event.hanging.HangingBreakByEntityEvent((Hanging) this.getBukkitEntity(), damagesource.getEntity() == null ? null : damagesource.getEntity().getBukkitEntity()); - - if (this instanceof EntityPainting) { - // Fire old painting event until it can be removed - paintingEvent = new org.bukkit.event.painting.PaintingBreakByEntityEvent((Painting) this.getBukkitEntity(), damagesource.getEntity() == null ? null : damagesource.getEntity().getBukkitEntity()); - } - } else if (damagesource.isExplosion()) { - event = new HangingBreakEvent((Hanging) this.getBukkitEntity(), HangingBreakEvent.RemoveCause.EXPLOSION); - } - - this.world.getServer().getPluginManager().callEvent(event); - - if (paintingEvent != null) { - paintingEvent.setCancelled(event.isCancelled()); - this.world.getServer().getPluginManager().callEvent(paintingEvent); - } - - if (this.dead || event.isCancelled() || (paintingEvent != null && paintingEvent.isCancelled())) { - return true; - } - // CraftBukkit end - - this.die(); - this.Q(); - this.b(damagesource.getEntity()); - } - - 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 (this.dead) return; // CraftBukkit - - // CraftBukkit start - fire break events - // TODO - Does this need its own cause? Seems to only be triggered by pistons - HangingBreakEvent event = new HangingBreakEvent((Hanging) this.getBukkitEntity(), HangingBreakEvent.RemoveCause.PHYSICS); - this.world.getServer().getPluginManager().callEvent(event); - - if (this.dead || event.isCancelled()) { - return; - } - // CraftBukkit end - - this.die(); - this.b((Entity) null); - } - } - - 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.b((Entity) null); - } - } - - 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.hasKeyOfType("Direction", 99)) { - 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 f(); - - public abstract int i(); - - public abstract void b(Entity entity); - - protected boolean V() { - return false; - } -} diff --git a/src/main/java/net/minecraft/server/EntityHorse.java b/src/main/java/net/minecraft/server/EntityHorse.java deleted file mode 100644 index d167c001..00000000 --- a/src/main/java/net/minecraft/server/EntityHorse.java +++ /dev/null @@ -1,1226 +0,0 @@ -package net.minecraft.server; - -import java.util.Iterator; -import java.util.List; - -import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; // CraftBukkit - -public class EntityHorse extends EntityAnimal implements IInventoryListener { - - private static final IEntitySelector bu = new EntitySelectorHorse(); - public static final IAttribute attributeJumpStrength = (new AttributeRanged("horse.jumpStrength", 0.7D, 0.0D, 2.0D)).a("Jump Strength").a(true); // CraftBukkit - private -> public - private static final String[] bw = new String[] { null, "textures/entity/horse/armor/horse_armor_iron.png", "textures/entity/horse/armor/horse_armor_gold.png", "textures/entity/horse/armor/horse_armor_diamond.png"}; - private static final String[] bx = new String[] { "", "meo", "goo", "dio"}; - private static final int[] by = new int[] { 0, 5, 7, 11}; - private static final String[] bz = new String[] { "textures/entity/horse/horse_white.png", "textures/entity/horse/horse_creamy.png", "textures/entity/horse/horse_chestnut.png", "textures/entity/horse/horse_brown.png", "textures/entity/horse/horse_black.png", "textures/entity/horse/horse_gray.png", "textures/entity/horse/horse_darkbrown.png"}; - private static final String[] bA = new String[] { "hwh", "hcr", "hch", "hbr", "hbl", "hgr", "hdb"}; - private static final String[] bB = new String[] { null, "textures/entity/horse/horse_markings_white.png", "textures/entity/horse/horse_markings_whitefield.png", "textures/entity/horse/horse_markings_whitedots.png", "textures/entity/horse/horse_markings_blackdots.png"}; - private static final String[] bC = new String[] { "", "wo_", "wmo", "wdo", "bdo"}; - private int bD; - private int bE; - private int bF; - public int bp; - public int bq; - protected boolean br; - public InventoryHorseChest inventoryChest; // CraftBukkit - private -> public - private boolean bH; - protected int bs; - protected float bt; - private boolean bI; - private float bJ; - private float bK; - private float bL; - private float bM; - private float bN; - private float bO; - private int bP; - private String bQ; - private String[] bR = new String[3]; - public int maxDomestication = 100; // CraftBukkit - store max domestication value - - public EntityHorse(World world) { - super(world); - this.a(1.4F, 1.6F); - this.fireProof = false; - this.setHasChest(false); - this.getNavigation().a(true); - this.goalSelector.a(0, new PathfinderGoalFloat(this)); - this.goalSelector.a(1, new PathfinderGoalPanic(this, 1.2D)); - this.goalSelector.a(1, new PathfinderGoalTame(this, 1.2D)); - this.goalSelector.a(2, new PathfinderGoalBreed(this, 1.0D)); - this.goalSelector.a(4, new PathfinderGoalFollowParent(this, 1.0D)); - this.goalSelector.a(6, new PathfinderGoalRandomStroll(this, 0.7D)); - this.goalSelector.a(7, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 6.0F)); - this.goalSelector.a(8, new PathfinderGoalRandomLookaround(this)); - this.loadChest(); - } - - protected void c() { - super.c(); - this.datawatcher.a(16, Integer.valueOf(0)); - this.datawatcher.a(19, Byte.valueOf((byte) 0)); - this.datawatcher.a(20, Integer.valueOf(0)); - this.datawatcher.a(21, String.valueOf("")); - this.datawatcher.a(22, Integer.valueOf(0)); - } - - public void setType(int i) { - this.datawatcher.watch(19, Byte.valueOf((byte) i)); - this.cP(); - } - - public int getType() { - return this.datawatcher.getByte(19); - } - - public void setVariant(int i) { - this.datawatcher.watch(20, Integer.valueOf(i)); - this.cP(); - } - - public int getVariant() { - return this.datawatcher.getInt(20); - } - - public String getName() { - if (this.hasCustomName()) { - return this.getCustomName(); - } else { - int i = this.getType(); - - switch (i) { - case 0: - default: - return LocaleI18n.get("entity.horse.name"); - - case 1: - return LocaleI18n.get("entity.donkey.name"); - - case 2: - return LocaleI18n.get("entity.mule.name"); - - case 3: - return LocaleI18n.get("entity.zombiehorse.name"); - - case 4: - return LocaleI18n.get("entity.skeletonhorse.name"); - } - } - } - - private boolean x(int i) { - return (this.datawatcher.getInt(16) & i) != 0; - } - - private void b(int i, boolean flag) { - int j = this.datawatcher.getInt(16); - - if (flag) { - this.datawatcher.watch(16, Integer.valueOf(j | i)); - } else { - this.datawatcher.watch(16, Integer.valueOf(j & ~i)); - } - } - - public boolean cb() { - return !this.isBaby(); - } - - public boolean isTame() { - return this.x(2); - } - - public boolean cg() { - return this.cb(); - } - - public String getOwnerUUID() { - return this.datawatcher.getString(21); - } - - public void setOwnerUUID(String s) { - this.datawatcher.watch(21, s); - } - - public float ci() { - int i = this.getAge(); - - return i >= 0 ? 1.0F : 0.5F + (float) (-24000 - i) / -24000.0F * 0.5F; - } - - public void a(boolean flag) { - if (flag) { - this.a(this.ci()); - } else { - this.a(1.0F); - } - } - - public boolean cj() { - return this.br; - } - - public void setTame(boolean flag) { - this.b(2, flag); - } - - public void j(boolean flag) { - this.br = flag; - } - - public boolean bM() { - return !this.cE() && super.bM(); - } - - protected void o(float f) { - if (f > 6.0F && this.cm()) { - this.o(false); - } - } - - public boolean hasChest() { - return this.x(8); - } - - public int cl() { - return this.datawatcher.getInt(22); - } - - private int e(ItemStack itemstack) { - if (itemstack == null) { - return 0; - } else { - Item item = itemstack.getItem(); - - return item == Items.HORSE_ARMOR_IRON ? 1 : (item == Items.HORSE_ARMOR_GOLD ? 2 : (item == Items.HORSE_ARMOR_DIAMOND ? 3 : 0)); - } - } - - public boolean cm() { - return this.x(32); - } - - public boolean cn() { - return this.x(64); - } - - public boolean co() { - return this.x(16); - } - - public boolean cp() { - return this.bH; - } - - public void d(ItemStack itemstack) { - this.datawatcher.watch(22, Integer.valueOf(this.e(itemstack))); - this.cP(); - } - - public void k(boolean flag) { - this.b(16, flag); - } - - public void setHasChest(boolean flag) { - this.b(8, flag); - } - - public void m(boolean flag) { - this.bH = flag; - } - - public void n(boolean flag) { - this.b(4, flag); - } - - public int getTemper() { - return this.bs; - } - - public void setTemper(int i) { - this.bs = i; - } - - public int v(int i) { - int j = MathHelper.a(this.getTemper() + i, 0, this.getMaxDomestication()); - - this.setTemper(j); - return j; - } - - public boolean damageEntity(DamageSource damagesource, float f) { - Entity entity = damagesource.getEntity(); - - return this.passenger != null && this.passenger.equals(entity) ? false : super.damageEntity(damagesource, f); - } - - public int aV() { - return by[this.cl()]; - } - - public boolean S() { - return this.passenger == null; - } - - public boolean cr() { - int i = MathHelper.floor(this.locX); - int j = MathHelper.floor(this.locZ); - - this.world.getBiome(i, j); - return true; - } - - public void cs() { - if (!this.world.isStatic && this.hasChest()) { - this.a(Item.getItemOf(Blocks.CHEST), 1); - this.setHasChest(false); - } - } - - private void cL() { - this.cS(); - this.world.makeSound(this, "eating", 1.0F, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.2F); - } - - protected void b(float f) { - if (f > 1.0F) { - this.makeSound("mob.horse.land", 0.4F, 1.0F); - } - - int i = MathHelper.f(f * 0.5F - 3.0F); - - if (i > 0) { - this.damageEntity(DamageSource.FALL, (float) i); - if (this.passenger != null) { - this.passenger.damageEntity(DamageSource.FALL, (float) i); - } - - Block block = this.world.getType(MathHelper.floor(this.locX), MathHelper.floor(this.locY - 0.2D - (double) this.lastYaw), MathHelper.floor(this.locZ)); - - if (block.getMaterial() != Material.AIR) { - StepSound stepsound = block.stepSound; - - this.world.makeSound(this, stepsound.getStepSound(), stepsound.getVolume1() * 0.5F, stepsound.getVolume2() * 0.75F); - } - } - } - - private int cM() { - int i = this.getType(); - - return this.hasChest() /* && (i == 1 || i == 2) */ ? 17 : 2; // CraftBukkit - Remove type check - } - - public void loadChest() { // CraftBukkit - private -> public - InventoryHorseChest inventoryhorsechest = this.inventoryChest; - - this.inventoryChest = new InventoryHorseChest("HorseChest", this.cM(), this); // CraftBukkit - add this horse - this.inventoryChest.a(this.getName()); - if (inventoryhorsechest != null) { - inventoryhorsechest.b(this); - int i = Math.min(inventoryhorsechest.getSize(), this.inventoryChest.getSize()); - - for (int j = 0; j < i; ++j) { - ItemStack itemstack = inventoryhorsechest.getItem(j); - - if (itemstack != null) { - this.inventoryChest.setItem(j, itemstack.cloneItemStack()); - } - } - - inventoryhorsechest = null; - } - - this.inventoryChest.a(this); - this.cO(); - } - - private void cO() { - if (!this.world.isStatic) { - this.n(this.inventoryChest.getItem(0) != null); - if (this.cB()) { - this.d(this.inventoryChest.getItem(1)); - } - } - } - - public void a(InventorySubcontainer inventorysubcontainer) { - int i = this.cl(); - boolean flag = this.cu(); - - this.cO(); - if (this.ticksLived > 20) { - if (i == 0 && i != this.cl()) { - this.makeSound("mob.horse.armor", 0.5F, 1.0F); - } else if (i != this.cl()) { - this.makeSound("mob.horse.armor", 0.5F, 1.0F); - } - - if (!flag && this.cu()) { - this.makeSound("mob.horse.leather", 0.5F, 1.0F); - } - } - } - - public boolean canSpawn() { - this.cr(); - return super.canSpawn(); - } - - protected EntityHorse a(Entity entity, double d0) { - double d1 = Double.MAX_VALUE; - Entity entity1 = null; - List list = this.world.getEntities(entity, entity.boundingBox.a(d0, d0, d0), bu); - Iterator iterator = list.iterator(); - - while (iterator.hasNext()) { - Entity entity2 = (Entity) iterator.next(); - double d2 = entity2.e(entity.locX, entity.locY, entity.locZ); - - if (d2 < d1) { - entity1 = entity2; - d1 = d2; - } - } - - return (EntityHorse) entity1; - } - - public double getJumpStrength() { - return this.getAttributeInstance(attributeJumpStrength).getValue(); - } - - protected String aU() { - this.cS(); - int i = this.getType(); - - return i == 3 ? "mob.horse.zombie.death" : (i == 4 ? "mob.horse.skeleton.death" : (i != 1 && i != 2 ? "mob.horse.death" : "mob.horse.donkey.death")); - } - - protected Item getLoot() { - boolean flag = this.random.nextInt(4) == 0; - int i = this.getType(); - - return i == 4 ? Items.BONE : (i == 3 ? (flag ? Item.getById(0) : Items.ROTTEN_FLESH) : Items.LEATHER); - } - - protected String aT() { - this.cS(); - if (this.random.nextInt(3) == 0) { - this.cU(); - } - - int i = this.getType(); - - return i == 3 ? "mob.horse.zombie.hit" : (i == 4 ? "mob.horse.skeleton.hit" : (i != 1 && i != 2 ? "mob.horse.hit" : "mob.horse.donkey.hit")); - } - - public boolean cu() { - return this.x(4); - } - - protected String t() { - this.cS(); - if (this.random.nextInt(10) == 0 && !this.bh()) { - this.cU(); - } - - int i = this.getType(); - - return i == 3 ? "mob.horse.zombie.idle" : (i == 4 ? "mob.horse.skeleton.idle" : (i != 1 && i != 2 ? "mob.horse.idle" : "mob.horse.donkey.idle")); - } - - protected String cv() { - this.cS(); - this.cU(); - int i = this.getType(); - - return i != 3 && i != 4 ? (i != 1 && i != 2 ? "mob.horse.angry" : "mob.horse.donkey.angry") : null; - } - - protected void a(int i, int j, int k, Block block) { - StepSound stepsound = block.stepSound; - - if (this.world.getType(i, j + 1, k) == Blocks.SNOW) { - stepsound = Blocks.SNOW.stepSound; - } - - if (!block.getMaterial().isLiquid()) { - int l = this.getType(); - - if (this.passenger != null && l != 1 && l != 2) { - ++this.bP; - if (this.bP > 5 && this.bP % 3 == 0) { - this.makeSound("mob.horse.gallop", stepsound.getVolume1() * 0.15F, stepsound.getVolume2()); - if (l == 0 && this.random.nextInt(10) == 0) { - this.makeSound("mob.horse.breathe", stepsound.getVolume1() * 0.6F, stepsound.getVolume2()); - } - } else if (this.bP <= 5) { - this.makeSound("mob.horse.wood", stepsound.getVolume1() * 0.15F, stepsound.getVolume2()); - } - } else if (stepsound == Block.f) { - this.makeSound("mob.horse.wood", stepsound.getVolume1() * 0.15F, stepsound.getVolume2()); - } else { - this.makeSound("mob.horse.soft", stepsound.getVolume1() * 0.15F, stepsound.getVolume2()); - } - } - } - - protected void aD() { - super.aD(); - this.getAttributeMap().b(attributeJumpStrength); - this.getAttributeInstance(GenericAttributes.maxHealth).setValue(53.0D); - this.getAttributeInstance(GenericAttributes.d).setValue(0.22499999403953552D); - } - - public int bB() { - return 6; - } - - public int getMaxDomestication() { - return this.maxDomestication; // CraftBukkit - return stored max domestication instead of 100 - } - - protected float bf() { - return 0.8F; - } - - public int q() { - return 400; - } - - private void cP() { - this.bQ = null; - } - - public void g(EntityHuman entityhuman) { - if (!this.world.isStatic && (this.passenger == null || this.passenger == entityhuman) && this.isTame()) { - this.inventoryChest.a(this.getName()); - entityhuman.openHorseInventory(this, this.inventoryChest); - } - } - - public boolean a(EntityHuman entityhuman) { - ItemStack itemstack = entityhuman.inventory.getItemInHand(); - - if (itemstack != null && itemstack.getItem() == Items.MONSTER_EGG) { - return super.a(entityhuman); - } else if (!this.isTame() && this.cE()) { - return false; - } else if (this.isTame() && this.cb() && entityhuman.isSneaking()) { - this.g(entityhuman); - return true; - } else if (this.cg() && this.passenger != null) { - return super.a(entityhuman); - } else { - if (itemstack != null) { - boolean flag = false; - - if (this.cB()) { - byte b0 = -1; - - if (itemstack.getItem() == Items.HORSE_ARMOR_IRON) { - b0 = 1; - } else if (itemstack.getItem() == Items.HORSE_ARMOR_GOLD) { - b0 = 2; - } else if (itemstack.getItem() == Items.HORSE_ARMOR_DIAMOND) { - b0 = 3; - } - - if (b0 >= 0) { - if (!this.isTame()) { - this.cJ(); - return true; - } - - this.g(entityhuman); - return true; - } - } - - if (!flag && !this.cE()) { - float f = 0.0F; - short short1 = 0; - byte b1 = 0; - - if (itemstack.getItem() == Items.WHEAT) { - f = 2.0F; - short1 = 60; - b1 = 3; - } else if (itemstack.getItem() == Items.SUGAR) { - f = 1.0F; - short1 = 30; - b1 = 3; - } else if (itemstack.getItem() == Items.BREAD) { - f = 7.0F; - short1 = 180; - b1 = 3; - } else if (Block.a(itemstack.getItem()) == Blocks.HAY_BLOCK) { - f = 20.0F; - short1 = 180; - } else if (itemstack.getItem() == Items.APPLE) { - f = 3.0F; - short1 = 60; - b1 = 3; - } else if (itemstack.getItem() == Items.CARROT_GOLDEN) { - f = 4.0F; - short1 = 60; - b1 = 5; - if (this.isTame() && this.getAge() == 0) { - flag = true; - this.f(entityhuman); - } - } else if (itemstack.getItem() == Items.GOLDEN_APPLE) { - f = 10.0F; - short1 = 240; - b1 = 10; - if (this.isTame() && this.getAge() == 0) { - flag = true; - this.f(entityhuman); - } - } - - if (this.getHealth() < this.getMaxHealth() && f > 0.0F) { - this.heal(f, RegainReason.EATING); // CraftBukkit - flag = true; - } - - if (!this.cb() && short1 > 0) { - this.a(short1); - flag = true; - } - - if (b1 > 0 && (flag || !this.isTame()) && b1 < this.getMaxDomestication()) { - flag = true; - this.v(b1); - } - - if (flag) { - this.cL(); - } - } - - if (!this.isTame() && !flag) { - if (itemstack != null && itemstack.a(entityhuman, (EntityLiving) this)) { - return true; - } - - this.cJ(); - return true; - } - - if (!flag && this.cC() && !this.hasChest() && itemstack.getItem() == Item.getItemOf(Blocks.CHEST)) { - this.setHasChest(true); - this.makeSound("mob.chickenplop", 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); - flag = true; - this.loadChest(); - } - - if (!flag && this.cg() && !this.cu() && itemstack.getItem() == Items.SADDLE) { - this.g(entityhuman); - return true; - } - - if (flag) { - if (!entityhuman.abilities.canInstantlyBuild && --itemstack.count == 0) { - entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, (ItemStack) null); - } - - return true; - } - } - - if (this.cg() && this.passenger == null) { - if (itemstack != null && itemstack.a(entityhuman, (EntityLiving) this)) { - return true; - } else { - this.i(entityhuman); - return true; - } - } else { - return super.a(entityhuman); - } - } - } - - private void i(EntityHuman entityhuman) { - entityhuman.yaw = this.yaw; - entityhuman.pitch = this.pitch; - this.o(false); - this.p(false); - if (!this.world.isStatic) { - entityhuman.mount(this); - } - } - - public boolean cB() { - return this.getType() == 0; - } - - public boolean cC() { - int i = this.getType(); - - return i == 2 || i == 1; - } - - protected boolean bh() { - return this.passenger != null && this.cu() ? true : this.cm() || this.cn(); - } - - public boolean cE() { - int i = this.getType(); - - return i == 3 || i == 4; - } - - public boolean cF() { - return this.cE() || this.getType() == 2; - } - - public boolean c(ItemStack itemstack) { - return false; - } - - private void cR() { - this.bp = 1; - } - - public void die(DamageSource damagesource) { - super.die(damagesource); - /* CraftBukkit start - Handle chest dropping in dropDeathLoot below - if (!this.world.isStatic) { - this.dropChest(); - } - // CraftBukkit end */ - } - - // CraftBukkit start - Add method - protected void dropDeathLoot(boolean flag, int i) { - super.dropDeathLoot(flag, i); - - // Moved from die method above - if (!this.world.isStatic) { - this.dropChest(); - } - } - // CraftBukkit end - - public void e() { - if (this.random.nextInt(200) == 0) { - this.cR(); - } - - super.e(); - if (!this.world.isStatic) { - if (this.random.nextInt(900) == 0 && this.deathTicks == 0) { - this.heal(1.0F, RegainReason.REGEN); // CraftBukkit - } - - if (!this.cm() && this.passenger == null && this.random.nextInt(300) == 0 && this.world.getType(MathHelper.floor(this.locX), MathHelper.floor(this.locY) - 1, MathHelper.floor(this.locZ)) == Blocks.GRASS) { - this.o(true); - } - - if (this.cm() && ++this.bD > 50) { - this.bD = 0; - this.o(false); - } - - if (this.co() && !this.cb() && !this.cm()) { - EntityHorse entityhorse = this.a(this, 16.0D); - - if (entityhorse != null && this.f(entityhorse) > 4.0D) { - PathEntity pathentity = this.world.findPath(this, entityhorse, 16.0F, true, false, false, true); - - this.setPathEntity(pathentity); - } - } - } - } - - public void h() { - super.h(); - if (this.world.isStatic && this.datawatcher.a()) { - this.datawatcher.e(); - this.cP(); - } - - if (this.bE > 0 && ++this.bE > 30) { - this.bE = 0; - this.b(128, false); - } - - if (!this.world.isStatic && this.bF > 0 && ++this.bF > 20) { - this.bF = 0; - this.p(false); - } - - if (this.bp > 0 && ++this.bp > 8) { - this.bp = 0; - } - - if (this.bq > 0) { - ++this.bq; - if (this.bq > 300) { - this.bq = 0; - } - } - - this.bK = this.bJ; - if (this.cm()) { - this.bJ += (1.0F - this.bJ) * 0.4F + 0.05F; - if (this.bJ > 1.0F) { - this.bJ = 1.0F; - } - } else { - this.bJ += (0.0F - this.bJ) * 0.4F - 0.05F; - if (this.bJ < 0.0F) { - this.bJ = 0.0F; - } - } - - this.bM = this.bL; - if (this.cn()) { - this.bK = this.bJ = 0.0F; - this.bL += (1.0F - this.bL) * 0.4F + 0.05F; - if (this.bL > 1.0F) { - this.bL = 1.0F; - } - } else { - this.bI = false; - this.bL += (0.8F * this.bL * this.bL * this.bL - this.bL) * 0.6F - 0.05F; - if (this.bL < 0.0F) { - this.bL = 0.0F; - } - } - - this.bO = this.bN; - if (this.x(128)) { - this.bN += (1.0F - this.bN) * 0.7F + 0.05F; - if (this.bN > 1.0F) { - this.bN = 1.0F; - } - } else { - this.bN += (0.0F - this.bN) * 0.7F - 0.05F; - if (this.bN < 0.0F) { - this.bN = 0.0F; - } - } - } - - private void cS() { - if (!this.world.isStatic) { - this.bE = 1; - this.b(128, true); - } - } - - private boolean cT() { - return this.passenger == null && this.vehicle == null && this.isTame() && this.cb() && !this.cF() && this.getHealth() >= this.getMaxHealth(); - } - - public void e(boolean flag) { - this.b(32, flag); - } - - public void o(boolean flag) { - this.e(flag); - } - - public void p(boolean flag) { - if (flag) { - this.o(false); - } - - this.b(64, flag); - } - - private void cU() { - if (!this.world.isStatic) { - this.bF = 1; - this.p(true); - } - } - - public void cJ() { - this.cU(); - String s = this.cv(); - - if (s != null) { - this.makeSound(s, this.bf(), this.bg()); - } - } - - public void dropChest() { - this.a(this, this.inventoryChest); - this.cs(); - } - - private void a(Entity entity, InventoryHorseChest inventoryhorsechest) { - if (inventoryhorsechest != null && !this.world.isStatic) { - for (int i = 0; i < inventoryhorsechest.getSize(); ++i) { - ItemStack itemstack = inventoryhorsechest.getItem(i); - - if (itemstack != null) { - this.a(itemstack, 0.0F); - } - } - } - } - - public boolean h(EntityHuman entityhuman) { - this.setOwnerUUID(entityhuman.getUniqueID().toString()); - this.setTame(true); - return true; - } - - public void e(float f, float f1) { - if (this.passenger != null && this.passenger instanceof EntityLiving && this.cu()) { - this.lastYaw = this.yaw = this.passenger.yaw; - this.pitch = this.passenger.pitch * 0.5F; - this.b(this.yaw, this.pitch); - this.aO = this.aM = this.yaw; - f = ((EntityLiving) this.passenger).bd * 0.5F; - f1 = ((EntityLiving) this.passenger).be; - if (f1 <= 0.0F) { - f1 *= 0.25F; - this.bP = 0; - } - - if (this.onGround && this.bt == 0.0F && this.cn() && !this.bI) { - f = 0.0F; - f1 = 0.0F; - } - - if (this.bt > 0.0F && !this.cj() && this.onGround) { - this.motY = this.getJumpStrength() * (double) this.bt; - if (this.hasEffect(MobEffectList.JUMP)) { - this.motY += (double) ((float) (this.getEffect(MobEffectList.JUMP).getAmplifier() + 1) * 0.1F); - } - - this.j(true); - this.al = true; - if (f1 > 0.0F) { - float f2 = MathHelper.sin(this.yaw * 3.1415927F / 180.0F); - float f3 = MathHelper.cos(this.yaw * 3.1415927F / 180.0F); - - this.motX += (double) (-0.4F * f2 * this.bt); - this.motZ += (double) (0.4F * f3 * this.bt); - this.makeSound("mob.horse.jump", 0.4F, 1.0F); - } - - this.bt = 0.0F; - } - - this.W = 1.0F; - this.aQ = this.bl() * 0.1F; - if (!this.world.isStatic) { - this.i((float) this.getAttributeInstance(GenericAttributes.d).getValue()); - super.e(f, f1); - } - - if (this.onGround) { - this.bt = 0.0F; - this.j(false); - } - - this.aE = this.aF; - double d0 = this.locX - this.lastX; - double d1 = this.locZ - this.lastZ; - float f4 = MathHelper.sqrt(d0 * d0 + d1 * d1) * 4.0F; - - if (f4 > 1.0F) { - f4 = 1.0F; - } - - this.aF += (f4 - this.aF) * 0.4F; - this.aG += this.aF; - } else { - this.W = 0.5F; - this.aQ = 0.02F; - super.e(f, f1); - } - } - - public void b(NBTTagCompound nbttagcompound) { - super.b(nbttagcompound); - nbttagcompound.setBoolean("EatingHaystack", this.cm()); - nbttagcompound.setBoolean("ChestedHorse", this.hasChest()); - nbttagcompound.setBoolean("HasReproduced", this.cp()); - nbttagcompound.setBoolean("Bred", this.co()); - nbttagcompound.setInt("Type", this.getType()); - nbttagcompound.setInt("Variant", this.getVariant()); - nbttagcompound.setInt("Temper", this.getTemper()); - nbttagcompound.setBoolean("Tame", this.isTame()); - nbttagcompound.setString("OwnerUUID", this.getOwnerUUID()); - nbttagcompound.setInt("Bukkit.MaxDomestication", this.maxDomestication); // CraftBukkit - if (this.hasChest()) { - NBTTagList nbttaglist = new NBTTagList(); - - for (int i = 2; i < this.inventoryChest.getSize(); ++i) { - ItemStack itemstack = this.inventoryChest.getItem(i); - - if (itemstack != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - - nbttagcompound1.setByte("Slot", (byte) i); - itemstack.save(nbttagcompound1); - nbttaglist.add(nbttagcompound1); - } - } - - nbttagcompound.set("Items", nbttaglist); - } - - if (this.inventoryChest.getItem(1) != null) { - nbttagcompound.set("ArmorItem", this.inventoryChest.getItem(1).save(new NBTTagCompound())); - } - - if (this.inventoryChest.getItem(0) != null) { - nbttagcompound.set("SaddleItem", this.inventoryChest.getItem(0).save(new NBTTagCompound())); - } - } - - public void a(NBTTagCompound nbttagcompound) { - super.a(nbttagcompound); - this.o(nbttagcompound.getBoolean("EatingHaystack")); - this.k(nbttagcompound.getBoolean("Bred")); - this.setHasChest(nbttagcompound.getBoolean("ChestedHorse")); - this.m(nbttagcompound.getBoolean("HasReproduced")); - this.setType(nbttagcompound.getInt("Type")); - this.setVariant(nbttagcompound.getInt("Variant")); - this.setTemper(nbttagcompound.getInt("Temper")); - this.setTame(nbttagcompound.getBoolean("Tame")); - if (nbttagcompound.hasKeyOfType("OwnerUUID", 8)) { - this.setOwnerUUID(nbttagcompound.getString("OwnerUUID")); - } - // CraftBukkit start - if (nbttagcompound.hasKey("Bukkit.MaxDomestication")) { - this.maxDomestication = nbttagcompound.getInt("Bukkit.MaxDomestication"); - } - // CraftBukkit end - AttributeInstance attributeinstance = this.getAttributeMap().a("Speed"); - - if (attributeinstance != null) { - this.getAttributeInstance(GenericAttributes.d).setValue(attributeinstance.b() * 0.25D); - } - - if (this.hasChest()) { - NBTTagList nbttaglist = nbttagcompound.getList("Items", 10); - - this.loadChest(); - - for (int i = 0; i < nbttaglist.size(); ++i) { - NBTTagCompound nbttagcompound1 = nbttaglist.get(i); - int j = nbttagcompound1.getByte("Slot") & 255; - - if (j >= 2 && j < this.inventoryChest.getSize()) { - this.inventoryChest.setItem(j, ItemStack.createStack(nbttagcompound1)); - } - } - } - - ItemStack itemstack; - - if (nbttagcompound.hasKeyOfType("ArmorItem", 10)) { - itemstack = ItemStack.createStack(nbttagcompound.getCompound("ArmorItem")); - if (itemstack != null && a(itemstack.getItem())) { - this.inventoryChest.setItem(1, itemstack); - } - } - - if (nbttagcompound.hasKeyOfType("SaddleItem", 10)) { - itemstack = ItemStack.createStack(nbttagcompound.getCompound("SaddleItem")); - if (itemstack != null && itemstack.getItem() == Items.SADDLE) { - this.inventoryChest.setItem(0, itemstack); - } - } else if (nbttagcompound.getBoolean("Saddle")) { - this.inventoryChest.setItem(0, new ItemStack(Items.SADDLE)); - } - - this.cO(); - } - - public boolean mate(EntityAnimal entityanimal) { - if (entityanimal == this) { - return false; - } else if (entityanimal.getClass() != this.getClass()) { - return false; - } else { - EntityHorse entityhorse = (EntityHorse) entityanimal; - - if (this.cT() && entityhorse.cT()) { - int i = this.getType(); - int j = entityhorse.getType(); - - return i == j || i == 0 && j == 1 || i == 1 && j == 0; - } else { - return false; - } - } - } - - public EntityAgeable createChild(EntityAgeable entityageable) { - EntityHorse entityhorse = (EntityHorse) entityageable; - EntityHorse entityhorse1 = new EntityHorse(this.world); - int i = this.getType(); - int j = entityhorse.getType(); - int k = 0; - - if (i == j) { - k = i; - } else if (i == 0 && j == 1 || i == 1 && j == 0) { - k = 2; - } - - if (k == 0) { - int l = this.random.nextInt(9); - int i1; - - if (l < 4) { - i1 = this.getVariant() & 255; - } else if (l < 8) { - i1 = entityhorse.getVariant() & 255; - } else { - i1 = this.random.nextInt(7); - } - - int j1 = this.random.nextInt(5); - - if (j1 < 2) { - i1 |= this.getVariant() & '\uff00'; - } else if (j1 < 4) { - i1 |= entityhorse.getVariant() & '\uff00'; - } else { - i1 |= this.random.nextInt(5) << 8 & '\uff00'; - } - - entityhorse1.setVariant(i1); - } - - entityhorse1.setType(k); - double d0 = this.getAttributeInstance(GenericAttributes.maxHealth).b() + entityageable.getAttributeInstance(GenericAttributes.maxHealth).b() + (double) this.cV(); - - entityhorse1.getAttributeInstance(GenericAttributes.maxHealth).setValue(d0 / 3.0D); - double d1 = this.getAttributeInstance(attributeJumpStrength).b() + entityageable.getAttributeInstance(attributeJumpStrength).b() + this.cW(); - - entityhorse1.getAttributeInstance(attributeJumpStrength).setValue(d1 / 3.0D); - double d2 = this.getAttributeInstance(GenericAttributes.d).b() + entityageable.getAttributeInstance(GenericAttributes.d).b() + this.cX(); - - entityhorse1.getAttributeInstance(GenericAttributes.d).setValue(d2 / 3.0D); - return entityhorse1; - } - - public GroupDataEntity prepare(GroupDataEntity groupdataentity) { - Object object = super.prepare(groupdataentity); - boolean flag = false; - int i = 0; - int j; - - if (object instanceof GroupDataHorse) { - j = ((GroupDataHorse) object).a; - i = ((GroupDataHorse) object).b & 255 | this.random.nextInt(5) << 8; - } else { - if (this.random.nextInt(10) == 0) { - j = 1; - } else { - int k = this.random.nextInt(7); - int l = this.random.nextInt(5); - - j = 0; - i = k | l << 8; - } - - object = new GroupDataHorse(j, i); - } - - this.setType(j); - this.setVariant(i); - if (this.random.nextInt(5) == 0) { - this.setAge(-24000); - } - - if (j != 4 && j != 3) { - this.getAttributeInstance(GenericAttributes.maxHealth).setValue((double) this.cV()); - if (j == 0) { - this.getAttributeInstance(GenericAttributes.d).setValue(this.cX()); - } else { - this.getAttributeInstance(GenericAttributes.d).setValue(0.17499999701976776D); - } - } else { - this.getAttributeInstance(GenericAttributes.maxHealth).setValue(15.0D); - this.getAttributeInstance(GenericAttributes.d).setValue(0.20000000298023224D); - } - - if (j != 2 && j != 1) { - this.getAttributeInstance(attributeJumpStrength).setValue(this.cW()); - } else { - this.getAttributeInstance(attributeJumpStrength).setValue(0.5D); - } - - this.setHealth(this.getMaxHealth()); - return (GroupDataEntity) object; - } - - protected boolean bk() { - return true; - } - - public void w(int i) { - if (this.cu()) { - // CraftBukkit start - fire HorseJumpEvent, use event power - if (i < 0) { - i = 0; - } - - float power; - if (i >= 90) { - power = 1.0F; - } else { - power = 0.4F + 0.4F * (float) i / 90.0F; - } - - org.bukkit.event.entity.HorseJumpEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callHorseJumpEvent(this, power); - if (!event.isCancelled()) { - this.bI = true; - this.cU(); - this.bt = event.getPower(); - } - // CraftBukkit end - } - } - - public void ac() { - super.ac(); - if (this.bM > 0.0F) { - float f = MathHelper.sin(this.aM * 3.1415927F / 180.0F); - float f1 = MathHelper.cos(this.aM * 3.1415927F / 180.0F); - float f2 = 0.7F * this.bM; - float f3 = 0.15F * this.bM; - - this.passenger.setPosition(this.locX + (double) (f2 * f), this.locY + this.ad() + this.passenger.ad() + (double) f3, this.locZ - (double) (f2 * f1)); - if (this.passenger instanceof EntityLiving) { - ((EntityLiving) this.passenger).aM = this.aM; - } - } - } - - private float cV() { - return 15.0F + (float) this.random.nextInt(8) + (float) this.random.nextInt(9); - } - - private double cW() { - return 0.4000000059604645D + this.random.nextDouble() * 0.2D + this.random.nextDouble() * 0.2D + this.random.nextDouble() * 0.2D; - } - - private double cX() { - return (0.44999998807907104D + this.random.nextDouble() * 0.3D + this.random.nextDouble() * 0.3D + this.random.nextDouble() * 0.3D) * 0.25D; - } - - public static boolean a(Item item) { - return item == Items.HORSE_ARMOR_IRON || item == Items.HORSE_ARMOR_GOLD || item == Items.HORSE_ARMOR_DIAMOND; - } - - public boolean h_() { - return false; - } -} diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java deleted file mode 100644 index 331dbac1..00000000 --- a/src/main/java/net/minecraft/server/EntityHuman.java +++ /dev/null @@ -1,1599 +0,0 @@ -package net.minecraft.server; - -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.UUID; - -import net.minecraft.util.com.google.common.base.Charsets; -import net.minecraft.util.com.mojang.authlib.GameProfile; - -// CraftBukkit start -import org.bukkit.craftbukkit.entity.CraftHumanEntity; -import org.bukkit.craftbukkit.entity.CraftItem; -import org.bukkit.craftbukkit.inventory.CraftItemStack; -import org.bukkit.entity.Player; -import org.bukkit.event.entity.EntityCombustByEntityEvent; -import org.bukkit.event.player.PlayerBedEnterEvent; -import org.bukkit.event.player.PlayerBedLeaveEvent; -import org.bukkit.event.player.PlayerDropItemEvent; -import org.bukkit.event.player.PlayerItemConsumeEvent; -// CraftBukkit end - -public abstract class EntityHuman extends EntityLiving implements ICommandListener { - - public PlayerInventory inventory = new PlayerInventory(this); - private InventoryEnderChest enderChest = new InventoryEnderChest(); - public Container defaultContainer; - public Container activeContainer; - protected FoodMetaData foodData = new FoodMetaData(this); // CraftBukkit - add "this" to constructor - protected int bq; - public float br; - public float bs; - public int bt; - public double bu; - public double bv; - public double bw; - public double bx; - public double by; - public double bz; - // CraftBukkit start - public boolean sleeping; // protected -> public - public boolean fauxSleeping; - public String spawnWorld = ""; - - @Override - public CraftHumanEntity getBukkitEntity() { - return (CraftHumanEntity) super.getBukkitEntity(); - } - // CraftBukkit end - - public ChunkCoordinates bB; - public int sleepTicks; // CraftBukkit - private -> public - public float bC; - public float bD; - private ChunkCoordinates c; - private boolean d; - private ChunkCoordinates e; - public PlayerAbilities abilities = new PlayerAbilities(); - public int oldLevel = -1; // CraftBukkit - add field - public int expLevel; - public int expTotal; - public float exp; - private ItemStack f; - private int g; - protected float bI = 0.1F; - protected float bJ = 0.02F; - private int h; - private final GameProfile i; - public EntityFishingHook hookedFish; - - public EntityHuman(World world, GameProfile gameprofile) { - super(world); - this.uniqueID = a(gameprofile); - this.i = gameprofile; - 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.aZ = 180.0F; - this.maxFireTicks = 20; - } - - protected void aD() { - super.aD(); - this.getAttributeMap().b(GenericAttributes.e).setValue(1.0D); - } - - protected void c() { - super.c(); - this.datawatcher.a(16, Byte.valueOf((byte) 0)); - this.datawatcher.a(17, Float.valueOf(0.0F)); - this.datawatcher.a(18, Integer.valueOf(0)); - } - - public boolean by() { - return this.f != null; - } - - public void bA() { - if (this.f != null) { - this.f.b(this.world, this, this.g); - } - - this.bB(); - } - - public void bB() { - this.f = null; - this.g = 0; - if (!this.world.isStatic) { - this.e(false); - } - } - - public boolean isBlocking() { - return this.by() && this.f.getItem().d(this.f) == EnumAnimation.BLOCK; - } - - public void h() { - if (this.f != null) { - ItemStack itemstack = this.inventory.getItemInHand(); - - if (itemstack == this.f) { - if (this.g <= 25 && this.g % 4 == 0) { - this.c(itemstack, 5); - } - - if (--this.g == 0 && !this.world.isStatic) { - this.p(); - } - } else { - this.bB(); - } - } - - if (this.bt > 0) { - --this.bt; - } - - if (this.isSleeping()) { - ++this.sleepTicks; - if (this.sleepTicks > 100) { - this.sleepTicks = 100; - } - - if (!this.world.isStatic) { - if (!this.j()) { - this.a(true, true, false); - } else if (this.world.w()) { - this.a(false, true, true); - } - } - } else if (this.sleepTicks > 0) { - ++this.sleepTicks; - if (this.sleepTicks >= 110) { - this.sleepTicks = 0; - } - } - - super.h(); - if (!this.world.isStatic && this.activeContainer != null && !this.activeContainer.a(this)) { - this.closeInventory(); - this.activeContainer = this.defaultContainer; - } - - if (this.isBurning() && this.abilities.isInvulnerable) { - this.extinguish(); - } - - this.bu = this.bx; - this.bv = this.by; - this.bw = this.bz; - double d0 = this.locX - this.bx; - double d1 = this.locY - this.by; - double d2 = this.locZ - this.bz; - double d3 = 10.0D; - - if (d0 > d3) { - this.bu = this.bx = this.locX; - } - - if (d2 > d3) { - this.bw = this.bz = this.locZ; - } - - if (d1 > d3) { - this.bv = this.by = this.locY; - } - - if (d0 < -d3) { - this.bu = this.bx = this.locX; - } - - if (d2 < -d3) { - this.bw = this.bz = this.locZ; - } - - if (d1 < -d3) { - this.bv = this.by = this.locY; - } - - this.bx += d0 * 0.25D; - this.bz += d2 * 0.25D; - this.by += d1 * 0.25D; - if (this.vehicle == null) { - this.e = null; - } - - if (!this.world.isStatic) { - this.foodData.a(this); - this.a(StatisticList.g, 1); - } - } - - public int D() { - return this.abilities.isInvulnerable ? 0 : 80; - } - - protected String H() { - return "game.player.swim"; - } - - protected String O() { - return "game.player.swim.splash"; - } - - public int ai() { - return 10; - } - - public void makeSound(String s, float f, float f1) { - this.world.a(this, s, f, f1); - } - - protected void c(ItemStack itemstack, int i) { - if (itemstack.o() == EnumAnimation.DRINK) { - this.makeSound("random.drink", 0.5F, this.world.random.nextFloat() * 0.1F + 0.9F); - } - - if (itemstack.o() == EnumAnimation.EAT) { - for (int j = 0; j < i; ++j) { - Vec3D vec3d = Vec3D.a(((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(((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); - String s = "iconcrack_" + Item.getId(itemstack.getItem()); - - if (itemstack.usesData()) { - s = s + "_" + itemstack.getData(); - } - - this.world.addParticle(s, vec3d1.a, vec3d1.b, vec3d1.c, vec3d.a, vec3d.b + 0.05D, vec3d.c); - } - - this.makeSound("random.eat", 0.5F + 0.5F * (float) this.random.nextInt(2), (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); - } - } - - protected void p() { - if (this.f != null) { - this.c(this.f, 16); - int i = this.f.count; - - // CraftBukkit start - fire PlayerItemConsumeEvent - org.bukkit.inventory.ItemStack craftItem = CraftItemStack.asBukkitCopy(this.f); - PlayerItemConsumeEvent event = new PlayerItemConsumeEvent((Player) this.getBukkitEntity(), craftItem); - world.getServer().getPluginManager().callEvent(event); - - if (event.isCancelled()) { - // Update client - if (this instanceof EntityPlayer) { - ((EntityPlayer) this).playerConnection.sendPacket(new PacketPlayOutSetSlot((byte) 0, activeContainer.getSlot((IInventory) this.inventory, this.inventory.itemInHandIndex).index, this.f)); - } - return; - } - - // Plugin modified the item, process it but don't remove it - if (!craftItem.equals(event.getItem())) { - CraftItemStack.asNMSCopy(event.getItem()).b(this.world, this); - - // Update client - if (this instanceof EntityPlayer) { - ((EntityPlayer) this).playerConnection.sendPacket(new PacketPlayOutSetSlot((byte) 0, activeContainer.getSlot((IInventory) this.inventory, this.inventory.itemInHandIndex).index, this.f)); - } - return; - } - // CraftBukkit end - - ItemStack itemstack = this.f.b(this.world, this); - - 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.bB(); - } - } - - protected boolean bh() { - return this.getHealth() <= 0.0F || this.isSleeping(); - } - - // CraftBukkit - protected -> public - public void closeInventory() { - this.activeContainer = this.defaultContainer; - } - - public void mount(Entity entity) { - // CraftBukkit start - mirror Entity mount changes - this.setPassengerOf(entity); - } - - public void setPassengerOf(Entity entity) { - // CraftBukkit end - if (this.vehicle != null && entity == null) { - // CraftBukkit start - use parent method instead to correctly fire VehicleExitEvent - Entity originalVehicle = this.vehicle; - // First statement moved down, second statement handled in parent method. - /* - if (!this.world.isStatic) { - this.m(this.vehicle); - } - - if (this.vehicle != null) { - this.vehicle.passenger = null; - } - - this.vehicle = null; - */ - super.setPassengerOf(entity); - if (!this.world.isStatic && this.vehicle == null) { - this.m(originalVehicle); - } - // CraftBukkit end - } else { - super.setPassengerOf(entity); // CraftBukkit - call new parent - } - } - - public void ab() { - if (!this.world.isStatic && this.isSneaking()) { - this.mount((Entity) null); - this.setSneaking(false); - } else { - double d0 = this.locX; - double d1 = this.locY; - double d2 = this.locZ; - float f = this.yaw; - float f1 = this.pitch; - - super.ab(); - this.br = this.bs; - this.bs = 0.0F; - this.l(this.locX - d0, this.locY - d1, this.locZ - d2); - if (this.vehicle instanceof EntityPig) { - this.pitch = f1; - this.yaw = f; - this.aM = ((EntityPig) this.vehicle).aM; - } - } - } - - protected void bq() { - super.bq(); - this.bb(); - } - - public void e() { - if (this.bq > 0) { - --this.bq; - } - - if (this.world.difficulty == EnumDifficulty.PEACEFUL && this.getHealth() < this.getMaxHealth() && this.world.getGameRules().getBoolean("naturalRegeneration") && this.ticksLived % 20 * 12 == 0) { - // CraftBukkit - added regain reason of "REGEN" for filtering purposes. - this.heal(1.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.REGEN); - } - - this.inventory.k(); - this.br = this.bs; - super.e(); - AttributeInstance attributeinstance = this.getAttributeInstance(GenericAttributes.d); - - if (!this.world.isStatic) { - attributeinstance.setValue((double) this.abilities.b()); - } - - this.aQ = this.bJ; - if (this.isSprinting()) { - this.aQ = (float) ((double) this.aQ + (double) this.bJ * 0.3D); - } - - this.i((float) attributeinstance.getValue()); - float f = MathHelper.sqrt(this.motX * this.motX + this.motZ * this.motZ); - // CraftBukkit - Math -> TrigMath - float f1 = (float) org.bukkit.craftbukkit.TrigMath.atan(-this.motY * 0.20000000298023224D) * 15.0F; - - if (f > 0.1F) { - f = 0.1F; - } - - if (!this.onGround || this.getHealth() <= 0.0F) { - f = 0.0F; - } - - if (this.onGround || this.getHealth() <= 0.0F) { - f1 = 0.0F; - } - - this.bs += (f - this.bs) * 0.4F; - this.aJ += (f1 - this.aJ) * 0.8F; - if (this.getHealth() > 0.0F) { - AxisAlignedBB axisalignedbb = null; - - if (this.vehicle != null && !this.vehicle.dead) { - axisalignedbb = this.boundingBox.a(this.vehicle.boundingBox).grow(1.0D, 0.0D, 1.0D); - } else { - axisalignedbb = this.boundingBox.grow(1.0D, 0.5D, 1.0D); - } - - List list = this.world.getEntities(this, axisalignedbb); - - if (list != null) { - for (int i = 0; i < list.size(); ++i) { - Entity entity = (Entity) list.get(i); - - if (!entity.dead) { - this.d(entity); - } - } - } - } - } - - private void d(Entity entity) { - entity.b_(this); - } - - public int getScore() { - return this.datawatcher.getInt(18); - } - - public void setScore(int i) { - this.datawatcher.watch(18, Integer.valueOf(i)); - } - - public void addScore(int i) { - int j = this.getScore(); - - this.datawatcher.watch(18, Integer.valueOf(j + i)); - } - - public void die(DamageSource damagesource) { - super.die(damagesource); - this.a(0.2F, 0.2F); - this.setPosition(this.locX, this.locY, this.locZ); - this.motY = 0.10000000149011612D; - if (this.getName().equals("Notch")) { - this.a(new ItemStack(Items.APPLE, 1), true, false); - } - - if (!this.world.getGameRules().getBoolean("keepInventory")) { - this.inventory.m(); - } - - if (damagesource != null) { - this.motX = (double) (-MathHelper.cos((this.az + this.yaw) * 3.1415927F / 180.0F) * 0.1F); - this.motZ = (double) (-MathHelper.sin((this.az + this.yaw) * 3.1415927F / 180.0F) * 0.1F); - } else { - this.motX = this.motZ = 0.0D; - } - - this.height = 0.1F; - this.a(StatisticList.v, 1); - } - - protected String aT() { - return "game.player.hurt"; - } - - protected String aU() { - return "game.player.die"; - } - - public void b(Entity entity, int i) { - this.addScore(i); - // CraftBukkit - Get our scores instead - Collection<ScoreboardScore> collection = this.world.getServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.e, this.getName(), new java.util.ArrayList<ScoreboardScore>()); - - if (entity instanceof EntityHuman) { - this.a(StatisticList.y, 1); - // CraftBukkit - Get our scores instead - this.world.getServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.d, this.getName(), collection); - } else { - this.a(StatisticList.w, 1); - } - - Iterator iterator = collection.iterator(); - - while (iterator.hasNext()) { - ScoreboardScore scoreboardscore = (ScoreboardScore) iterator.next(); // CraftBukkit - Use our scores instead - - scoreboardscore.incrementScore(); - } - } - - public EntityItem a(boolean flag) { - // Called only when dropped by Q or CTRL-Q - return this.a(this.inventory.splitStack(this.inventory.itemInHandIndex, flag && this.inventory.getItemInHand() != null ? this.inventory.getItemInHand().count : 1), false, true); - } - - public EntityItem drop(ItemStack itemstack, boolean flag) { - return this.a(itemstack, false, false); - } - - public EntityItem a(ItemStack itemstack, boolean flag, boolean flag1) { - if (itemstack == null) { - return null; - } else if (itemstack.count == 0) { - return null; - } else { - EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY - 0.30000001192092896D + (double) this.getHeadHeight(), this.locZ, itemstack); - - entityitem.pickupDelay = 40; - if (flag1) { - entityitem.b(this.getName()); - } - - float f = 0.1F; - float f1; - - if (flag) { - f1 = this.random.nextFloat() * 0.5F; - float f2 = this.random.nextFloat() * 3.1415927F * 2.0F; - - entityitem.motX = (double) (-MathHelper.sin(f2) * f1); - entityitem.motZ = (double) (MathHelper.cos(f2) * f1); - entityitem.motY = 0.20000000298023224D; - } else { - f = 0.3F; - entityitem.motX = (double) (-MathHelper.sin(this.yaw / 180.0F * 3.1415927F) * MathHelper.cos(this.pitch / 180.0F * 3.1415927F) * f); - entityitem.motZ = (double) (MathHelper.cos(this.yaw / 180.0F * 3.1415927F) * MathHelper.cos(this.pitch / 180.0F * 3.1415927F) * f); - entityitem.motY = (double) (-MathHelper.sin(this.pitch / 180.0F * 3.1415927F) * f + 0.1F); - f = 0.02F; - f1 = this.random.nextFloat() * 3.1415927F * 2.0F; - f *= this.random.nextFloat(); - entityitem.motX += Math.cos((double) f1) * (double) f; - entityitem.motY += (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F); - entityitem.motZ += Math.sin((double) f1) * (double) f; - } - - // CraftBukkit start - fire PlayerDropItemEvent - Player player = (Player) this.getBukkitEntity(); - CraftItem drop = new CraftItem(this.world.getServer(), entityitem); - - PlayerDropItemEvent event = new PlayerDropItemEvent(player, drop); - this.world.getServer().getPluginManager().callEvent(event); - - if (event.isCancelled()) { - org.bukkit.inventory.ItemStack cur = player.getInventory().getItemInHand(); - if (flag1 && (cur == null || cur.getAmount() == 0)) { - // The complete stack was dropped - player.getInventory().setItemInHand(drop.getItemStack()); - } else if (flag1 && cur.isSimilar(drop.getItemStack()) && drop.getItemStack().getAmount() == 1) { - // Only one item is dropped - cur.setAmount(cur.getAmount() + 1); - player.getInventory().setItemInHand(cur); - } else { - // Fallback - player.getInventory().addItem(drop.getItemStack()); - } - return null; - } - // CraftBukkit end - - this.a(entityitem); - this.a(StatisticList.s, 1); - return entityitem; - } - } - - protected void a(EntityItem entityitem) { - this.world.addEntity(entityitem); - } - - public float a(Block block, boolean flag) { - float f = this.inventory.a(block); - - if (f > 1.0F) { - int i = EnchantmentManager.getDigSpeedEnchantmentLevel(this); - ItemStack itemstack = this.inventory.getItemInHand(); - - if (i > 0 && itemstack != null) { - float f1 = (float) (i * i + 1); - - if (!itemstack.b(block) && f <= 1.0F) { - f += f1 * 0.08F; - } else { - f += f1; - } - } - } - - if (this.hasEffect(MobEffectList.FASTER_DIG)) { - f *= 1.0F + (float) (this.getEffect(MobEffectList.FASTER_DIG).getAmplifier() + 1) * 0.2F; - } - - if (this.hasEffect(MobEffectList.SLOWER_DIG)) { - f *= 1.0F - (float) (this.getEffect(MobEffectList.SLOWER_DIG).getAmplifier() + 1) * 0.2F; - } - - if (this.a(Material.WATER) && !EnchantmentManager.hasWaterWorkerEnchantment(this)) { - f /= 5.0F; - } - - if (!this.onGround) { - f /= 5.0F; - } - - return f; - } - - public boolean a(Block block) { - return this.inventory.b(block); - } - - public void a(NBTTagCompound nbttagcompound) { - super.a(nbttagcompound); - this.uniqueID = a(this.i); - NBTTagList nbttaglist = nbttagcompound.getList("Inventory", 10); - - this.inventory.b(nbttaglist); - this.inventory.itemInHandIndex = nbttagcompound.getInt("SelectedItemSlot"); - 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"); - this.setScore(nbttagcompound.getInt("Score")); - if (this.sleeping) { - this.bB = new ChunkCoordinates(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ)); - this.a(true, true, false); - } - - // CraftBukkit start - this.spawnWorld = nbttagcompound.getString("SpawnWorld"); - if ("".equals(spawnWorld)) { - this.spawnWorld = this.world.getServer().getWorlds().get(0).getName(); - } - // CraftBukkit end - - if (nbttagcompound.hasKeyOfType("SpawnX", 99) && nbttagcompound.hasKeyOfType("SpawnY", 99) && nbttagcompound.hasKeyOfType("SpawnZ", 99)) { - this.c = new ChunkCoordinates(nbttagcompound.getInt("SpawnX"), nbttagcompound.getInt("SpawnY"), nbttagcompound.getInt("SpawnZ")); - this.d = nbttagcompound.getBoolean("SpawnForced"); - } - - this.foodData.a(nbttagcompound); - this.abilities.b(nbttagcompound); - if (nbttagcompound.hasKeyOfType("EnderItems", 9)) { - NBTTagList nbttaglist1 = nbttagcompound.getList("EnderItems", 10); - - this.enderChest.a(nbttaglist1); - } - } - - public void b(NBTTagCompound nbttagcompound) { - super.b(nbttagcompound); - nbttagcompound.set("Inventory", this.inventory.a(new NBTTagList())); - nbttagcompound.setInt("SelectedItemSlot", this.inventory.itemInHandIndex); - nbttagcompound.setBoolean("Sleeping", this.sleeping); - nbttagcompound.setShort("SleepTimer", (short) this.sleepTicks); - nbttagcompound.setFloat("XpP", this.exp); - nbttagcompound.setInt("XpLevel", this.expLevel); - nbttagcompound.setInt("XpTotal", this.expTotal); - nbttagcompound.setInt("Score", this.getScore()); - if (this.c != null) { - 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 - } - - this.foodData.b(nbttagcompound); - this.abilities.a(nbttagcompound); - nbttagcompound.set("EnderItems", this.enderChest.h()); - } - - public void openContainer(IInventory iinventory) {} - - public void openHopper(TileEntityHopper tileentityhopper) {} - - public void openMinecartHopper(EntityMinecartHopper entityminecarthopper) {} - - public void openHorseInventory(EntityHorse entityhorse, IInventory iinventory) {} - - public void startEnchanting(int i, int j, int k, String s) {} - - public void openAnvil(int i, int j, int k) {} - - public void startCrafting(int i, int j, int k) {} - - public float getHeadHeight() { - return 0.12F; - } - - protected void e_() { - this.height = 1.62F; - } - - public boolean damageEntity(DamageSource damagesource, float f) { - if (this.isInvulnerable()) { - return false; - } else if (this.abilities.isInvulnerable && !damagesource.ignoresInvulnerability()) { - return false; - } else { - this.aU = 0; - if (this.getHealth() <= 0.0F) { - return false; - } else { - if (this.isSleeping() && !this.world.isStatic) { - this.a(true, true, false); - } - - if (damagesource.r()) { - if (this.world.difficulty == EnumDifficulty.PEACEFUL) { - return false; // CraftBukkit - f = 0.0f -> return false - } - - if (this.world.difficulty == EnumDifficulty.EASY) { - f = f / 2.0F + 1.0F; - } - - if (this.world.difficulty == EnumDifficulty.HARD) { - f = f * 3.0F / 2.0F; - } - } - - if (false && f == 0.0F) { // CraftBukkit - Don't filter out 0 damage - return false; - } else { - Entity entity = damagesource.getEntity(); - - if (entity instanceof EntityArrow && ((EntityArrow) entity).shooter != null) { - entity = ((EntityArrow) entity).shooter; - } - - this.a(StatisticList.u, Math.round(f * 10.0F)); - return super.damageEntity(damagesource, f); - } - } - } - } - - public boolean a(EntityHuman entityhuman) { - // CraftBukkit start - Change to check OTHER player's scoreboard team according to API - // To summarize this method's logic, it's "Can parameter hurt this" - org.bukkit.scoreboard.Team team; - if (entityhuman instanceof EntityPlayer) { - EntityPlayer thatPlayer = (EntityPlayer) entityhuman; - team = thatPlayer.getBukkitEntity().getScoreboard().getPlayerTeam(thatPlayer.getBukkitEntity()); - if (team == null || team.allowFriendlyFire()) { - return true; - } - } else { - // This should never be called, but is implemented anyway - org.bukkit.OfflinePlayer thisPlayer = entityhuman.world.getServer().getOfflinePlayer(entityhuman.getName()); - team = entityhuman.world.getServer().getScoreboardManager().getMainScoreboard().getPlayerTeam(thisPlayer); - if (team == null || team.allowFriendlyFire()) { - return true; - } - } - - if (this instanceof EntityPlayer) { - return !team.hasPlayer(((EntityPlayer) this).getBukkitEntity()); - } - return !team.hasPlayer(this.world.getServer().getOfflinePlayer(this.getName())); - // CraftBukkit end - } - - protected void damageArmor(float f) { - this.inventory.a(f); - } - - public int aV() { - return this.inventory.l(); - } - - public float bE() { - 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; - } - } - - return (float) i / (float) this.inventory.armor.length; - } - - // CraftBukkit start - protected boolean d(DamageSource damagesource, float f) { // void -> boolean - if (true) { - return super.d(damagesource, f); - } - // CraftBukkit end - if (!this.isInvulnerable()) { - if (!damagesource.ignoresArmor() && this.isBlocking() && f > 0.0F) { - f = (1.0F + f) * 0.5F; - } - - f = this.applyArmorModifier(damagesource, f); - f = this.applyMagicModifier(damagesource, f); - float f1 = f; - - f = Math.max(f - this.getAbsorptionHearts(), 0.0F); - this.setAbsorptionHearts(this.getAbsorptionHearts() - (f1 - f)); - if (f != 0.0F) { - this.applyExhaustion(damagesource.getExhaustionCost()); - float f2 = this.getHealth(); - - this.setHealth(this.getHealth() - f); - this.aW().a(damagesource, f2, f); - } - } - return false; // CraftBukkit - } - - public void openFurnace(TileEntityFurnace tileentityfurnace) {} - - public void openDispenser(TileEntityDispenser tileentitydispenser) {} - - public void a(TileEntity tileentity) {} - - public void a(CommandBlockListenerAbstract commandblocklistenerabstract) {} - - public void openBrewingStand(TileEntityBrewingStand tileentitybrewingstand) {} - - public void openBeacon(TileEntityBeacon tileentitybeacon) {} - - public void openTrade(IMerchant imerchant, String s) {} - - public void b(ItemStack itemstack) {} - - public boolean q(Entity entity) { - ItemStack itemstack = this.bF(); - ItemStack itemstack1 = itemstack != null ? itemstack.cloneItemStack() : null; - - if (!entity.c(this)) { - if (itemstack != null && entity instanceof EntityLiving) { - if (this.abilities.canInstantlyBuild) { - itemstack = itemstack1; - } - - if (itemstack.a(this, (EntityLiving) entity)) { - // CraftBukkit - bypass infinite items; <= 0 -> == 0 - if (itemstack.count == 0 && !this.abilities.canInstantlyBuild) { - this.bG(); - } - - return true; - } - } - - return false; - } else { - if (itemstack != null && itemstack == this.bF()) { - if (itemstack.count <= 0 && !this.abilities.canInstantlyBuild) { - this.bG(); - } else if (itemstack.count < itemstack1.count && this.abilities.canInstantlyBuild) { - itemstack.count = itemstack1.count; - } - } - - return true; - } - } - - public ItemStack bF() { - return this.inventory.getItemInHand(); - } - - public void bG() { - this.inventory.setItem(this.inventory.itemInHandIndex, (ItemStack) null); - } - - public double ad() { - return (double) (this.height - 0.5F); - } - - public void attack(Entity entity) { - if (entity.av()) { - if (!entity.j(this)) { - float f = (float) this.getAttributeInstance(GenericAttributes.e).getValue(); - int i = 0; - float f1 = 0.0F; - - if (entity instanceof EntityLiving) { - f1 = EnchantmentManager.a((EntityLiving) this, (EntityLiving) entity); - i += EnchantmentManager.getKnockbackEnchantmentLevel(this, (EntityLiving) entity); - } - - if (this.isSprinting()) { - ++i; - } - - if (f > 0.0F || f1 > 0.0F) { - boolean flag = this.fallDistance > 0.0F && !this.onGround && !this.h_() && !this.M() && !this.hasEffect(MobEffectList.BLINDNESS) && this.vehicle == null && entity instanceof EntityLiving; - - if (flag && f > 0.0F) { - f *= 1.5F; - } - - f += f1; - boolean flag1 = false; - int j = EnchantmentManager.getFireAspectEnchantmentLevel(this); - - if (entity instanceof EntityLiving && j > 0 && !entity.isBurning()) { - // CraftBukkit start - Call a combust event when somebody hits with a fire enchanted item - EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), 1); - org.bukkit.Bukkit.getPluginManager().callEvent(combustEvent); - - if (!combustEvent.isCancelled()) { - flag1 = true; - entity.setOnFire(combustEvent.getDuration()); - } - // CraftBukkit end - } - - boolean flag2 = entity.damageEntity(DamageSource.playerAttack(this), f); - - if (flag2) { - if (i > 0) { - entity.g((double) (-MathHelper.sin(this.yaw * 3.1415927F / 180.0F) * (float) i * 0.5F), 0.1D, (double) (MathHelper.cos(this.yaw * 3.1415927F / 180.0F) * (float) i * 0.5F)); - this.motX *= 0.6D; - this.motZ *= 0.6D; - this.setSprinting(false); - } - - if (flag) { - this.b(entity); - } - - if (f1 > 0.0F) { - this.c(entity); - } - - if (f >= 18.0F) { - this.a((Statistic) AchievementList.F); - } - - this.l(entity); - if (entity instanceof EntityLiving) { - EnchantmentManager.a((EntityLiving) entity, (Entity) this); - } - - EnchantmentManager.b(this, entity); - ItemStack itemstack = this.bF(); - Object object = entity; - - if (entity instanceof EntityComplexPart) { - IComplex icomplex = ((EntityComplexPart) entity).owner; - - if (icomplex != null && icomplex instanceof EntityLiving) { - object = (EntityLiving) icomplex; - } - } - - if (itemstack != null && object instanceof EntityLiving) { - itemstack.a((EntityLiving) object, this); - // CraftBukkit - bypass infinite items; <= 0 -> == 0 - if (itemstack.count == 0) { - this.bG(); - } - } - - if (entity instanceof EntityLiving) { - this.a(StatisticList.t, Math.round(f * 10.0F)); - if (j > 0) { - // CraftBukkit start - Call a combust event when somebody hits with a fire enchanted item - EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), j * 4); - org.bukkit.Bukkit.getPluginManager().callEvent(combustEvent); - - if (!combustEvent.isCancelled()) { - entity.setOnFire(combustEvent.getDuration()); - } - // CraftBukkit end - } - } - - this.applyExhaustion(0.3F); - } else if (flag1) { - entity.extinguish(); - } - } - } - } - } - - public void b(Entity entity) {} - - public void c(Entity entity) {} - - public void die() { - super.die(); - this.defaultContainer.b(this); - if (this.activeContainer != null) { - this.activeContainer.b(this); - } - } - - public boolean inBlock() { - return !this.sleeping && super.inBlock(); - } - - public GameProfile getProfile() { - return this.i; - } - - public EnumBedResult a(int i, int j, int k) { - if (!this.world.isStatic) { - if (this.isSleeping() || !this.isAlive()) { - return EnumBedResult.OTHER_PROBLEM; - } - - if (!this.world.worldProvider.d()) { - return EnumBedResult.NOT_POSSIBLE_HERE; - } - - if (this.world.w()) { - return EnumBedResult.NOT_POSSIBLE_NOW; - } - - if (Math.abs(this.locX - (double) i) > 3.0D || Math.abs(this.locY - (double) j) > 2.0D || Math.abs(this.locZ - (double) k) > 3.0D) { - return EnumBedResult.TOO_FAR_AWAY; - } - - double d0 = 8.0D; - double d1 = 5.0D; - List list = this.world.a(EntityMonster.class, AxisAlignedBB.a((double) i - d0, (double) j - d1, (double) k - d0, (double) i + d0, (double) j + d1, (double) k + d0)); - - if (!list.isEmpty()) { - return EnumBedResult.NOT_SAFE; - } - } - - if (this.am()) { - this.mount((Entity) null); - } - - // CraftBukkit start - fire PlayerBedEnterEvent - if (this.getBukkitEntity() instanceof Player) { - Player player = (Player) this.getBukkitEntity(); - org.bukkit.block.Block bed = this.world.getWorld().getBlockAt(i, j, k); - - PlayerBedEnterEvent event = new PlayerBedEnterEvent(player, bed); - this.world.getServer().getPluginManager().callEvent(event); - - if (event.isCancelled()) { - return EnumBedResult.OTHER_PROBLEM; - } - } - // CraftBukkit end - - this.a(0.2F, 0.2F); - this.height = 0.2F; - if (this.world.isLoaded(i, j, k)) { - int l = this.world.getData(i, j, k); - int i1 = BlockBed.l(l); - float f = 0.5F; - float f1 = 0.5F; - - switch (i1) { - case 0: - f1 = 0.9F; - break; - - case 1: - f = 0.1F; - break; - - case 2: - f1 = 0.1F; - break; - - case 3: - f = 0.9F; - } - - this.w(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)); - } - - this.sleeping = true; - this.sleepTicks = 0; - this.bB = new ChunkCoordinates(i, j, k); - this.motX = this.motZ = this.motY = 0.0D; - if (!this.world.isStatic) { - this.world.everyoneSleeping(); - } - - return EnumBedResult.OK; - } - - private void w(int i) { - this.bC = 0.0F; - this.bD = 0.0F; - switch (i) { - case 0: - this.bD = -1.8F; - break; - - case 1: - this.bC = 1.8F; - break; - - case 2: - this.bD = 1.8F; - break; - - case 3: - this.bC = -1.8F; - } - } - - public void a(boolean flag, boolean flag1, boolean flag2) { - this.a(0.6F, 1.8F); - this.e_(); - ChunkCoordinates chunkcoordinates = this.bB; - ChunkCoordinates chunkcoordinates1 = this.bB; - - if (chunkcoordinates != null && this.world.getType(chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z) == Blocks.BED) { - BlockBed.a(this.world, chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z, false); - chunkcoordinates1 = BlockBed.a(this.world, chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z, 0); - if (chunkcoordinates1 == null) { - chunkcoordinates1 = new ChunkCoordinates(chunkcoordinates.x, chunkcoordinates.y + 1, chunkcoordinates.z); - } - - this.setPosition((double) ((float) chunkcoordinates1.x + 0.5F), (double) ((float) chunkcoordinates1.y + this.height + 0.1F), (double) ((float) chunkcoordinates1.z + 0.5F)); - } - - this.sleeping = false; - if (!this.world.isStatic && flag1) { - this.world.everyoneSleeping(); - } - - // CraftBukkit start - fire PlayerBedLeaveEvent - if (this.getBukkitEntity() instanceof Player) { - Player player = (Player) this.getBukkitEntity(); - - org.bukkit.block.Block bed; - if (chunkcoordinates != null) { - bed = this.world.getWorld().getBlockAt(chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z); - } else { - bed = this.world.getWorld().getBlockAt(player.getLocation()); - } - - PlayerBedLeaveEvent event = new PlayerBedLeaveEvent(player, bed); - this.world.getServer().getPluginManager().callEvent(event); - } - // CraftBukkit end - - if (flag) { - this.sleepTicks = 0; - } else { - this.sleepTicks = 100; - } - - if (flag2) { - this.setRespawnPosition(this.bB, false); - } - } - - private boolean j() { - return this.world.getType(this.bB.x, this.bB.y, this.bB.z) == Blocks.BED; - } - - public static ChunkCoordinates getBed(World world, ChunkCoordinates chunkcoordinates, boolean flag) { - IChunkProvider ichunkprovider = world.L(); - - 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.getType(chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z) == Blocks.BED) { - ChunkCoordinates chunkcoordinates1 = BlockBed.a(world, chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z, 0); - - return chunkcoordinates1; - } else { - Material material = world.getType(chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z).getMaterial(); - Material material1 = world.getType(chunkcoordinates.x, chunkcoordinates.y + 1, chunkcoordinates.z).getMaterial(); - boolean flag1 = !material.isBuildable() && !material.isLiquid(); - boolean flag2 = !material1.isBuildable() && !material1.isLiquid(); - - return flag && flag1 && flag2 ? chunkcoordinates : null; - } - } - - public boolean isSleeping() { - return this.sleeping; - } - - public boolean isDeeplySleeping() { - return this.sleeping && this.sleepTicks >= 100; - } - - 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(IChatBaseComponent ichatbasecomponent) {} - - public ChunkCoordinates getBed() { - return this.c; - } - - public boolean isRespawnForced() { - return this.d; - } - - public void setRespawnPosition(ChunkCoordinates chunkcoordinates, boolean flag) { - if (chunkcoordinates != null) { - this.c = new ChunkCoordinates(chunkcoordinates); - this.d = flag; - this.spawnWorld = this.world.worldData.getName(); // CraftBukkit - } else { - this.c = null; - this.d = false; - this.spawnWorld = ""; // CraftBukkit - } - } - - public void a(Statistic statistic) { - this.a(statistic, 1); - } - - public void a(Statistic statistic, int i) {} - - public void bj() { - super.bj(); - this.a(StatisticList.r, 1); - if (this.isSprinting()) { - this.applyExhaustion(0.8F); - } else { - this.applyExhaustion(0.2F); - } - } - - public void e(float f, float f1) { - double d0 = this.locX; - double d1 = this.locY; - double d2 = this.locZ; - - if (this.abilities.isFlying && this.vehicle == null) { - double d3 = this.motY; - float f2 = this.aQ; - - this.aQ = this.abilities.a(); - super.e(f, f1); - this.motY = d3 * 0.6D; - this.aQ = f2; - } else { - super.e(f, f1); - } - - this.checkMovement(this.locX - d0, this.locY - d1, this.locZ - d2); - } - - public float bl() { - return (float) this.getAttributeInstance(GenericAttributes.d).getValue(); - } - - public void checkMovement(double d0, double d1, double d2) { - if (this.vehicle == null) { - int i; - - if (this.a(Material.WATER)) { - i = Math.round(MathHelper.sqrt(d0 * d0 + d1 * d1 + d2 * d2) * 100.0F); - if (i > 0) { - this.a(StatisticList.m, i); - this.applyExhaustion(0.015F * (float) i * 0.01F); - } - } else if (this.M()) { - i = Math.round(MathHelper.sqrt(d0 * d0 + d2 * d2) * 100.0F); - if (i > 0) { - this.a(StatisticList.i, i); - this.applyExhaustion(0.015F * (float) i * 0.01F); - } - } else if (this.h_()) { - if (d1 > 0.0D) { - this.a(StatisticList.k, (int) Math.round(d1 * 100.0D)); - } - } else if (this.onGround) { - i = Math.round(MathHelper.sqrt(d0 * d0 + d2 * d2) * 100.0F); - if (i > 0) { - this.a(StatisticList.h, i); - if (this.isSprinting()) { - this.applyExhaustion(0.099999994F * (float) i * 0.01F); - } else { - this.applyExhaustion(0.01F * (float) i * 0.01F); - } - } - } else { - i = Math.round(MathHelper.sqrt(d0 * d0 + d2 * d2) * 100.0F); - if (i > 25) { - this.a(StatisticList.l, i); - } - } - } - } - - private void l(double d0, double d1, double d2) { - if (this.vehicle != null) { - int i = Math.round(MathHelper.sqrt(d0 * d0 + d1 * d1 + d2 * d2) * 100.0F); - - if (i > 0) { - if (this.vehicle instanceof EntityMinecartAbstract) { - this.a(StatisticList.n, i); - 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) { - this.a(StatisticList.o, i); - } else if (this.vehicle instanceof EntityPig) { - this.a(StatisticList.p, i); - } else if (this.vehicle instanceof EntityHorse) { - this.a(StatisticList.q, i); - } - } - } - } - - protected void b(float f) { - if (!this.abilities.canFly) { - if (f >= 2.0F) { - this.a(StatisticList.j, (int) Math.round((double) f * 100.0D)); - } - - super.b(f); - } - } - - protected String o(int i) { - return i > 4 ? "game.player.hurt.fall.big" : "game.player.hurt.fall.small"; - } - - public void a(EntityLiving entityliving) { - if (entityliving instanceof IMonster) { - this.a((Statistic) AchievementList.s); - } - - int i = EntityTypes.a(entityliving); - MonsterEggInfo monsteregginfo = (MonsterEggInfo) EntityTypes.eggInfo.get(Integer.valueOf(i)); - - if (monsteregginfo != null) { - this.a(monsteregginfo.killEntityStatistic, 1); - } - } - - public void as() { - if (!this.abilities.isFlying) { - super.as(); - } - } - - public ItemStack r(int i) { - return this.inventory.d(i); - } - - public void giveExp(int i) { - this.addScore(i); - int j = Integer.MAX_VALUE - this.expTotal; - - if (i > j) { - i = j; - } - - this.exp += (float) i / (float) this.getExpToLevel(); - - for (this.expTotal += i; this.exp >= 1.0F; this.exp /= (float) this.getExpToLevel()) { - this.exp = (this.exp - 1.0F) * (float) this.getExpToLevel(); - this.levelDown(1); - } - } - - public void levelDown(int i) { - this.expLevel += i; - if (this.expLevel < 0) { - this.expLevel = 0; - this.exp = 0.0F; - this.expTotal = 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); - } - - public void applyExhaustion(float f) { - if (!this.abilities.isInvulnerable) { - if (!this.world.isStatic) { - this.foodData.a(f); - } - } - } - - public FoodMetaData getFoodData() { - return this.foodData; - } - - public boolean g(boolean flag) { - return (flag || this.foodData.c()) && !this.abilities.isInvulnerable; - } - - public boolean bR() { - return this.getHealth() > 0.0F && this.getHealth() < this.getMaxHealth(); - } - - public void a(ItemStack itemstack, int i) { - if (itemstack != this.f) { - this.f = itemstack; - this.g = i; - if (!this.world.isStatic) { - this.e(true); - } - } - } - - public boolean d(int i, int j, int k) { - if (this.abilities.mayBuild) { - return true; - } else { - Block block = this.world.getType(i, j, k); - - if (block.getMaterial() != Material.AIR) { - if (block.getMaterial().q()) { - return true; - } - - if (this.bF() != null) { - ItemStack itemstack = this.bF(); - - if (itemstack.b(block) || itemstack.a(block) > 1.0F) { - return true; - } - } - } - - return false; - } - } - - public boolean a(int i, int j, int k, int l, ItemStack itemstack) { - return this.abilities.mayBuild ? true : (itemstack != null ? itemstack.z() : false); - } - - protected int getExpValue(EntityHuman entityhuman) { - if (this.world.getGameRules().getBoolean("keepInventory")) { - return 0; - } else { - int i = this.expLevel * 7; - - return i > 100 ? 100 : i; - } - } - - protected boolean alwaysGivesExp() { - return true; - } - - public void copyTo(EntityHuman entityhuman, boolean flag) { - if (flag) { - this.inventory.b(entityhuman.inventory); - this.setHealth(entityhuman.getHealth()); - this.foodData = entityhuman.foodData; - this.expLevel = entityhuman.expLevel; - this.expTotal = entityhuman.expTotal; - this.exp = entityhuman.exp; - this.setScore(entityhuman.getScore()); - 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.setScore(entityhuman.getScore()); - } - - this.enderChest = entityhuman.enderChest; - } - - protected boolean g_() { - return !this.abilities.isFlying; - } - - public void updateAbilities() {} - - public void a(EnumGamemode enumgamemode) {} - - public String getName() { - return this.i.getName(); - } - - public World getWorld() { - return this.world; - } - - public InventoryEnderChest getEnderChest() { - return this.enderChest; - } - - public ItemStack getEquipment(int i) { - return i == 0 ? this.inventory.getItemInHand() : this.inventory.armor[i - 1]; - } - - public ItemStack be() { - return this.inventory.getItemInHand(); - } - - public void setEquipment(int i, ItemStack itemstack) { - this.inventory.armor[i] = itemstack; - } - - public ItemStack[] getEquipment() { - return this.inventory.armor; - } - - public boolean aC() { - return !this.abilities.isFlying; - } - - public Scoreboard getScoreboard() { - return this.world.getScoreboard(); - } - - public ScoreboardTeamBase getScoreboardTeam() { - return this.getScoreboard().getPlayerTeam(this.getName()); - } - - public IChatBaseComponent getScoreboardDisplayName() { - // CraftBukkit - todo: fun - ChatComponentText chatcomponenttext = new ChatComponentText(ScoreboardTeam.getPlayerDisplayName(this.getScoreboardTeam(), this.getName())); - - chatcomponenttext.getChatModifier().setChatClickable(new ChatClickable(EnumClickAction.SUGGEST_COMMAND, "/msg " + this.getName() + " ")); - return chatcomponenttext; - } - - public void setAbsorptionHearts(float f) { - if (f < 0.0F) { - f = 0.0F; - } - - this.getDataWatcher().watch(17, Float.valueOf(f)); - } - - public float getAbsorptionHearts() { - return this.getDataWatcher().getFloat(17); - } - - public static UUID a(GameProfile gameprofile) { - UUID uuid = gameprofile.getId(); - - if (uuid == null) { - uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + gameprofile.getName()).getBytes(Charsets.UTF_8)); - } - - return uuid; - } -} diff --git a/src/main/java/net/minecraft/server/EntityInsentient.java b/src/main/java/net/minecraft/server/EntityInsentient.java deleted file mode 100644 index a812656f..00000000 --- a/src/main/java/net/minecraft/server/EntityInsentient.java +++ /dev/null @@ -1,892 +0,0 @@ -package net.minecraft.server; - -import java.util.Iterator; -import java.util.List; -import java.util.UUID; - -// CraftBukkit start -import org.bukkit.craftbukkit.event.CraftEventFactory; -import org.bukkit.event.entity.EntityUnleashEvent; -import org.bukkit.event.entity.EntityUnleashEvent.UnleashReason; -// CraftBukkit end - -public abstract class EntityInsentient extends EntityLiving { - - public int a_; - protected int b; - private ControllerLook lookController; - private ControllerMove moveController; - private ControllerJump bm; - private EntityAIBodyControl bn; - private Navigation navigation; - protected final PathfinderGoalSelector goalSelector; - protected final PathfinderGoalSelector targetSelector; - private EntityLiving goalTarget; - private EntitySenses bq; - private ItemStack[] equipment = new ItemStack[5]; - public float[] dropChances = new float[5]; // CraftBukkit - protected -> public - public boolean canPickUpLoot; // CraftBukkit - private -> public - public boolean persistent = !isTypeNotPersistent(); // CraftBukkit - private -> public - protected float f; - private Entity bu; - protected int g; - private boolean bv; - private Entity bw; - private NBTTagCompound bx; - - public EntityInsentient(World world) { - super(world); - this.goalSelector = new PathfinderGoalSelector(world != null && world.methodProfiler != null ? world.methodProfiler : null); - this.targetSelector = new PathfinderGoalSelector(world != null && world.methodProfiler != null ? world.methodProfiler : null); - this.lookController = new ControllerLook(this); - this.moveController = new ControllerMove(this); - this.bm = new ControllerJump(this); - this.bn = new EntityAIBodyControl(this); - this.navigation = new Navigation(this, world); - this.bq = new EntitySenses(this); - - for (int i = 0; i < this.dropChances.length; ++i) { - this.dropChances[i] = 0.085F; - } - } - - protected void aD() { - super.aD(); - this.getAttributeMap().b(GenericAttributes.b).setValue(16.0D); - } - - public ControllerLook getControllerLook() { - return this.lookController; - } - - public ControllerMove getControllerMove() { - return this.moveController; - } - - public ControllerJump getControllerJump() { - return this.bm; - } - - public Navigation getNavigation() { - return this.navigation; - } - - public EntitySenses getEntitySenses() { - return this.bq; - } - - public EntityLiving getGoalTarget() { - return this.goalTarget; - } - - public void setGoalTarget(EntityLiving entityliving) { - this.goalTarget = entityliving; - } - - public boolean a(Class oclass) { - return EntityCreeper.class != oclass && EntityGhast.class != oclass; - } - - public void p() {} - - protected void c() { - super.c(); - this.datawatcher.a(11, Byte.valueOf((byte) 0)); - this.datawatcher.a(10, ""); - } - - public int q() { - return 80; - } - - public void r() { - String s = this.t(); - - if (s != null) { - this.makeSound(s, this.bf(), this.bg()); - } - } - - public void C() { - super.C(); - this.world.methodProfiler.a("mobBaseTick"); - if (this.isAlive() && this.random.nextInt(1000) < this.a_++) { - this.a_ = -this.q(); - this.r(); - } - - this.world.methodProfiler.b(); - } - - protected int getExpValue(EntityHuman entityhuman) { - if (this.b > 0) { - int i = this.b; - ItemStack[] aitemstack = this.getEquipment(); - - for (int j = 0; j < aitemstack.length; ++j) { - if (aitemstack[j] != null && this.dropChances[j] <= 1.0F) { - i += 1 + this.random.nextInt(3); - } - } - - return i; - } else { - return this.b; - } - } - - public void s() { - 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.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 h() { - super.h(); - if (!this.world.isStatic) { - this.bL(); - } - } - - protected float f(float f, float f1) { - if (this.bk()) { - this.bn.a(); - return f1; - } else { - return super.f(f, f1); - } - } - - protected String t() { - return null; - } - - protected Item getLoot() { - return Item.getById(0); - } - - protected void dropDeathLoot(boolean flag, int i) { - Item item = this.getLoot(); - - if (item != null) { - int j = this.random.nextInt(3); - - if (i > 0) { - j += this.random.nextInt(i + 1); - } - - for (int k = 0; k < j; ++k) { - this.a(item, 1); - } - } - } - - public void b(NBTTagCompound nbttagcompound) { - super.b(nbttagcompound); - nbttagcompound.setBoolean("CanPickUpLoot", this.bJ()); - nbttagcompound.setBoolean("PersistenceRequired", this.persistent); - NBTTagList nbttaglist = new NBTTagList(); - - NBTTagCompound nbttagcompound1; - - for (int i = 0; i < this.equipment.length; ++i) { - nbttagcompound1 = new NBTTagCompound(); - if (this.equipment[i] != null) { - this.equipment[i].save(nbttagcompound1); - } - - nbttaglist.add(nbttagcompound1); - } - - nbttagcompound.set("Equipment", nbttaglist); - NBTTagList nbttaglist1 = new NBTTagList(); - - for (int j = 0; j < this.dropChances.length; ++j) { - nbttaglist1.add(new NBTTagFloat(this.dropChances[j])); - } - - nbttagcompound.set("DropChances", nbttaglist1); - nbttagcompound.setString("CustomName", this.getCustomName()); - nbttagcompound.setBoolean("CustomNameVisible", this.getCustomNameVisible()); - nbttagcompound.setBoolean("Leashed", this.bv); - if (this.bw != null) { - nbttagcompound1 = new NBTTagCompound(); - if (this.bw instanceof EntityLiving) { - nbttagcompound1.setLong("UUIDMost", this.bw.getUniqueID().getMostSignificantBits()); - nbttagcompound1.setLong("UUIDLeast", this.bw.getUniqueID().getLeastSignificantBits()); - } else if (this.bw instanceof EntityHanging) { - EntityHanging entityhanging = (EntityHanging) this.bw; - - nbttagcompound1.setInt("X", entityhanging.x); - nbttagcompound1.setInt("Y", entityhanging.y); - nbttagcompound1.setInt("Z", entityhanging.z); - } - - nbttagcompound.set("Leash", nbttagcompound1); - } - } - - public void a(NBTTagCompound nbttagcompound) { - super.a(nbttagcompound); - - // CraftBukkit start - If looting or persistence is false only use it if it was set after we started using it - boolean data = nbttagcompound.getBoolean("CanPickUpLoot"); - if (isLevelAtLeast(nbttagcompound, 1) || data) { - this.canPickUpLoot = data; - } - - data = nbttagcompound.getBoolean("PersistenceRequired"); - if (isLevelAtLeast(nbttagcompound, 1) || data) { - this.persistent = data; - } - // CraftBukkit end - - if (nbttagcompound.hasKeyOfType("CustomName", 8) && nbttagcompound.getString("CustomName").length() > 0) { - this.setCustomName(nbttagcompound.getString("CustomName")); - } - - this.setCustomNameVisible(nbttagcompound.getBoolean("CustomNameVisible")); - NBTTagList nbttaglist; - int i; - - if (nbttagcompound.hasKeyOfType("Equipment", 9)) { - nbttaglist = nbttagcompound.getList("Equipment", 10); - - for (i = 0; i < this.equipment.length; ++i) { - this.equipment[i] = ItemStack.createStack(nbttaglist.get(i)); - } - } - - if (nbttagcompound.hasKeyOfType("DropChances", 9)) { - nbttaglist = nbttagcompound.getList("DropChances", 5); - - for (i = 0; i < nbttaglist.size(); ++i) { - this.dropChances[i] = nbttaglist.e(i); - } - } - - this.bv = nbttagcompound.getBoolean("Leashed"); - if (this.bv && nbttagcompound.hasKeyOfType("Leash", 10)) { - this.bx = nbttagcompound.getCompound("Leash"); - } - } - - public void n(float f) { - this.be = f; - } - - public void i(float f) { - super.i(f); - this.n(f); - } - - public void e() { - super.e(); - this.world.methodProfiler.a("looting"); - if (!this.world.isStatic && this.bJ() && !this.aT && this.world.getGameRules().getBoolean("mobGriefing")) { - List list = this.world.a(EntityItem.class, this.boundingBox.grow(1.0D, 0.0D, 1.0D)); - Iterator iterator = list.iterator(); - - while (iterator.hasNext()) { - EntityItem entityitem = (EntityItem) iterator.next(); - - if (!entityitem.dead && entityitem.getItemStack() != null) { - ItemStack itemstack = entityitem.getItemStack(); - 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.i() == itemsword1.i()) { - flag = itemstack.getData() > itemstack1.getData() || itemstack.hasTag() && !itemstack1.hasTag(); - } else { - flag = itemsword.i() > itemsword1.i(); - } - } 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.c == itemarmor1.c) { - flag = itemstack.getData() > itemstack1.getData() || itemstack.hasTag() && !itemstack1.hasTag(); - } else { - flag = itemarmor.c > itemarmor1.c; - } - } else { - flag = false; - } - } - - if (flag) { - if (itemstack1 != null && this.random.nextFloat() - 0.1F < this.dropChances[i]) { - this.a(itemstack1, 0.0F); - } - - if (itemstack.getItem() == Items.DIAMOND && entityitem.j() != null) { - EntityHuman entityhuman = this.world.a(entityitem.j()); - - if (entityhuman != null) { - entityhuman.a((Statistic) AchievementList.x); - } - } - - this.setEquipment(i, itemstack); - this.dropChances[i] = 2.0F; - this.persistent = true; - this.receive(entityitem, 1); - entityitem.die(); - } - } - } - } - } - - this.world.methodProfiler.b(); - } - - protected boolean bk() { - return false; - } - - protected boolean isTypeNotPersistent() { - return true; - } - - protected void w() { - if (this.persistent) { - this.aU = 0; - } else { - 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 (d3 > 16384.0D) { // CraftBukkit - remove isTypeNotPersistent() check - this.die(); - } - - if (this.aU > 600 && this.random.nextInt(800) == 0 && d3 > 1024.0D) { // CraftBukkit - remove isTypeNotPersistent() check - this.die(); - } else if (d3 < 1024.0D) { - this.aU = 0; - } - } - } - } - - protected void bn() { - ++this.aU; - this.world.methodProfiler.a("checkDespawn"); - this.w(); - this.world.methodProfiler.b(); - this.world.methodProfiler.a("sensing"); - this.bq.a(); - this.world.methodProfiler.b(); - this.world.methodProfiler.a("targetSelector"); - this.targetSelector.a(); - this.world.methodProfiler.b(); - this.world.methodProfiler.a("goalSelector"); - this.goalSelector.a(); - this.world.methodProfiler.b(); - this.world.methodProfiler.a("navigation"); - this.navigation.f(); - this.world.methodProfiler.b(); - this.world.methodProfiler.a("mob tick"); - this.bp(); - this.world.methodProfiler.b(); - this.world.methodProfiler.a("controls"); - this.world.methodProfiler.a("move"); - this.moveController.c(); - this.world.methodProfiler.c("look"); - this.lookController.a(); - this.world.methodProfiler.c("jump"); - this.bm.b(); - this.world.methodProfiler.b(); - this.world.methodProfiler.b(); - } - - protected void bq() { - super.bq(); - this.bd = 0.0F; - this.be = 0.0F; - this.w(); - float f = 8.0F; - - if (this.random.nextFloat() < 0.02F) { - EntityHuman entityhuman = this.world.findNearbyPlayer(this, (double) f); - - if (entityhuman != null) { - this.bu = entityhuman; - this.g = 10 + this.random.nextInt(20); - } else { - this.bf = (this.random.nextFloat() - 0.5F) * 20.0F; - } - } - - if (this.bu != null) { - this.a(this.bu, 10.0F, (float) this.x()); - if (this.g-- <= 0 || this.bu.dead || this.bu.f((Entity) this) > (double) (f * f)) { - this.bu = null; - } - } else { - if (this.random.nextFloat() < 0.05F) { - this.bf = (this.random.nextFloat() - 0.5F) * 20.0F; - } - - this.yaw += this.bf; - this.pitch = this.f; - } - - boolean flag = this.M(); - boolean flag1 = this.P(); - - if (flag || flag1) { - this.bc = this.random.nextFloat() < 0.8F; - } - } - - public int x() { - return 40; - } - - public void a(Entity entity, float f, float f1) { - double d0 = entity.locX - this.locX; - double d1 = entity.locZ - this.locZ; - double d2; - - if (entity instanceof EntityLiving) { - EntityLiving entityliving = (EntityLiving) entity; - - d2 = entityliving.locY + (double) entityliving.getHeadHeight() - (this.locY + (double) this.getHeadHeight()); - } else { - d2 = (entity.boundingBox.b + entity.boundingBox.e) / 2.0D - (this.locY + (double) this.getHeadHeight()); - } - - double d3 = (double) MathHelper.sqrt(d0 * d0 + d1 * d1); - float f2 = (float) (Math.atan2(d1, d0) * 180.0D / 3.1415927410125732D) - 90.0F; - float f3 = (float) (-(Math.atan2(d2, d3) * 180.0D / 3.1415927410125732D)); - - this.pitch = this.b(this.pitch, f3, f1); - this.yaw = this.b(this.yaw, f2, f); - } - - 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; - } - - public boolean canSpawn() { - return this.world.b(this.boundingBox) && this.world.getCubes(this, this.boundingBox).isEmpty() && !this.world.containsLiquid(this.boundingBox); - } - - public int bB() { - return 4; - } - - public int ax() { - if (this.getGoalTarget() == null) { - return 3; - } else { - int i = (int) (this.getHealth() - this.getMaxHealth() * 0.33F); - - i -= (3 - this.world.difficulty.a()) * 4; - if (i < 0) { - i = 0; - } - - return i + 3; - } - } - - public ItemStack be() { - return this.equipment[0]; - } - - public ItemStack getEquipment(int i) { - return this.equipment[i]; - } - - public ItemStack r(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.g()) { - int k = Math.max(itemstack.l() - 25, 1); - int l = itemstack.l() - 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 bC() { - if (this.random.nextFloat() < 0.15F * this.world.b(this.locX, this.locY, this.locZ)) { - int i = this.random.nextInt(2); - float f = this.world.difficulty == EnumDifficulty.HARD ? 0.1F : 0.25F; - - if (this.random.nextFloat() < 0.095F) { - ++i; - } - - if (this.random.nextFloat() < 0.095F) { - ++i; - } - - if (this.random.nextFloat() < 0.095F) { - ++i; - } - - for (int j = 3; j >= 0; --j) { - ItemStack itemstack = this.r(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 static int b(ItemStack itemstack) { - if (itemstack.getItem() != Item.getItemOf(Blocks.PUMPKIN) && itemstack.getItem() != Items.SKULL) { - if (itemstack.getItem() instanceof ItemArmor) { - switch (((ItemArmor) itemstack.getItem()).b) { - 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 Items.LEATHER_HELMET; - } else if (j == 1) { - return Items.GOLD_HELMET; - } else if (j == 2) { - return Items.CHAINMAIL_HELMET; - } else if (j == 3) { - return Items.IRON_HELMET; - } else if (j == 4) { - return Items.DIAMOND_HELMET; - } - - case 3: - if (j == 0) { - return Items.LEATHER_CHESTPLATE; - } else if (j == 1) { - return Items.GOLD_CHESTPLATE; - } else if (j == 2) { - return Items.CHAINMAIL_CHESTPLATE; - } else if (j == 3) { - return Items.IRON_CHESTPLATE; - } else if (j == 4) { - return Items.DIAMOND_CHESTPLATE; - } - - case 2: - if (j == 0) { - return Items.LEATHER_LEGGINGS; - } else if (j == 1) { - return Items.GOLD_LEGGINGS; - } else if (j == 2) { - return Items.CHAINMAIL_LEGGINGS; - } else if (j == 3) { - return Items.IRON_LEGGINGS; - } else if (j == 4) { - return Items.DIAMOND_LEGGINGS; - } - - case 1: - if (j == 0) { - return Items.LEATHER_BOOTS; - } else if (j == 1) { - return Items.GOLD_BOOTS; - } else if (j == 2) { - return Items.CHAINMAIL_BOOTS; - } else if (j == 3) { - return Items.IRON_BOOTS; - } else if (j == 4) { - return Items.DIAMOND_BOOTS; - } - - default: - return null; - } - } - - protected void bD() { - float f = this.world.b(this.locX, this.locY, this.locZ); - - if (this.be() != null && this.random.nextFloat() < 0.25F * f) { - EnchantmentManager.a(this.random, this.be(), (int) (5.0F + f * (float) this.random.nextInt(18))); - } - - for (int i = 0; i < 4; ++i) { - ItemStack itemstack = this.r(i); - - if (itemstack != null && this.random.nextFloat() < 0.5F * f) { - EnchantmentManager.a(this.random, itemstack, (int) (5.0F + f * (float) this.random.nextInt(18))); - } - } - } - - public GroupDataEntity prepare(GroupDataEntity groupdataentity) { - this.getAttributeInstance(GenericAttributes.b).a(new AttributeModifier("Random spawn bonus", this.random.nextGaussian() * 0.05D, 1)); - return groupdataentity; - } - - public boolean bE() { - return false; - } - - public String getName() { - return this.hasCustomName() ? this.getCustomName() : super.getName(); - } - - public void bF() { - this.persistent = true; - } - - public void setCustomName(String s) { - this.datawatcher.watch(10, s); - } - - public String getCustomName() { - return this.datawatcher.getString(10); - } - - public boolean hasCustomName() { - return this.datawatcher.getString(10).length() > 0; - } - - public void setCustomNameVisible(boolean flag) { - this.datawatcher.watch(11, Byte.valueOf((byte) (flag ? 1 : 0))); - } - - public boolean getCustomNameVisible() { - return this.datawatcher.getByte(11) == 1; - } - - public void a(int i, float f) { - this.dropChances[i] = f; - } - - public boolean bJ() { - return this.canPickUpLoot; - } - - public void h(boolean flag) { - this.canPickUpLoot = flag; - } - - public boolean isPersistent() { - return this.persistent; - } - - public final boolean c(EntityHuman entityhuman) { - if (this.bN() && this.getLeashHolder() == entityhuman) { - // CraftBukkit start - fire PlayerUnleashEntityEvent - if (CraftEventFactory.callPlayerUnleashEntityEvent(this, entityhuman).isCancelled()) { - ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutAttachEntity(1, this, this.getLeashHolder())); - return false; - } - // CraftBukkit end - this.unleash(true, !entityhuman.abilities.canInstantlyBuild); - return true; - } else { - ItemStack itemstack = entityhuman.inventory.getItemInHand(); - - if (itemstack != null && itemstack.getItem() == Items.LEASH && this.bM()) { - if (!(this instanceof EntityTameableAnimal) || !((EntityTameableAnimal) this).isTamed()) { - // CraftBukkit start - fire PlayerLeashEntityEvent - if (CraftEventFactory.callPlayerLeashEntityEvent(this, entityhuman, entityhuman).isCancelled()) { - ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutAttachEntity(1, this, this.getLeashHolder())); - return false; - } - // CraftBukkit end - this.setLeashHolder(entityhuman, true); - --itemstack.count; - return true; - } - - if (((EntityTameableAnimal) this).e(entityhuman)) { - // CraftBukkit start - fire PlayerLeashEntityEvent - if (CraftEventFactory.callPlayerLeashEntityEvent(this, entityhuman, entityhuman).isCancelled()) { - ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutAttachEntity(1, this, this.getLeashHolder())); - return false; - } - // CraftBukkit end - this.setLeashHolder(entityhuman, true); - --itemstack.count; - return true; - } - } - - return this.a(entityhuman) ? true : super.c(entityhuman); - } - } - - protected boolean a(EntityHuman entityhuman) { - return false; - } - - protected void bL() { - if (this.bx != null) { - this.bP(); - } - - if (this.bv) { - if (this.bw == null || this.bw.dead) { - this.world.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.HOLDER_GONE)); // CraftBukkit - this.unleash(true, true); - } - } - } - - public void unleash(boolean flag, boolean flag1) { - if (this.bv) { - this.bv = false; - this.bw = null; - if (!this.world.isStatic && flag1) { - this.a(Items.LEASH, 1); - } - - if (!this.world.isStatic && flag && this.world instanceof WorldServer) { - ((WorldServer) this.world).getTracker().a((Entity) this, (Packet) (new PacketPlayOutAttachEntity(1, this, (Entity) null))); - } - } - } - - public boolean bM() { - return !this.bN() && !(this instanceof IMonster); - } - - public boolean bN() { - return this.bv; - } - - public Entity getLeashHolder() { - return this.bw; - } - - public void setLeashHolder(Entity entity, boolean flag) { - this.bv = true; - this.bw = entity; - if (!this.world.isStatic && flag && this.world instanceof WorldServer) { - ((WorldServer) this.world).getTracker().a((Entity) this, (Packet) (new PacketPlayOutAttachEntity(1, this, this.bw))); - } - } - - private void bP() { - if (this.bv && this.bx != null) { - if (this.bx.hasKeyOfType("UUIDMost", 4) && this.bx.hasKeyOfType("UUIDLeast", 4)) { - UUID uuid = new UUID(this.bx.getLong("UUIDMost"), this.bx.getLong("UUIDLeast")); - List list = this.world.a(EntityLiving.class, this.boundingBox.grow(10.0D, 10.0D, 10.0D)); - Iterator iterator = list.iterator(); - - while (iterator.hasNext()) { - EntityLiving entityliving = (EntityLiving) iterator.next(); - - if (entityliving.getUniqueID().equals(uuid)) { - this.bw = entityliving; - break; - } - } - } else if (this.bx.hasKeyOfType("X", 99) && this.bx.hasKeyOfType("Y", 99) && this.bx.hasKeyOfType("Z", 99)) { - int i = this.bx.getInt("X"); - int j = this.bx.getInt("Y"); - int k = this.bx.getInt("Z"); - EntityLeash entityleash = EntityLeash.b(this.world, i, j, k); - - if (entityleash == null) { - entityleash = EntityLeash.a(this.world, i, j, k); - } - - this.bw = entityleash; - } else { - this.world.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.UNKNOWN)); // CraftBukkit - this.unleash(false, true); - } - } - - this.bx = null; - } -} diff --git a/src/main/java/net/minecraft/server/EntityIronGolem.java b/src/main/java/net/minecraft/server/EntityIronGolem.java deleted file mode 100644 index a274d03c..00000000 --- a/src/main/java/net/minecraft/server/EntityIronGolem.java +++ /dev/null @@ -1,190 +0,0 @@ -package net.minecraft.server; - -public class EntityIronGolem extends EntityGolem { - - private int bq; - Village bp; - private int br; - private int bs; - - public EntityIronGolem(World world) { - super(world); - this.a(1.4F, 2.9F); - this.getNavigation().a(true); - this.goalSelector.a(1, new PathfinderGoalMeleeAttack(this, 1.0D, true)); - this.goalSelector.a(2, new PathfinderGoalMoveTowardsTarget(this, 0.9D, 32.0F)); - this.goalSelector.a(3, new PathfinderGoalMoveThroughVillage(this, 0.6D, true)); - this.goalSelector.a(4, new PathfinderGoalMoveTowardsRestriction(this, 1.0D)); - this.goalSelector.a(5, new PathfinderGoalOfferFlower(this)); - this.goalSelector.a(6, new PathfinderGoalRandomStroll(this, 0.6D)); - this.goalSelector.a(7, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 6.0F)); - 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, EntityInsentient.class, 0, false, true, IMonster.a)); - } - - protected void c() { - super.c(); - this.datawatcher.a(16, Byte.valueOf((byte) 0)); - } - - public boolean bk() { - return true; - } - - protected void bp() { - if (--this.bq <= 0) { - this.bq = 70 + this.random.nextInt(50); - this.bp = this.world.villages.getClosestVillage(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ), 32); - if (this.bp == null) { - this.bX(); - } else { - ChunkCoordinates chunkcoordinates = this.bp.getCenter(); - - this.a(chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z, (int) ((float) this.bp.getSize() * 0.6F)); - } - } - - super.bp(); - } - - protected void aD() { - super.aD(); - this.getAttributeInstance(GenericAttributes.maxHealth).setValue(100.0D); - this.getAttributeInstance(GenericAttributes.d).setValue(0.25D); - } - - protected int j(int i) { - return i; - } - - protected void o(Entity entity) { - if (entity instanceof IMonster && this.aI().nextInt(20) == 0) { - // CraftBukkit start - org.bukkit.event.entity.EntityTargetLivingEntityEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTargetLivingEvent(this, (EntityLiving) entity, org.bukkit.event.entity.EntityTargetEvent.TargetReason.COLLISION); - if (!event.isCancelled()) { - if (event.getTarget() == null) { - this.setGoalTarget(null); - } else { - this.setGoalTarget(((org.bukkit.craftbukkit.entity.CraftLivingEntity) event.getTarget()).getHandle()); - } - } - // CraftBukkit end - } - - super.o(entity); - } - - public void e() { - super.e(); - if (this.br > 0) { - --this.br; - } - - if (this.bs > 0) { - --this.bs; - } - - if (this.motX * this.motX + this.motZ * this.motZ > 2.500000277905201E-7D && this.random.nextInt(5) == 0) { - int i = MathHelper.floor(this.locX); - int j = MathHelper.floor(this.locY - 0.20000000298023224D - (double) this.height); - int k = MathHelper.floor(this.locZ); - Block block = this.world.getType(i, j, k); - - if (block.getMaterial() != Material.AIR) { - this.world.addParticle("blockcrack_" + Block.getId(block) + "_" + this.world.getData(i, j, k), 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.isPlayerCreated() && EntityHuman.class.isAssignableFrom(oclass) ? false : super.a(oclass); - } - - public void b(NBTTagCompound nbttagcompound) { - super.b(nbttagcompound); - nbttagcompound.setBoolean("PlayerCreated", this.isPlayerCreated()); - } - - public void a(NBTTagCompound nbttagcompound) { - super.a(nbttagcompound); - this.setPlayerCreated(nbttagcompound.getBoolean("PlayerCreated")); - } - - public boolean n(Entity entity) { - this.br = 10; - this.world.broadcastEntityEffect(this, (byte) 4); - boolean flag = entity.damageEntity(DamageSource.mobAttack(this), (float) (7 + this.random.nextInt(15))); - - if (flag) { - entity.motY += 0.4000000059604645D; - } - - this.makeSound("mob.irongolem.throw", 1.0F, 1.0F); - return flag; - } - - public Village bZ() { - return this.bp; - } - - public void a(boolean flag) { - this.bs = flag ? 400 : 0; - this.world.broadcastEntityEffect(this, (byte) 11); - } - - protected String aT() { - return "mob.irongolem.hit"; - } - - protected String aU() { - return "mob.irongolem.death"; - } - - protected void a(int i, int j, int k, Block block) { - this.makeSound("mob.irongolem.walk", 1.0F, 1.0F); - } - - protected void dropDeathLoot(boolean flag, int i) { - int j = this.random.nextInt(3); - - int k; - - for (k = 0; k < j; ++k) { - this.a(Item.getItemOf(Blocks.RED_ROSE), 1, 0.0F); - } - - k = 3 + this.random.nextInt(3); - - for (int l = 0; l < k; ++l) { - this.a(Items.IRON_INGOT, 1); - } - } - - public int cb() { - return this.bs; - } - - public boolean isPlayerCreated() { - return (this.datawatcher.getByte(16) & 1) != 0; - } - - public void setPlayerCreated(boolean flag) { - byte b0 = this.datawatcher.getByte(16); - - if (flag) { - this.datawatcher.watch(16, Byte.valueOf((byte) (b0 | 1))); - } else { - this.datawatcher.watch(16, Byte.valueOf((byte) (b0 & -2))); - } - } - - public void die(DamageSource damagesource) { - if (!this.isPlayerCreated() && this.killer != null && this.bp != null) { - this.bp.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 deleted file mode 100644 index 394bfbf6..00000000 --- a/src/main/java/net/minecraft/server/EntityItem.java +++ /dev/null @@ -1,341 +0,0 @@ -package net.minecraft.server; - -import java.util.Iterator; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import org.bukkit.event.player.PlayerPickupItemEvent; // CraftBukkit - -public class EntityItem extends Entity { - - private static final Logger d = LogManager.getLogger(); - public int age; - public int pickupDelay; - private int e; - private String f; - private String g; - public float c; - private int lastTick = MinecraftServer.currentTick; // CraftBukkit - - public EntityItem(World world, double d0, double d1, double d2) { - super(world); - this.e = 5; - this.c = (float) (Math.random() * 3.141592653589793D * 2.0D); - this.a(0.25F, 0.25F); - this.height = this.length / 2.0F; - this.setPosition(d0, d1, d2); - 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)); - } - - public EntityItem(World world, double d0, double d1, double d2, ItemStack itemstack) { - this(world, d0, d1, d2); - // CraftBukkit start - Can't set null items in the datawatcher - if (itemstack == null || itemstack.getItem() == null) { - return; - } - // CraftBukkit end - this.setItemStack(itemstack); - } - - protected boolean g_() { - return false; - } - - public EntityItem(World world) { - super(world); - this.e = 5; - this.c = (float) (Math.random() * 3.141592653589793D * 2.0D); - this.a(0.25F, 0.25F); - this.height = this.length / 2.0F; - } - - protected void c() { - this.getDataWatcher().add(10, 5); - } - - public void h() { - if (this.getItemStack() == null) { - this.die(); - } else { - super.h(); - // CraftBukkit start - Use wall time for pickup and despawn timers - int elapsedTicks = MinecraftServer.currentTick - this.lastTick; - this.pickupDelay -= elapsedTicks; - this.age += elapsedTicks; - this.lastTick = MinecraftServer.currentTick; - // CraftBukkit end - - this.lastX = this.locX; - this.lastY = this.locY; - this.lastZ = this.locZ; - this.motY -= 0.03999999910593033D; - this.X = this.j(this.locX, (this.boundingBox.b + this.boundingBox.e) / 2.0D, this.locZ); - this.move(this.motX, this.motY, this.motZ); - boolean flag = (int) this.lastX != (int) this.locX || (int) this.lastY != (int) this.locY || (int) this.lastZ != (int) this.locZ; - - if (flag || this.ticksLived % 25 == 0) { - if (this.world.getType(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ)).getMaterial() == Material.LAVA) { - this.motY = 0.20000000298023224D; - this.motX = (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F); - this.motZ = (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F); - this.makeSound("random.fizz", 0.4F, 2.0F + this.random.nextFloat() * 0.4F); - } - - if (!this.world.isStatic) { - this.k(); - } - } - - float f = 0.98F; - - if (this.onGround) { - f = this.world.getType(MathHelper.floor(this.locX), MathHelper.floor(this.boundingBox.b) - 1, MathHelper.floor(this.locZ)).frictionFactor * 0.98F; - } - - this.motX *= (double) f; - this.motY *= 0.9800000190734863D; - this.motZ *= (double) f; - if (this.onGround) { - this.motY *= -0.5D; - } - - // ++this.age; // CraftBukkit - Moved up - if (!this.world.isStatic && this.age >= 6000) { - // CraftBukkit start - fire ItemDespawnEvent - if (org.bukkit.craftbukkit.event.CraftEventFactory.callItemDespawnEvent(this).isCancelled()) { - this.age = 0; - return; - } - // CraftBukkit end - this.die(); - } - } - } - - private void k() { - Iterator iterator = this.world.a(EntityItem.class, this.boundingBox.grow(0.5D, 0.0D, 0.5D)).iterator(); - - while (iterator.hasNext()) { - EntityItem entityitem = (EntityItem) iterator.next(); - - this.a(entityitem); - } - } - - public boolean a(EntityItem entityitem) { - if (entityitem == this) { - return false; - } else if (entityitem.isAlive() && this.isAlive()) { - ItemStack itemstack = this.getItemStack(); - ItemStack itemstack1 = entityitem.getItemStack(); - - if (itemstack1.getItem() != itemstack.getItem()) { - return false; - } else if (itemstack1.hasTag() ^ itemstack.hasTag()) { - return false; - } else if (itemstack1.hasTag() && !itemstack1.getTag().equals(itemstack.getTag())) { - return false; - } else if (itemstack1.getItem() == null) { - return false; - } else if (itemstack1.getItem().n() && itemstack1.getData() != itemstack.getData()) { - return false; - } else if (itemstack1.count < itemstack.count) { - return entityitem.a(this); - } else if (itemstack1.count + itemstack.count > itemstack1.getMaxStackSize()) { - return false; - } else { - itemstack1.count += itemstack.count; - entityitem.pickupDelay = Math.max(entityitem.pickupDelay, this.pickupDelay); - entityitem.age = Math.min(entityitem.age, this.age); - entityitem.setItemStack(itemstack1); - this.die(); - return true; - } - } else { - return false; - } - } - - public void e() { - this.age = 4800; - } - - public boolean N() { - return this.world.a(this.boundingBox, Material.WATER, (Entity) this); - } - - protected void burn(int i) { - this.damageEntity(DamageSource.FIRE, (float) i); - } - - public boolean damageEntity(DamageSource damagesource, float f) { - if (this.isInvulnerable()) { - return false; - } else if (this.getItemStack() != null && this.getItemStack().getItem() == Items.NETHER_STAR && damagesource.isExplosion()) { - return false; - } else { - this.Q(); - this.e = (int) ((float) this.e - f); - if (this.e <= 0) { - this.die(); - } - - return false; - } - } - - public void b(NBTTagCompound nbttagcompound) { - nbttagcompound.setShort("Health", (short) ((byte) this.e)); - nbttagcompound.setShort("Age", (short) this.age); - if (this.j() != null) { - nbttagcompound.setString("Thrower", this.f); - } - - if (this.i() != null) { - nbttagcompound.setString("Owner", this.g); - } - - if (this.getItemStack() != null) { - nbttagcompound.set("Item", this.getItemStack().save(new NBTTagCompound())); - } - } - - public void a(NBTTagCompound nbttagcompound) { - this.e = nbttagcompound.getShort("Health") & 255; - this.age = nbttagcompound.getShort("Age"); - if (nbttagcompound.hasKey("Owner")) { - this.g = nbttagcompound.getString("Owner"); - } - - if (nbttagcompound.hasKey("Thrower")) { - this.f = nbttagcompound.getString("Thrower"); - } - - NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("Item"); - - // CraftBukkit start - Handle missing "Item" compounds - if (nbttagcompound1 != null) { - ItemStack itemstack = ItemStack.createStack(nbttagcompound1); - if (itemstack != null) { - this.setItemStack(itemstack); - } else { - this.die(); - } - } else { - this.die(); - } - // CraftBukkit end - if (this.getItemStack() == null) { - this.die(); - } - } - - public void b_(EntityHuman entityhuman) { - if (!this.world.isStatic) { - ItemStack itemstack = this.getItemStack(); - int i = itemstack.count; - - // CraftBukkit start - fire PlayerPickupItemEvent - int canHold = entityhuman.inventory.canHold(itemstack); - int remaining = itemstack.count - canHold; - - if (this.pickupDelay <= 0 && canHold > 0) { - itemstack.count = canHold; - PlayerPickupItemEvent event = new PlayerPickupItemEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), (org.bukkit.entity.Item) this.getBukkitEntity(), remaining); - // event.setCancelled(!entityhuman.canPickUpLoot); TODO - this.world.getServer().getPluginManager().callEvent(event); - itemstack.count = canHold + remaining; - - if (event.isCancelled()) { - return; - } - - // Possibly < 0; fix here so we do not have to modify code below - this.pickupDelay = 0; - } - // CraftBukkit end - - if (this.pickupDelay == 0 && (this.g == null || 6000 - this.age <= 200 || this.g.equals(entityhuman.getName())) && entityhuman.inventory.pickup(itemstack)) { - if (itemstack.getItem() == Item.getItemOf(Blocks.LOG)) { - entityhuman.a((Statistic) AchievementList.g); - } - - if (itemstack.getItem() == Item.getItemOf(Blocks.LOG2)) { - entityhuman.a((Statistic) AchievementList.g); - } - - if (itemstack.getItem() == Items.LEATHER) { - entityhuman.a((Statistic) AchievementList.t); - } - - if (itemstack.getItem() == Items.DIAMOND) { - entityhuman.a((Statistic) AchievementList.w); - } - - if (itemstack.getItem() == Items.BLAZE_ROD) { - entityhuman.a((Statistic) AchievementList.A); - } - - if (itemstack.getItem() == Items.DIAMOND && this.j() != null) { - EntityHuman entityhuman1 = this.world.a(this.j()); - - if (entityhuman1 != null && entityhuman1 != entityhuman) { - entityhuman1.a((Statistic) AchievementList.x); - } - } - - this.world.makeSound(entityhuman, "random.pop", 0.2F, ((this.random.nextFloat() - this.random.nextFloat()) * 0.7F + 1.0F) * 2.0F); - entityhuman.receive(this, i); - if (itemstack.count <= 0) { - this.die(); - } - } - } - } - - public String getName() { - return LocaleI18n.get("item." + this.getItemStack().a()); - } - - public boolean av() { - return false; - } - - public void b(int i) { - super.b(i); - if (!this.world.isStatic) { - this.k(); - } - } - - public ItemStack getItemStack() { - ItemStack itemstack = this.getDataWatcher().getItemStack(10); - - return itemstack == null ? new ItemStack(Blocks.STONE) : itemstack; - } - - public void setItemStack(ItemStack itemstack) { - this.getDataWatcher().watch(10, itemstack); - this.getDataWatcher().update(10); - } - - public String i() { - return this.g; - } - - public void a(String s) { - this.g = s; - } - - public String j() { - return this.f; - } - - public void b(String s) { - this.f = s; - } -} diff --git a/src/main/java/net/minecraft/server/EntityItemFrame.java b/src/main/java/net/minecraft/server/EntityItemFrame.java deleted file mode 100644 index d1d73f91..00000000 --- a/src/main/java/net/minecraft/server/EntityItemFrame.java +++ /dev/null @@ -1,152 +0,0 @@ -package net.minecraft.server; - -public class EntityItemFrame extends EntityHanging { - - private float e = 1.0F; - - public EntityItemFrame(World world) { - super(world); - } - - public EntityItemFrame(World world, int i, int j, int k, int l) { - super(world, i, j, k, l); - this.setDirection(l); - } - - protected void c() { - this.getDataWatcher().add(2, 5); - this.getDataWatcher().a(3, Byte.valueOf((byte) 0)); - } - - public boolean damageEntity(DamageSource damagesource, float f) { - if (this.isInvulnerable()) { - return false; - } else if (this.getItem() != null) { - if (!this.world.isStatic) { - // CraftBukkit start - fire EntityDamageEvent - if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f, false) || this.dead) { - return true; - } - // CraftBukkit end - - this.b(damagesource.getEntity(), false); - this.setItem((ItemStack) null); - } - - return true; - } else { - return super.damageEntity(damagesource, f); - } - } - - public int f() { - return 9; - } - - public int i() { - return 9; - } - - public void b(Entity entity) { - this.b(entity, true); - } - - public void b(Entity entity, boolean flag) { - ItemStack itemstack = this.getItem(); - - if (entity instanceof EntityHuman) { - EntityHuman entityhuman = (EntityHuman) entity; - - if (entityhuman.abilities.canInstantlyBuild) { - this.b(itemstack); - return; - } - } - - if (flag) { - this.a(new ItemStack(Items.ITEM_FRAME), 0.0F); - } - - if (itemstack != null && this.random.nextFloat() < this.e) { - itemstack = itemstack.cloneItemStack(); - this.b(itemstack); - this.a(itemstack, 0.0F); - } - } - - private void b(ItemStack itemstack) { - if (itemstack != null) { - if (itemstack.getItem() == Items.MAP) { - WorldMap worldmap = ((ItemWorldMap) itemstack.getItem()).getSavedMap(itemstack, this.world); - - worldmap.decorations.remove("frame-" + this.getId()); - } - - itemstack.a((EntityItemFrame) null); - } - } - - public ItemStack getItem() { - return this.getDataWatcher().getItemStack(2); - } - - public void setItem(ItemStack itemstack) { - if (itemstack != null) { - itemstack = itemstack.cloneItemStack(); - itemstack.count = 1; - itemstack.a(this); - } - - this.getDataWatcher().watch(2, itemstack); - this.getDataWatcher().update(2); - } - - public int getRotation() { - return this.getDataWatcher().getByte(3); - } - - public void setRotation(int i) { - this.getDataWatcher().watch(3, Byte.valueOf((byte) (i % 4))); - } - - public void b(NBTTagCompound nbttagcompound) { - if (this.getItem() != null) { - nbttagcompound.set("Item", this.getItem().save(new NBTTagCompound())); - nbttagcompound.setByte("ItemRotation", (byte) this.getRotation()); - nbttagcompound.setFloat("ItemDropChance", this.e); - } - - super.b(nbttagcompound); - } - - public void a(NBTTagCompound nbttagcompound) { - NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("Item"); - - if (nbttagcompound1 != null && !nbttagcompound1.isEmpty()) { - this.setItem(ItemStack.createStack(nbttagcompound1)); - this.setRotation(nbttagcompound.getByte("ItemRotation")); - if (nbttagcompound.hasKeyOfType("ItemDropChance", 99)) { - this.e = nbttagcompound.getFloat("ItemDropChance"); - } - } - - super.a(nbttagcompound); - } - - public boolean c(EntityHuman entityhuman) { - if (this.getItem() == null) { - ItemStack itemstack = entityhuman.be(); - - if (itemstack != null && !this.world.isStatic) { - this.setItem(itemstack); - if (!entityhuman.abilities.canInstantlyBuild && --itemstack.count <= 0) { - entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, (ItemStack) null); - } - } - } else if (!this.world.isStatic) { - this.setRotation(this.getRotation() + 1); - } - - return true; - } -} diff --git a/src/main/java/net/minecraft/server/EntityLargeFireball.java b/src/main/java/net/minecraft/server/EntityLargeFireball.java deleted file mode 100644 index 326f7ea6..00000000 --- a/src/main/java/net/minecraft/server/EntityLargeFireball.java +++ /dev/null @@ -1,49 +0,0 @@ -package net.minecraft.server; - -import org.bukkit.event.entity.ExplosionPrimeEvent; // CraftBukkit - -public class EntityLargeFireball extends EntityFireball { - - public int yield = 1; - - 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.0F); - } - - // CraftBukkit start - fire ExplosionPrimeEvent - 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(); - } - } - - public void b(NBTTagCompound nbttagcompound) { - super.b(nbttagcompound); - nbttagcompound.setInt("ExplosionPower", this.yield); - } - - public void a(NBTTagCompound nbttagcompound) { - super.a(nbttagcompound); - if (nbttagcompound.hasKeyOfType("ExplosionPower", 99)) { - // CraftBukkit - set bukkitYield when setting explosionpower - this.bukkitYield = this.yield = nbttagcompound.getInt("ExplosionPower"); - } - } -} diff --git a/src/main/java/net/minecraft/server/EntityLeash.java b/src/main/java/net/minecraft/server/EntityLeash.java deleted file mode 100644 index 9b2ac823..00000000 --- a/src/main/java/net/minecraft/server/EntityLeash.java +++ /dev/null @@ -1,137 +0,0 @@ -package net.minecraft.server; - -import java.util.Iterator; -import java.util.List; - -import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit - -public class EntityLeash extends EntityHanging { - - public EntityLeash(World world) { - super(world); - } - - public EntityLeash(World world, int i, int j, int k) { - super(world, i, j, k, 0); - this.setPosition((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D); - } - - protected void c() { - super.c(); - } - - public void setDirection(int i) {} - - public int f() { - return 9; - } - - public int i() { - return 9; - } - - public void b(Entity entity) {} - - public boolean d(NBTTagCompound nbttagcompound) { - return false; - } - - public void b(NBTTagCompound nbttagcompound) {} - - public void a(NBTTagCompound nbttagcompound) {} - - public boolean c(EntityHuman entityhuman) { - ItemStack itemstack = entityhuman.be(); - boolean flag = false; - double d0; - List list; - Iterator iterator; - EntityInsentient entityinsentient; - - if (itemstack != null && itemstack.getItem() == Items.LEASH && !this.world.isStatic) { - d0 = 7.0D; - list = this.world.a(EntityInsentient.class, AxisAlignedBB.a(this.locX - d0, this.locY - d0, this.locZ - d0, this.locX + d0, this.locY + d0, this.locZ + d0)); - if (list != null) { - iterator = list.iterator(); - - while (iterator.hasNext()) { - entityinsentient = (EntityInsentient) iterator.next(); - if (entityinsentient.bN() && entityinsentient.getLeashHolder() == entityhuman) { - // CraftBukkit start - if (CraftEventFactory.callPlayerLeashEntityEvent(entityinsentient, this, entityhuman).isCancelled()) { - ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutAttachEntity(1, entityinsentient, entityinsentient.getLeashHolder())); - continue; - } - // CraftBukkit end - entityinsentient.setLeashHolder(this, true); - flag = true; - } - } - } - } - - if (!this.world.isStatic && !flag) { - // CraftBukkit start - Move below - // this.die(); - boolean die = true; - // CraftBukkit end - if (true || entityhuman.abilities.canInstantlyBuild) { // CraftBukkit - Process for non-creative as well - d0 = 7.0D; - list = this.world.a(EntityInsentient.class, AxisAlignedBB.a(this.locX - d0, this.locY - d0, this.locZ - d0, this.locX + d0, this.locY + d0, this.locZ + d0)); - if (list != null) { - iterator = list.iterator(); - - while (iterator.hasNext()) { - entityinsentient = (EntityInsentient) iterator.next(); - if (entityinsentient.bN() && entityinsentient.getLeashHolder() == this) { - // CraftBukkit start - if (CraftEventFactory.callPlayerUnleashEntityEvent(entityinsentient, entityhuman).isCancelled()) { - die = false; - continue; - } - entityinsentient.unleash(true, !entityhuman.abilities.canInstantlyBuild); // false -> survival mode boolean - // CraftBukkit end - } - } - } - } - // CraftBukkit start - if (die) { - this.die(); - } - // CraftBukkit end - } - - return true; - } - - public boolean survives() { - return this.world.getType(this.x, this.y, this.z).b() == 11; - } - - public static EntityLeash a(World world, int i, int j, int k) { - EntityLeash entityleash = new EntityLeash(world, i, j, k); - - entityleash.attachedToPlayer = true; - world.addEntity(entityleash); - return entityleash; - } - - public static EntityLeash b(World world, int i, int j, int k) { - List list = world.a(EntityLeash.class, AxisAlignedBB.a((double) i - 1.0D, (double) j - 1.0D, (double) k - 1.0D, (double) i + 1.0D, (double) j + 1.0D, (double) k + 1.0D)); - - if (list != null) { - Iterator iterator = list.iterator(); - - while (iterator.hasNext()) { - EntityLeash entityleash = (EntityLeash) iterator.next(); - - if (entityleash.x == i && entityleash.y == j && entityleash.z == k) { - return entityleash; - } - } - } - - return null; - } -} diff --git a/src/main/java/net/minecraft/server/EntityLightning.java b/src/main/java/net/minecraft/server/EntityLightning.java deleted file mode 100644 index 66402a05..00000000 --- a/src/main/java/net/minecraft/server/EntityLightning.java +++ /dev/null @@ -1,133 +0,0 @@ -package net.minecraft.server; - -import java.util.List; - -import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit - -public class EntityLightning extends EntityWeather { - - private int lifeTicks; - public long a; - private int c; - - // CraftBukkit start - public boolean isEffect = false; - - public EntityLightning(World world, double d0, double d1, double d2) { - this(world, d0, d1, d2, false); - } - - public EntityLightning(World world, double d0, double d1, double d2, boolean isEffect) { - // CraftBukkit end - - super(world); - - // CraftBukkit - Set isEffect - this.isEffect = isEffect; - - this.setPositionRotation(d0, d1, d2, 0.0F, 0.0F); - this.lifeTicks = 2; - this.a = this.random.nextLong(); - this.c = this.random.nextInt(3) + 1; - - // CraftBukkit - add "!isEffect" - if (!isEffect && !world.isStatic && world.getGameRules().getBoolean("doFireTick") && (world.difficulty == EnumDifficulty.NORMAL || world.difficulty == EnumDifficulty.HARD) && world.areChunksLoaded(MathHelper.floor(d0), MathHelper.floor(d1), MathHelper.floor(d2), 10)) { - int i = MathHelper.floor(d0); - int j = MathHelper.floor(d1); - int k = MathHelper.floor(d2); - - if (world.getType(i, j, k).getMaterial() == Material.AIR && Blocks.FIRE.canPlace(world, i, j, k)) { - // CraftBukkit start - if (!CraftEventFactory.callBlockIgniteEvent(world, i, j, k, this).isCancelled()) { - world.setTypeUpdate(i, j, k, Blocks.FIRE); - } - // CraftBukkit end - } - - for (i = 0; i < 4; ++i) { - j = MathHelper.floor(d0) + this.random.nextInt(3) - 1; - k = MathHelper.floor(d1) + this.random.nextInt(3) - 1; - int l = MathHelper.floor(d2) + this.random.nextInt(3) - 1; - - if (world.getType(j, k, l).getMaterial() == Material.AIR && Blocks.FIRE.canPlace(world, j, k, l)) { - // CraftBukkit start - if (!CraftEventFactory.callBlockIgniteEvent(world, j, k, l, this).isCancelled()) { - world.setTypeUpdate(j, k, l, Blocks.FIRE); - } - // CraftBukkit end - } - } - } - } - - public void h() { - super.h(); - if (this.lifeTicks == 2) { - // CraftBukkit start - Use relative location for far away sounds - //this.world.makeSound(this.locX, this.locY, this.locZ, "ambient.weather.thunder", 10000.0F, 0.8F + this.random.nextFloat() * 0.2F); - float pitch = 0.8F + this.random.nextFloat() * 0.2F; - int viewDistance = ((WorldServer) this.world).getServer().getViewDistance() * 16; - for (EntityPlayer player : (List<EntityPlayer>) this.world.players) { - double deltaX = this.locX - player.locX; - double deltaZ = this.locZ - player.locZ; - double distanceSquared = deltaX * deltaX + deltaZ * deltaZ; - if (distanceSquared > viewDistance * viewDistance) { - double deltaLength = Math.sqrt(distanceSquared); - double relativeX = player.locX + (deltaX / deltaLength) * viewDistance; - double relativeZ = player.locZ + (deltaZ / deltaLength) * viewDistance; - player.playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect("ambient.weather.thunder", relativeX, this.locY, relativeZ, 10000.0F, pitch)); - } else { - player.playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect("ambient.weather.thunder", this.locX, this.locY, this.locZ, 10000.0F, pitch)); - } - } - // CraftBukkit end - this.world.makeSound(this.locX, this.locY, this.locZ, "random.explode", 2.0F, 0.5F + this.random.nextFloat() * 0.2F); - } - - --this.lifeTicks; - if (this.lifeTicks < 0) { - if (this.c == 0) { - this.die(); - } else if (this.lifeTicks < -this.random.nextInt(10)) { - --this.c; - this.lifeTicks = 1; - this.a = this.random.nextLong(); - // CraftBukkit - add "!isEffect" - if (!isEffect && !this.world.isStatic && this.world.getGameRules().getBoolean("doFireTick") && this.world.areChunksLoaded(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ), 10)) { - int i = MathHelper.floor(this.locX); - int j = MathHelper.floor(this.locY); - int k = MathHelper.floor(this.locZ); - - if (this.world.getType(i, j, k).getMaterial() == Material.AIR && Blocks.FIRE.canPlace(this.world, i, j, k)) { - // CraftBukkit start - if (!CraftEventFactory.callBlockIgniteEvent(world, i, j, k, this).isCancelled()) { - this.world.setTypeUpdate(i, j, k, Blocks.FIRE); - } - // CraftBukkit end - } - } - } - } - - if (this.lifeTicks >= 0 && !this.isEffect) { // CraftBukkit - add !this.isEffect - if (this.world.isStatic) { - this.world.q = 2; - } else { - double d0 = 3.0D; - List list = this.world.getEntities(this, AxisAlignedBB.a(this.locX - d0, this.locY - d0, this.locZ - d0, this.locX + d0, this.locY + 6.0D + d0, this.locZ + d0)); - - for (int l = 0; l < list.size(); ++l) { - Entity entity = (Entity) list.get(l); - - entity.a(this); - } - } - } - } - - protected void c() {} - - protected void a(NBTTagCompound nbttagcompound) {} - - protected void b(NBTTagCompound nbttagcompound) {} -} diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java deleted file mode 100644 index 0c63b2c6..00000000 --- a/src/main/java/net/minecraft/server/EntityLiving.java +++ /dev/null @@ -1,1720 +0,0 @@ -package net.minecraft.server; - -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Random; -import java.util.UUID; - -// CraftBukkit start -import java.util.ArrayList; -import com.google.common.base.Function; -import org.bukkit.craftbukkit.event.CraftEventFactory; -import org.bukkit.event.entity.EntityDamageEvent; -import org.bukkit.event.entity.EntityDamageEvent.DamageModifier; -import org.bukkit.event.entity.EntityRegainHealthEvent; -// CraftBukkit end - -public abstract class EntityLiving extends Entity { - - private static final UUID b = UUID.fromString("662A6B8D-DA3E-4C1C-8813-96EA6097278D"); - private static final AttributeModifier c = (new AttributeModifier(b, "Sprinting speed boost", 0.30000001192092896D, 2)).a(false); - private AttributeMapBase d; - public CombatTracker combatTracker = new CombatTracker(this); // CraftBukkit - private -> public, remove final - public final HashMap effects = new HashMap(); // CraftBukkit - protected -> public - private final ItemStack[] g = new ItemStack[5]; - public boolean at; - public int au; - public int av; - public float aw; - public int hurtTicks; - public int ay; - public float az; - public int deathTicks; - public int attackTicks; - public float aC; - public float aD; - public float aE; - public float aF; - public float aG; - public int maxNoDamageTicks = 20; - public float aI; - public float aJ; - public float aK; - public float aL; - public float aM; - public float aN; - public float aO; - public float aP; - public float aQ = 0.02F; - public EntityHuman killer; // CraftBukkit - protected -> public - protected int lastDamageByPlayerTime; - protected boolean aT; - protected int aU; - protected float aV; - protected float aW; - protected float aX; - protected float aY; - protected float aZ; - protected int ba; - public float lastDamage; // CraftBukkit - protected -> public - protected boolean bc; - public float bd; - public float be; - protected float bf; - protected int bg; - protected double bh; - protected double bi; - protected double bj; - protected double bk; - protected double bl; - public boolean updateEffects = true; // CraftBukkit - private -> public - public EntityLiving lastDamager; // CraftBukkit - private -> public - private int bm; - private EntityLiving bn; - private int bo; - private float bp; - private int bq; - private float br; - // CraftBukkit start - public int expToDrop; - public int maxAirTicks = 300; - ArrayList<org.bukkit.inventory.ItemStack> drops = null; - // CraftBukkit end - - public EntityLiving(World world) { - super(world); - this.aD(); - // CraftBukkit - setHealth(getMaxHealth()) inlined and simplified to skip the instanceof check for EntityPlayer, as getBukkitEntity() is not initialized in constructor - this.datawatcher.watch(6, (float) this.getAttributeInstance(GenericAttributes.maxHealth).getValue()); - this.k = true; - this.aL = (float) (Math.random() + 1.0D) * 0.01F; - this.setPosition(this.locX, this.locY, this.locZ); - this.aK = (float) Math.random() * 12398.0F; - this.yaw = (float) (Math.random() * 3.1415927410125732D * 2.0D); - this.aO = this.yaw; - this.W = 0.5F; - } - - protected void c() { - this.datawatcher.a(7, Integer.valueOf(0)); - this.datawatcher.a(8, Byte.valueOf((byte) 0)); - this.datawatcher.a(9, Byte.valueOf((byte) 0)); - this.datawatcher.a(6, Float.valueOf(1.0F)); - } - - protected void aD() { - this.getAttributeMap().b(GenericAttributes.maxHealth); - this.getAttributeMap().b(GenericAttributes.c); - this.getAttributeMap().b(GenericAttributes.d); - if (!this.bk()) { - this.getAttributeInstance(GenericAttributes.d).setValue(0.10000000149011612D); - } - } - - protected void a(double d0, boolean flag) { - if (!this.M()) { - this.N(); - } - - 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); - Block block = this.world.getType(i, j, k); - - if (block.getMaterial() == Material.AIR) { - int l = this.world.getType(i, j - 1, k).b(); - - if (l == 11 || l == 32 || l == 21) { - block = this.world.getType(i, j - 1, k); - } - } else if (!this.world.isStatic && this.fallDistance > 3.0F) { - // CraftBukkit start - supply player as argument in particles for visibility API to work - if (this instanceof EntityPlayer) { - this.world.a((EntityHuman) this, 2006, i, j, k, MathHelper.f(this.fallDistance - 3.0F)); - ((EntityPlayer) this).playerConnection.sendPacket(new PacketPlayOutWorldEvent(2006, i, j, k, MathHelper.f(this.fallDistance - 3.0F), false)); - } else { - this.world.triggerEffect(2006, i, j, k, MathHelper.f(this.fallDistance - 3.0F)); - } - // CraftBukkit end - } - - block.a(this.world, i, j, k, this, this.fallDistance); - } - - super.a(d0, flag); - } - - public boolean aE() { - return false; - } - - public void C() { - this.aC = this.aD; - super.C(); - this.world.methodProfiler.a("livingEntityBaseTick"); - if (this.isAlive() && this.inBlock()) { - this.damageEntity(DamageSource.STUCK, 1.0F); - } - - if (this.isFireproof() || this.world.isStatic) { - this.extinguish(); - } - - boolean flag = this instanceof EntityHuman && ((EntityHuman) this).abilities.isInvulnerable; - - if (this.isAlive() && this.a(Material.WATER)) { - if (!this.aE() && !this.hasEffect(MobEffectList.WATER_BREATHING.id) && !flag) { - this.setAirTicks(this.j(this.getAirTicks())); - if (this.getAirTicks() == -20) { - this.setAirTicks(0); - - for (int i = 0; i < 8; ++i) { - float f = this.random.nextFloat() - this.random.nextFloat(); - float f1 = this.random.nextFloat() - this.random.nextFloat(); - float f2 = this.random.nextFloat() - this.random.nextFloat(); - - this.world.addParticle("bubble", this.locX + (double) f, this.locY + (double) f1, this.locZ + (double) f2, this.motX, this.motY, this.motZ); - } - - this.damageEntity(DamageSource.DROWN, 2.0F); - } - } - - if (!this.world.isStatic && this.am() && this.vehicle instanceof EntityLiving) { - this.mount((Entity) null); - } - } else { - // CraftBukkit start - Only set if needed to work around a DataWatcher inefficiency - if (this.getAirTicks() != 300) { - this.setAirTicks(maxAirTicks); - } - // CraftBukkit end - } - - if (this.isAlive() && this.L()) { - this.extinguish(); - } - - this.aI = this.aJ; - if (this.attackTicks > 0) { - --this.attackTicks; - } - - if (this.hurtTicks > 0) { - --this.hurtTicks; - } - - if (this.noDamageTicks > 0 && !(this instanceof EntityPlayer)) { - --this.noDamageTicks; - } - - if (this.getHealth() <= 0.0F) { - this.aF(); - } - - if (this.lastDamageByPlayerTime > 0) { - --this.lastDamageByPlayerTime; - } else { - this.killer = null; - } - - if (this.bn != null && !this.bn.isAlive()) { - this.bn = null; - } - - if (this.lastDamager != null) { - if (!this.lastDamager.isAlive()) { - this.b((EntityLiving) null); - } else if (this.ticksLived - this.bm > 100) { - this.b((EntityLiving) null); - } - } - - this.aO(); - this.aY = this.aX; - this.aN = this.aM; - this.aP = this.aO; - this.lastYaw = this.yaw; - this.lastPitch = this.pitch; - this.world.methodProfiler.b(); - } - - // CraftBukkit start - public int getExpReward() { - int exp = this.getExpValue(this.killer); - - if (!this.world.isStatic && (this.lastDamageByPlayerTime > 0 || this.alwaysGivesExp()) && this.aG() && this.world.getGameRules().getBoolean("doMobLoot")) { - return exp; - } else { - return 0; - } - } - // CraftBukkit end - - public boolean isBaby() { - return false; - } - - protected void aF() { - ++this.deathTicks; - if (this.deathTicks >= 20 && !this.dead) { // CraftBukkit - (this.deathTicks == 20) -> (this.deathTicks >= 20 && !this.dead) - int i; - - // CraftBukkit start - Update getExpReward() above if the removed if() changes! - i = this.expToDrop; - while (i > 0) { - int j = EntityExperienceOrb.getOrbValue(i); - - i -= j; - this.world.addEntity(new EntityExperienceOrb(this.world, this.locX, this.locY, this.locZ, j)); - } - this.expToDrop = 0; - // CraftBukkit end - - this.die(); - - for (i = 0; i < 20; ++i) { - double d0 = this.random.nextGaussian() * 0.02D; - double d1 = this.random.nextGaussian() * 0.02D; - double d2 = this.random.nextGaussian() * 0.02D; - - this.world.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 boolean aG() { - return !this.isBaby(); - } - - protected int j(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 0; - } - - protected boolean alwaysGivesExp() { - return false; - } - - public Random aI() { - return this.random; - } - - public EntityLiving getLastDamager() { - return this.lastDamager; - } - - public int aK() { - return this.bm; - } - - public void b(EntityLiving entityliving) { - this.lastDamager = entityliving; - this.bm = this.ticksLived; - } - - public EntityLiving aL() { - return this.bn; - } - - public int aM() { - return this.bo; - } - - public void l(Entity entity) { - if (entity instanceof EntityLiving) { - this.bn = (EntityLiving) entity; - } else { - this.bn = null; - } - - this.bo = this.ticksLived; - } - - public int aN() { - return this.aU; - } - - public void b(NBTTagCompound nbttagcompound) { - nbttagcompound.setFloat("HealF", this.getHealth()); - nbttagcompound.setShort("Health", (short) ((int) Math.ceil((double) this.getHealth()))); - nbttagcompound.setShort("HurtTime", (short) this.hurtTicks); - nbttagcompound.setShort("DeathTime", (short) this.deathTicks); - nbttagcompound.setShort("AttackTime", (short) this.attackTicks); - nbttagcompound.setFloat("AbsorptionAmount", this.getAbsorptionHearts()); - ItemStack[] aitemstack = this.getEquipment(); - int i = aitemstack.length; - - int j; - ItemStack itemstack; - - for (j = 0; j < i; ++j) { - itemstack = aitemstack[j]; - if (itemstack != null) { - this.d.a(itemstack.D()); - } - } - - nbttagcompound.set("Attributes", GenericAttributes.a(this.getAttributeMap())); - aitemstack = this.getEquipment(); - i = aitemstack.length; - - for (j = 0; j < i; ++j) { - itemstack = aitemstack[j]; - if (itemstack != null) { - this.d.b(itemstack.D()); - } - } - - if (!this.effects.isEmpty()) { - NBTTagList nbttaglist = new NBTTagList(); - Iterator iterator = this.effects.values().iterator(); - - while (iterator.hasNext()) { - MobEffect mobeffect = (MobEffect) iterator.next(); - - nbttaglist.add(mobeffect.a(new NBTTagCompound())); - } - - nbttagcompound.set("ActiveEffects", nbttaglist); - } - } - - public void a(NBTTagCompound nbttagcompound) { - this.setAbsorptionHearts(nbttagcompound.getFloat("AbsorptionAmount")); - if (nbttagcompound.hasKeyOfType("Attributes", 9) && this.world != null && !this.world.isStatic) { - GenericAttributes.a(this.getAttributeMap(), nbttagcompound.getList("Attributes", 10)); - } - - if (nbttagcompound.hasKeyOfType("ActiveEffects", 9)) { - NBTTagList nbttaglist = nbttagcompound.getList("ActiveEffects", 10); - - for (int i = 0; i < nbttaglist.size(); ++i) { - NBTTagCompound nbttagcompound1 = nbttaglist.get(i); - MobEffect mobeffect = MobEffect.b(nbttagcompound1); - - if (mobeffect != null) { - this.effects.put(Integer.valueOf(mobeffect.getEffectId()), mobeffect); - } - } - } - - // CraftBukkit start - if (nbttagcompound.hasKey("Bukkit.MaxHealth")) { - NBTBase nbtbase = nbttagcompound.get("Bukkit.MaxHealth"); - if (nbtbase.getTypeId() == 5) { - this.getAttributeInstance(GenericAttributes.maxHealth).setValue((double) ((NBTTagFloat) nbtbase).c()); - } else if (nbtbase.getTypeId() == 3) { - this.getAttributeInstance(GenericAttributes.maxHealth).setValue((double) ((NBTTagInt) nbtbase).d()); - } - } - // CraftBukkit end - - if (nbttagcompound.hasKeyOfType("HealF", 99)) { - this.setHealth(nbttagcompound.getFloat("HealF")); - } else { - NBTBase nbtbase = nbttagcompound.get("Health"); - - if (nbtbase == null) { - this.setHealth(this.getMaxHealth()); - } else if (nbtbase.getTypeId() == 5) { - this.setHealth(((NBTTagFloat) nbtbase).h()); - } else if (nbtbase.getTypeId() == 2) { - this.setHealth((float) ((NBTTagShort) nbtbase).e()); - } - } - - this.hurtTicks = nbttagcompound.getShort("HurtTime"); - this.deathTicks = nbttagcompound.getShort("DeathTime"); - this.attackTicks = nbttagcompound.getShort("AttackTime"); - } - - protected void aO() { - Iterator iterator = this.effects.keySet().iterator(); - - while (iterator.hasNext()) { - Integer integer = (Integer) iterator.next(); - MobEffect mobeffect = (MobEffect) this.effects.get(integer); - - if (!mobeffect.tick(this)) { - if (!this.world.isStatic) { - iterator.remove(); - this.b(mobeffect); - } - } else if (mobeffect.getDuration() % 600 == 0) { - this.a(mobeffect, false); - } - } - - int i; - - if (this.updateEffects) { - if (!this.world.isStatic) { - if (this.effects.isEmpty()) { - this.datawatcher.watch(8, Byte.valueOf((byte) 0)); - this.datawatcher.watch(7, Integer.valueOf(0)); - this.setInvisible(false); - } else { - i = PotionBrewer.a(this.effects.values()); - this.datawatcher.watch(8, Byte.valueOf((byte) (PotionBrewer.b(this.effects.values()) ? 1 : 0))); - this.datawatcher.watch(7, Integer.valueOf(i)); - this.setInvisible(this.hasEffect(MobEffectList.INVISIBILITY.id)); - } - } - - this.updateEffects = false; - } - - i = this.datawatcher.getInt(7); - boolean flag = this.datawatcher.getByte(8) > 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.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 removeAllEffects() { - Iterator iterator = this.effects.keySet().iterator(); - - while (iterator.hasNext()) { - Integer integer = (Integer) iterator.next(); - MobEffect mobeffect = (MobEffect) this.effects.get(integer); - - if (!this.world.isStatic) { - iterator.remove(); - this.b(mobeffect); - } - } - } - - public Collection getEffects() { - return this.effects.values(); - } - - public boolean hasEffect(int i) { - // CraftBukkit - Add size check for efficiency - return this.effects.size() != 0 && this.effects.containsKey(Integer.valueOf(i)); - } - - public boolean hasEffect(MobEffectList mobeffectlist) { - // CraftBukkit - Add size check for efficiency - return this.effects.size() != 0 && this.effects.containsKey(Integer.valueOf(mobeffectlist.id)); - } - - public MobEffect getEffect(MobEffectList mobeffectlist) { - return (MobEffect) this.effects.get(Integer.valueOf(mobeffectlist.id)); - } - - public void addEffect(MobEffect mobeffect) { - if (this.d(mobeffect)) { - if (this.effects.containsKey(Integer.valueOf(mobeffect.getEffectId()))) { - ((MobEffect) this.effects.get(Integer.valueOf(mobeffect.getEffectId()))).a(mobeffect); - this.a((MobEffect) this.effects.get(Integer.valueOf(mobeffect.getEffectId())), true); - } else { - this.effects.put(Integer.valueOf(mobeffect.getEffectId()), mobeffect); - this.a(mobeffect); - } - } - } - - public boolean d(MobEffect mobeffect) { - if (this.getMonsterType() == EnumMonsterType.UNDEAD) { - int i = mobeffect.getEffectId(); - - if (i == MobEffectList.REGENERATION.id || i == MobEffectList.POISON.id) { - return false; - } - } - - return true; - } - - public boolean aR() { - return this.getMonsterType() == EnumMonsterType.UNDEAD; - } - - public void removeEffect(int i) { - MobEffect mobeffect = (MobEffect) this.effects.remove(Integer.valueOf(i)); - - if (mobeffect != null) { - this.b(mobeffect); - } - } - - protected void a(MobEffect mobeffect) { - this.updateEffects = true; - if (!this.world.isStatic) { - MobEffectList.byId[mobeffect.getEffectId()].b(this, this.getAttributeMap(), mobeffect.getAmplifier()); - } - } - - protected void a(MobEffect mobeffect, boolean flag) { - this.updateEffects = true; - if (flag && !this.world.isStatic) { - MobEffectList.byId[mobeffect.getEffectId()].a(this, this.getAttributeMap(), mobeffect.getAmplifier()); - MobEffectList.byId[mobeffect.getEffectId()].b(this, this.getAttributeMap(), mobeffect.getAmplifier()); - } - } - - protected void b(MobEffect mobeffect) { - this.updateEffects = true; - if (!this.world.isStatic) { - MobEffectList.byId[mobeffect.getEffectId()].a(this, this.getAttributeMap(), mobeffect.getAmplifier()); - } - } - - // CraftBukkit start - Delegate so we can handle providing a reason for health being regained - public void heal(float f) { - heal(f, EntityRegainHealthEvent.RegainReason.CUSTOM); - } - - public void heal(float f, EntityRegainHealthEvent.RegainReason regainReason) { - float f1 = this.getHealth(); - - if (f1 > 0.0F) { - EntityRegainHealthEvent event = new EntityRegainHealthEvent(this.getBukkitEntity(), f, regainReason); - this.world.getServer().getPluginManager().callEvent(event); - - if (!event.isCancelled()) { - this.setHealth((float) (this.getHealth() + event.getAmount())); - } - } - } - - public final float getHealth() { - // CraftBukkit start - Use unscaled health - if (this instanceof EntityPlayer) { - return (float) ((EntityPlayer) this).getBukkitEntity().getHealth(); - } - // CraftBukkit end - return this.datawatcher.getFloat(6); - } - - public void setHealth(float f) { - // CraftBukkit start - Handle scaled health - if (this instanceof EntityPlayer) { - org.bukkit.craftbukkit.entity.CraftPlayer player = ((EntityPlayer) this).getBukkitEntity(); - // Squeeze - if (f < 0.0F) { - player.setRealHealth(0.0D); - } else if (f > player.getMaxHealth()) { - player.setRealHealth(player.getMaxHealth()); - } else { - player.setRealHealth(f); - } - - this.datawatcher.watch(6, Float.valueOf(player.getScaledHealth())); - return; - } - // CraftBukkit end - this.datawatcher.watch(6, Float.valueOf(MathHelper.a(f, 0.0F, this.getMaxHealth()))); - } - - public boolean damageEntity(DamageSource damagesource, float f) { - if (this.isInvulnerable()) { - return false; - } else if (this.world.isStatic) { - return false; - } else { - this.aU = 0; - if (this.getHealth() <= 0.0F) { - return false; - } else if (damagesource.o() && this.hasEffect(MobEffectList.FIRE_RESISTANCE)) { - return false; - } else { - // CraftBukkit - Moved into d(DamageSource, float) - if (false && (damagesource == DamageSource.ANVIL || damagesource == DamageSource.FALLING_BLOCK) && this.getEquipment(4) != null) { - this.getEquipment(4).damage((int) (f * 4.0F + this.random.nextFloat() * f * 2.0F), this); - f *= 0.75F; - } - - this.aF = 1.5F; - boolean flag = true; - - if ((float) this.noDamageTicks > (float) this.maxNoDamageTicks / 2.0F) { - if (f <= this.lastDamage) { - return false; - } - - // CraftBukkit start - if (!this.d(damagesource, f - this.lastDamage)) { - return false; - } - // CraftBukkit end - this.lastDamage = f; - flag = false; - } else { - // CraftBukkit start - float previousHealth = this.getHealth(); - if (!this.d(damagesource, f)) { - return false; - } - this.lastDamage = f; - this.aw = previousHealth; - this.noDamageTicks = this.maxNoDamageTicks; - // CraftBukkit end - this.hurtTicks = this.ay = 10; - } - - this.az = 0.0F; - Entity entity = damagesource.getEntity(); - - if (entity != null) { - if (entity instanceof EntityLiving) { - this.b((EntityLiving) entity); - } - - if (entity instanceof EntityHuman) { - this.lastDamageByPlayerTime = 100; - this.killer = (EntityHuman) entity; - } else if (entity instanceof EntityWolf) { - EntityWolf entitywolf = (EntityWolf) entity; - - if (entitywolf.isTamed()) { - this.lastDamageByPlayerTime = 100; - this.killer = null; - } - } - } - - if (flag) { - this.world.broadcastEntityEffect(this, (byte) 2); - if (damagesource != DamageSource.DROWN) { - this.Q(); - } - - if (entity != null) { - double d0 = entity.locX - this.locX; - - double d1; - - for (d1 = entity.locZ - this.locZ; d0 * d0 + d1 * d1 < 1.0E-4D; d1 = (Math.random() - Math.random()) * 0.01D) { - d0 = (Math.random() - Math.random()) * 0.01D; - } - - this.az = (float) (Math.atan2(d1, d0) * 180.0D / 3.1415927410125732D) - this.yaw; - this.a(entity, f, d0, d1); - } else { - this.az = (float) ((int) (Math.random() * 2.0D) * 180); - } - } - - String s; - - if (this.getHealth() <= 0.0F) { - s = this.aU(); - if (flag && s != null) { - this.makeSound(s, this.bf(), this.bg()); - } - - this.die(damagesource); - } else { - s = this.aT(); - if (flag && s != null) { - this.makeSound(s, this.bf(), this.bg()); - } - } - - return true; - } - } - } - - public void a(ItemStack itemstack) { - this.makeSound("random.break", 0.8F, 0.8F + this.world.random.nextFloat() * 0.4F); - - for (int i = 0; i < 5; ++i) { - Vec3D vec3d = Vec3D.a(((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(((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.addParticle("iconcrack_" + Item.getId(itemstack.getItem()), vec3d1.a, vec3d1.b, vec3d1.c, vec3d.a, vec3d.b + 0.05D, vec3d.c); - } - } - - public void die(DamageSource damagesource) { - Entity entity = damagesource.getEntity(); - EntityLiving entityliving = this.aX(); - - if (this.ba >= 0 && entityliving != null) { - entityliving.b(this, this.ba); - } - - if (entity != null) { - entity.a(this); - } - - this.aT = true; - this.aW().g(); - if (!this.world.isStatic) { - int i = 0; - - if (entity instanceof EntityHuman) { - i = EnchantmentManager.getBonusMonsterLootEnchantmentLevel((EntityLiving) entity); - } - - if (this.aG() && this.world.getGameRules().getBoolean("doMobLoot")) { - this.drops = new ArrayList<org.bukkit.inventory.ItemStack>(); // CraftBukkit - Setup drop capture - - this.dropDeathLoot(this.lastDamageByPlayerTime > 0, i); - this.dropEquipment(this.lastDamageByPlayerTime > 0, i); - if (this.lastDamageByPlayerTime > 0) { - int j = this.random.nextInt(200) - i; - - if (j < 5) { - this.getRareDrop(j <= 0 ? 1 : 0); - } - } - - // CraftBukkit start - Call death event - CraftEventFactory.callEntityDeathEvent(this, this.drops); - this.drops = null; - } else { - CraftEventFactory.callEntityDeathEvent(this); - // CraftBukkit end - } - } - - this.world.broadcastEntityEffect(this, (byte) 3); - } - - protected void dropEquipment(boolean flag, int i) {} - - public void a(Entity entity, float f, double d0, double d1) { - if (this.random.nextDouble() >= this.getAttributeInstance(GenericAttributes.c).getValue()) { - this.al = true; - float f1 = MathHelper.sqrt(d0 * d0 + d1 * d1); - float f2 = 0.4F; - - this.motX /= 2.0D; - this.motY /= 2.0D; - this.motZ /= 2.0D; - this.motX -= d0 / (double) f1 * (double) f2; - this.motY += (double) f2; - this.motZ -= d1 / (double) f1 * (double) f2; - if (this.motY > 0.4000000059604645D) { - this.motY = 0.4000000059604645D; - } - } - } - - protected String aT() { - return "game.neutral.hurt"; - } - - protected String aU() { - return "game.neutral.die"; - } - - protected void getRareDrop(int i) {} - - protected void dropDeathLoot(boolean flag, int i) {} - - public boolean h_() { - int i = MathHelper.floor(this.locX); - int j = MathHelper.floor(this.boundingBox.b); - int k = MathHelper.floor(this.locZ); - Block block = this.world.getType(i, j, k); - - return block == Blocks.LADDER || block == Blocks.VINE; - } - - public boolean isAlive() { - return !this.dead && this.getHealth() > 0.0F; - } - - protected void b(float f) { - super.b(f); - MobEffect mobeffect = this.getEffect(MobEffectList.JUMP); - float f1 = mobeffect != null ? (float) (mobeffect.getAmplifier() + 1) : 0.0F; - int i = MathHelper.f(f - 3.0F - f1); - - if (i > 0) { - // CraftBukkit start - if (!this.damageEntity(DamageSource.FALL, (float) i)) { - return; - } - // CraftBukkit end - this.makeSound(this.o(i), 1.0F, 1.0F); - // this.damageEntity(DamageSource.FALL, (float) i); // CraftBukkit - moved up - int j = MathHelper.floor(this.locX); - int k = MathHelper.floor(this.locY - 0.20000000298023224D - (double) this.height); - int l = MathHelper.floor(this.locZ); - Block block = this.world.getType(j, k, l); - - if (block.getMaterial() != Material.AIR) { - StepSound stepsound = block.stepSound; - - this.makeSound(stepsound.getStepSound(), stepsound.getVolume1() * 0.5F, stepsound.getVolume2() * 0.75F); - } - } - } - - protected String o(int i) { - return i > 4 ? "game.neutral.hurt.fall.big" : "game.neutral.hurt.fall.small"; - } - - public int aV() { - 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()).c; - - i += l; - } - } - - return i; - } - - protected void damageArmor(float f) {} - - protected float applyArmorModifier(DamageSource damagesource, float f) { - if (!damagesource.ignoresArmor()) { - int i = 25 - this.aV(); - float f1 = f * (float) i; - - // this.damageArmor(f); // CraftBukkit - Moved into d(DamageSource, float) - f = f1 / 25.0F; - } - - return f; - } - - protected float applyMagicModifier(DamageSource damagesource, float f) { - if (damagesource.isStarvation()) { - return f; - } else { - if (this instanceof EntityZombie) { - f = f; - } - - int i; - int j; - float f1; - - // CraftBukkit - Moved to d(DamageSource, float) - if (false && this.hasEffect(MobEffectList.RESISTANCE) && damagesource != DamageSource.OUT_OF_WORLD) { - i = (this.getEffect(MobEffectList.RESISTANCE).getAmplifier() + 1) * 5; - j = 25 - i; - f1 = f * (float) j; - f = f1 / 25.0F; - } - - if (f <= 0.0F) { - return 0.0F; - } else { - i = EnchantmentManager.a(this.getEquipment(), damagesource); - if (i > 20) { - i = 20; - } - - if (i > 0 && i <= 20) { - j = 25 - i; - f1 = f * (float) j; - f = f1 / 25.0F; - } - - return f; - } - } - } - - // CraftBukkit start - protected boolean d(final DamageSource damagesource, float f) { // void -> boolean, add final - if (!this.isInvulnerable()) { - final boolean human = this instanceof EntityHuman; - float originalDamage = f; - Function<Double, Double> hardHat = new Function<Double, Double>() { - @Override - public Double apply(Double f) { - if ((damagesource == DamageSource.ANVIL || damagesource == DamageSource.FALLING_BLOCK) && EntityLiving.this.getEquipment(4) != null) { - return -(f - (f * 0.75F)); - } - return -0.0; - } - }; - float hardHatModifier = hardHat.apply((double) f).floatValue(); - f += hardHatModifier; - - Function<Double, Double> blocking = new Function<Double, Double>() { - @Override - public Double apply(Double f) { - if (human) { - if (!damagesource.ignoresArmor() && ((EntityHuman) EntityLiving.this).isBlocking() && f > 0.0F) { - return -(f - ((1.0F + f) * 0.5F)); - } - } - return -0.0; - } - }; - float blockingModifier = blocking.apply((double) f).floatValue(); - f += blockingModifier; - - Function<Double, Double> armor = new Function<Double, Double>() { - @Override - public Double apply(Double f) { - return -(f - EntityLiving.this.applyArmorModifier(damagesource, f.floatValue())); - } - }; - float armorModifier = armor.apply((double) f).floatValue(); - f += armorModifier; - - Function<Double, Double> resistance = new Function<Double, Double>() { - @Override - public Double apply(Double f) { - if (!damagesource.isStarvation() && EntityLiving.this.hasEffect(MobEffectList.RESISTANCE) && damagesource != DamageSource.OUT_OF_WORLD) { - int i = (EntityLiving.this.getEffect(MobEffectList.RESISTANCE).getAmplifier() + 1) * 5; - int j = 25 - i; - float f1 = f.floatValue() * (float) j; - return -(f - (f1 / 25.0F)); - } - return -0.0; - } - }; - float resistanceModifier = resistance.apply((double) f).floatValue(); - f += resistanceModifier; - - Function<Double, Double> magic = new Function<Double, Double>() { - @Override - public Double apply(Double f) { - return -(f - EntityLiving.this.applyMagicModifier(damagesource, f.floatValue())); - } - }; - float magicModifier = magic.apply((double) f).floatValue(); - f += magicModifier; - - Function<Double, Double> absorption = new Function<Double, Double>() { - @Override - public Double apply(Double f) { - return -(Math.max(f - Math.max(f - EntityLiving.this.getAbsorptionHearts(), 0.0F), 0.0F)); - } - }; - float absorptionModifier = absorption.apply((double) f).floatValue(); - - EntityDamageEvent event = CraftEventFactory.handleLivingEntityDamageEvent(this, damagesource, originalDamage, hardHatModifier, blockingModifier, armorModifier, resistanceModifier, magicModifier, absorptionModifier, hardHat, blocking, armor, resistance, magic, absorption); - if (event.isCancelled()) { - return false; - } - - f = (float) event.getFinalDamage(); - - // Apply damage to helmet - if ((damagesource == DamageSource.ANVIL || damagesource == DamageSource.FALLING_BLOCK) && this.getEquipment(4) != null) { - this.getEquipment(4).damage((int) (event.getDamage() * 4.0F + this.random.nextFloat() * event.getDamage() * 2.0F), this); - } - - // Apply damage to armor - if (!damagesource.ignoresArmor()) { - float armorDamage = (float) (event.getDamage() + event.getDamage(DamageModifier.BLOCKING) + event.getDamage(DamageModifier.HARD_HAT)); - this.damageArmor(armorDamage); - } - - absorptionModifier = (float) -event.getDamage(DamageModifier.ABSORPTION); - this.setAbsorptionHearts(Math.max(this.getAbsorptionHearts() - absorptionModifier, 0.0F)); - if (f != 0.0F) { - if (human) { - ((EntityHuman) this).applyExhaustion(damagesource.getExhaustionCost()); - } - // CraftBukkit end - float f2 = this.getHealth(); - - this.setHealth(f2 - f); - this.aW().a(damagesource, f2, f); - // CraftBukkit start - if (human) { - return true; - } - // CraftBukkit end - this.setAbsorptionHearts(this.getAbsorptionHearts() - f); - } - return true; // CraftBukkit - } - return false; // CraftBukkit - } - - public CombatTracker aW() { - return this.combatTracker; - } - - public EntityLiving aX() { - return (EntityLiving) (this.combatTracker.c() != null ? this.combatTracker.c() : (this.killer != null ? this.killer : (this.lastDamager != null ? this.lastDamager : null))); - } - - public final float getMaxHealth() { - return (float) this.getAttributeInstance(GenericAttributes.maxHealth).getValue(); - } - - public final int aZ() { - return this.datawatcher.getByte(9); - } - - public final void p(int i) { - this.datawatcher.watch(9, Byte.valueOf((byte) i)); - } - - private int j() { - 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 ba() { - if (!this.at || this.au >= this.j() / 2 || this.au < 0) { - this.au = -1; - this.at = true; - if (this.world instanceof WorldServer) { - ((WorldServer) this.world).getTracker().a((Entity) this, (Packet) (new PacketPlayOutAnimation(this, 0))); - } - } - } - - protected void G() { - this.damageEntity(DamageSource.OUT_OF_WORLD, 4.0F); - } - - protected void bb() { - int i = this.j(); - - if (this.at) { - ++this.au; - if (this.au >= i) { - this.au = 0; - this.at = false; - } - } else { - this.au = 0; - } - - this.aD = (float) this.au / (float) i; - } - - public AttributeInstance getAttributeInstance(IAttribute iattribute) { - return this.getAttributeMap().a(iattribute); - } - - public AttributeMapBase getAttributeMap() { - if (this.d == null) { - this.d = new AttributeMapServer(); - } - - return this.d; - } - - public EnumMonsterType getMonsterType() { - return EnumMonsterType.UNDEFINED; - } - - public abstract ItemStack be(); - - public abstract ItemStack getEquipment(int i); - - public abstract void setEquipment(int i, ItemStack itemstack); - - public void setSprinting(boolean flag) { - super.setSprinting(flag); - AttributeInstance attributeinstance = this.getAttributeInstance(GenericAttributes.d); - - if (attributeinstance.a(b) != null) { - attributeinstance.b(c); - } - - if (flag) { - attributeinstance.a(c); - } - } - - public abstract ItemStack[] getEquipment(); - - protected float bf() { - return 1.0F; - } - - protected float bg() { - return this.isBaby() ? (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.5F : (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F; - } - - protected boolean bh() { - return this.getHealth() <= 0.0F; - } - - public void enderTeleportTo(double d0, double d1, double d2) { - this.setPositionRotation(d0, d1, d2, this.yaw, this.pitch); - } - - public void m(Entity entity) { - double d0 = entity.locX; - double d1 = entity.boundingBox.b + (double) entity.length; - double d2 = entity.locZ; - byte b0 = 1; - - for (int i = -b0; i <= b0; ++i) { - for (int j = -b0; j < b0; ++j) { - if (i != 0 || j != 0) { - int k = (int) (this.locX + (double) i); - int l = (int) (this.locZ + (double) j); - AxisAlignedBB axisalignedbb = this.boundingBox.c((double) i, 1.0D, (double) j); - - if (this.world.a(axisalignedbb).isEmpty()) { - if (World.a((IBlockAccess) this.world, k, (int) this.locY, l)) { - this.enderTeleportTo(this.locX + (double) i, this.locY + 1.0D, this.locZ + (double) j); - return; - } - - if (World.a((IBlockAccess) this.world, k, (int) this.locY - 1, l) || this.world.getType(k, (int) this.locY - 1, l).getMaterial() == Material.WATER) { - d0 = this.locX + (double) i; - d1 = this.locY + 1.0D; - d2 = this.locZ + (double) j; - } - } - } - } - } - - this.enderTeleportTo(d0, d1, d2); - } - - protected void bj() { - this.motY = 0.41999998688697815D; - if (this.hasEffect(MobEffectList.JUMP)) { - this.motY += (double) ((float) (this.getEffect(MobEffectList.JUMP).getAmplifier() + 1) * 0.1F); - } - - if (this.isSprinting()) { - float f = this.yaw * 0.017453292F; - - this.motX -= (double) (MathHelper.sin(f) * 0.2F); - this.motZ += (double) (MathHelper.cos(f) * 0.2F); - } - - this.al = true; - } - - public void e(float f, float f1) { - double d0; - - if (this.M() && (!(this instanceof EntityHuman) || !((EntityHuman) this).abilities.isFlying)) { - d0 = this.locY; - this.a(f, f1, this.bk() ? 0.04F : 0.02F); - this.move(this.motX, this.motY, this.motZ); - this.motX *= 0.800000011920929D; - this.motY *= 0.800000011920929D; - this.motZ *= 0.800000011920929D; - this.motY -= 0.02D; - if (this.positionChanged && this.c(this.motX, this.motY + 0.6000000238418579D - this.locY + d0, this.motZ)) { - this.motY = 0.30000001192092896D; - } - } else if (this.P() && (!(this instanceof EntityHuman) || !((EntityHuman) this).abilities.isFlying)) { - d0 = this.locY; - this.a(f, f1, 0.02F); - this.move(this.motX, this.motY, this.motZ); - this.motX *= 0.5D; - this.motY *= 0.5D; - this.motZ *= 0.5D; - this.motY -= 0.02D; - if (this.positionChanged && this.c(this.motX, this.motY + 0.6000000238418579D - this.locY + d0, this.motZ)) { - this.motY = 0.30000001192092896D; - } - } else { - float f2 = 0.91F; - - if (this.onGround) { - f2 = this.world.getType(MathHelper.floor(this.locX), MathHelper.floor(this.boundingBox.b) - 1, MathHelper.floor(this.locZ)).frictionFactor * 0.91F; - } - - float f3 = 0.16277136F / (f2 * f2 * f2); - float f4; - - if (this.onGround) { - f4 = this.bl() * f3; - } else { - f4 = this.aQ; - } - - this.a(f, f1, f4); - f2 = 0.91F; - if (this.onGround) { - f2 = this.world.getType(MathHelper.floor(this.locX), MathHelper.floor(this.boundingBox.b) - 1, MathHelper.floor(this.locZ)).frictionFactor * 0.91F; - } - - if (this.h_()) { - float f5 = 0.15F; - - if (this.motX < (double) (-f5)) { - this.motX = (double) (-f5); - } - - if (this.motX > (double) f5) { - this.motX = (double) f5; - } - - if (this.motZ < (double) (-f5)) { - this.motZ = (double) (-f5); - } - - if (this.motZ > (double) f5) { - this.motZ = (double) f5; - } - - this.fallDistance = 0.0F; - if (this.motY < -0.15D) { - this.motY = -0.15D; - } - - boolean flag = this.isSneaking() && this instanceof EntityHuman; - - if (flag && this.motY < 0.0D) { - this.motY = 0.0D; - } - } - - this.move(this.motX, this.motY, this.motZ); - if (this.positionChanged && this.h_()) { - this.motY = 0.2D; - } - - if (this.world.isStatic && (!this.world.isLoaded((int) this.locX, 0, (int) this.locZ) || !this.world.getChunkAtWorldCoords((int) this.locX, (int) this.locZ).d)) { - if (this.locY > 0.0D) { - this.motY = -0.1D; - } else { - this.motY = 0.0D; - } - } else { - this.motY -= 0.08D; - } - - this.motY *= 0.9800000190734863D; - this.motX *= (double) f2; - this.motZ *= (double) f2; - } - - this.aE = this.aF; - d0 = this.locX - this.lastX; - double d1 = this.locZ - this.lastZ; - float f6 = MathHelper.sqrt(d0 * d0 + d1 * d1) * 4.0F; - - if (f6 > 1.0F) { - f6 = 1.0F; - } - - this.aF += (f6 - this.aF) * 0.4F; - this.aG += this.aF; - } - - protected boolean bk() { - return false; - } - - public float bl() { - return this.bk() ? this.bp : 0.1F; - } - - public void i(float f) { - this.bp = f; - } - - public boolean n(Entity entity) { - this.l(entity); - return false; - } - - public boolean isSleeping() { - return false; - } - - public void h() { - super.h(); - if (!this.world.isStatic) { - int i = this.aZ(); - - if (i > 0) { - if (this.av <= 0) { - this.av = 20 * (30 - i); - } - - --this.av; - if (this.av <= 0) { - this.p(i - 1); - } - } - - for (int j = 0; j < 5; ++j) { - ItemStack itemstack = this.g[j]; - ItemStack itemstack1 = this.getEquipment(j); - - if (!ItemStack.matches(itemstack1, itemstack)) { - ((WorldServer) this.world).getTracker().a((Entity) this, (Packet) (new PacketPlayOutEntityEquipment(this.getId(), j, itemstack1))); - if (itemstack != null) { - this.d.a(itemstack.D()); - } - - if (itemstack1 != null) { - this.d.b(itemstack1.D()); - } - - this.g[j] = itemstack1 == null ? null : itemstack1.cloneItemStack(); - } - } - - if (this.ticksLived % 20 == 0) { - this.aW().g(); - } - } - - this.e(); - double d0 = this.locX - this.lastX; - double d1 = this.locZ - this.lastZ; - float f = (float) (d0 * d0 + d1 * d1); - float f1 = this.aM; - float f2 = 0.0F; - - this.aV = this.aW; - float f3 = 0.0F; - - if (f > 0.0025000002F) { - f3 = 1.0F; - f2 = (float) Math.sqrt((double) f) * 3.0F; - // CraftBukkit - Math -> TrigMath - f1 = (float) org.bukkit.craftbukkit.TrigMath.atan2(d1, d0) * 180.0F / 3.1415927F - 90.0F; - } - - if (this.aD > 0.0F) { - f1 = this.yaw; - } - - if (!this.onGround) { - f3 = 0.0F; - } - - this.aW += (f3 - this.aW) * 0.3F; - this.world.methodProfiler.a("headTurn"); - f2 = this.f(f1, f2); - this.world.methodProfiler.b(); - this.world.methodProfiler.a("rangeChecks"); - - while (this.yaw - this.lastYaw < -180.0F) { - this.lastYaw -= 360.0F; - } - - while (this.yaw - this.lastYaw >= 180.0F) { - this.lastYaw += 360.0F; - } - - while (this.aM - this.aN < -180.0F) { - this.aN -= 360.0F; - } - - while (this.aM - this.aN >= 180.0F) { - this.aN += 360.0F; - } - - while (this.pitch - this.lastPitch < -180.0F) { - this.lastPitch -= 360.0F; - } - - while (this.pitch - this.lastPitch >= 180.0F) { - this.lastPitch += 360.0F; - } - - while (this.aO - this.aP < -180.0F) { - this.aP -= 360.0F; - } - - while (this.aO - this.aP >= 180.0F) { - this.aP += 360.0F; - } - - this.world.methodProfiler.b(); - this.aX += f2; - } - - protected float f(float f, float f1) { - float f2 = MathHelper.g(f - this.aM); - - this.aM += f2 * 0.3F; - float f3 = MathHelper.g(this.yaw - this.aM); - boolean flag = f3 < -90.0F || f3 >= 90.0F; - - if (f3 < -75.0F) { - f3 = -75.0F; - } - - if (f3 >= 75.0F) { - f3 = 75.0F; - } - - this.aM = this.yaw - f3; - if (f3 * f3 > 2500.0F) { - this.aM += f3 * 0.2F; - } - - if (flag) { - f1 *= -1.0F; - } - - return f1; - } - - public void e() { - if (this.bq > 0) { - --this.bq; - } - - if (this.bg > 0) { - double d0 = this.locX + (this.bh - this.locX) / (double) this.bg; - double d1 = this.locY + (this.bi - this.locY) / (double) this.bg; - double d2 = this.locZ + (this.bj - this.locZ) / (double) this.bg; - double d3 = MathHelper.g(this.bk - (double) this.yaw); - - this.yaw = (float) ((double) this.yaw + d3 / (double) this.bg); - this.pitch = (float) ((double) this.pitch + (this.bl - (double) this.pitch) / (double) this.bg); - --this.bg; - this.setPosition(d0, d1, d2); - this.b(this.yaw, this.pitch); - } else if (!this.br()) { - this.motX *= 0.98D; - this.motY *= 0.98D; - this.motZ *= 0.98D; - } - - if (Math.abs(this.motX) < 0.005D) { - this.motX = 0.0D; - } - - if (Math.abs(this.motY) < 0.005D) { - this.motY = 0.0D; - } - - if (Math.abs(this.motZ) < 0.005D) { - this.motZ = 0.0D; - } - - this.world.methodProfiler.a("ai"); - if (this.bh()) { - this.bc = false; - this.bd = 0.0F; - this.be = 0.0F; - this.bf = 0.0F; - } else if (this.br()) { - if (this.bk()) { - this.world.methodProfiler.a("newAi"); - this.bn(); - this.world.methodProfiler.b(); - } else { - this.world.methodProfiler.a("oldAi"); - this.bq(); - this.world.methodProfiler.b(); - this.aO = this.yaw; - } - } - - this.world.methodProfiler.b(); - this.world.methodProfiler.a("jump"); - if (this.bc) { - if (!this.M() && !this.P()) { - if (this.onGround && this.bq == 0) { - this.bj(); - this.bq = 10; - } - } else { - this.motY += 0.03999999910593033D; - } - } else { - this.bq = 0; - } - - this.world.methodProfiler.b(); - this.world.methodProfiler.a("travel"); - this.bd *= 0.98F; - this.be *= 0.98F; - this.bf *= 0.9F; - this.e(this.bd, this.be); - this.world.methodProfiler.b(); - this.world.methodProfiler.a("push"); - if (!this.world.isStatic) { - this.bo(); - } - - this.world.methodProfiler.b(); - } - - protected void bn() {} - - protected void bo() { - List list = this.world.getEntities(this, this.boundingBox.grow(0.20000000298023224D, 0.0D, 0.20000000298023224D)); - - if (list != null && !list.isEmpty()) { - for (int i = 0; i < list.size(); ++i) { - Entity entity = (Entity) list.get(i); - - // TODO better check now? - // CraftBukkit start - Only handle mob (non-player) collisions every other tick - if (entity instanceof EntityLiving && !(this instanceof EntityPlayer) && this.ticksLived % 2 == 0) { - continue; - } - // CraftBukkit end - - if (entity.S()) { - this.o(entity); - } - } - } - } - - protected void o(Entity entity) { - entity.collide(this); - } - - public void ab() { - super.ab(); - this.aV = this.aW; - this.aW = 0.0F; - this.fallDistance = 0.0F; - } - - protected void bp() {} - - protected void bq() { - ++this.aU; - } - - public void f(boolean flag) { - this.bc = flag; - } - - 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, (Packet) (new PacketPlayOutCollect(entity.getId(), this.getId()))); - } - - if (entity instanceof EntityArrow) { - entitytracker.a(entity, (Packet) (new PacketPlayOutCollect(entity.getId(), this.getId()))); - } - - if (entity instanceof EntityExperienceOrb) { - entitytracker.a(entity, (Packet) (new PacketPlayOutCollect(entity.getId(), this.getId()))); - } - } - } - - public boolean hasLineOfSight(Entity entity) { - return this.world.a(Vec3D.a(this.locX, this.locY + (double) this.getHeadHeight(), this.locZ), Vec3D.a(entity.locX, entity.locY + (double) entity.getHeadHeight(), entity.locZ)) == null; - } - - public Vec3D ag() { - return this.j(1.0F); - } - - public Vec3D j(float f) { - float f1; - float f2; - float f3; - float f4; - - if (f == 1.0F) { - f1 = MathHelper.cos(-this.yaw * 0.017453292F - 3.1415927F); - 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((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; - f3 = MathHelper.cos(-f2 * 0.017453292F - 3.1415927F); - f4 = MathHelper.sin(-f2 * 0.017453292F - 3.1415927F); - float f5 = -MathHelper.cos(-f1 * 0.017453292F); - float f6 = MathHelper.sin(-f1 * 0.017453292F); - - return Vec3D.a((double) (f4 * f5), (double) f6, (double) (f3 * f5)); - } - } - - public boolean br() { - return !this.world.isStatic; - } - - public boolean R() { - return !this.dead; - } - - public boolean S() { - return !this.dead; - } - - public float getHeadHeight() { - return this.length * 0.85F; - } - - protected void Q() { - this.velocityChanged = this.random.nextDouble() >= this.getAttributeInstance(GenericAttributes.c).getValue(); - } - - public float getHeadRotation() { - return this.aO; - } - - public float getAbsorptionHearts() { - return this.br; - } - - public void setAbsorptionHearts(float f) { - if (f < 0.0F) { - f = 0.0F; - } - - this.br = f; - } - - public ScoreboardTeamBase getScoreboardTeam() { - return null; - } - - public boolean c(EntityLiving entityliving) { - return this.a(entityliving.getScoreboardTeam()); - } - - public boolean a(ScoreboardTeamBase scoreboardteambase) { - return this.getScoreboardTeam() != null ? this.getScoreboardTeam().isAlly(scoreboardteambase) : false; - } - - public void bu() {} - - public void bv() {} -} diff --git a/src/main/java/net/minecraft/server/EntityMinecartAbstract.java b/src/main/java/net/minecraft/server/EntityMinecartAbstract.java deleted file mode 100644 index f1ccd3a9..00000000 --- a/src/main/java/net/minecraft/server/EntityMinecartAbstract.java +++ /dev/null @@ -1,882 +0,0 @@ -package net.minecraft.server; - -import java.util.List; - -// CraftBukkit start -import org.bukkit.Location; -import org.bukkit.entity.Vehicle; -import org.bukkit.event.vehicle.VehicleDamageEvent; -import org.bukkit.event.vehicle.VehicleDestroyEvent; -import org.bukkit.event.vehicle.VehicleEntityCollisionEvent; -import org.bukkit.util.Vector; -// CraftBukkit end - -public abstract class EntityMinecartAbstract extends Entity { - - private boolean a; - private String b; - 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 d; - private double e; - private double f; - private double g; - private double h; - private double i; - - // CraftBukkit start - public boolean slowWhenEmpty = true; - private double derailedX = 0.5; - private double derailedY = 0.5; - private double derailedZ = 0.5; - private double flyingX = 0.95; - private double flyingY = 0.95; - private double flyingZ = 0.95; - public double maxSpeed = 0.4D; - // CraftBukkit end - - public EntityMinecartAbstract(World world) { - super(world); - this.k = true; - this.a(0.98F, 0.7F); - this.height = this.length / 2.0F; - } - - public static EntityMinecartAbstract a(World world, double d0, double d1, double d2, int i) { - switch (i) { - case 1: - return new EntityMinecartChest(world, d0, d1, d2); - - case 2: - return new EntityMinecartFurnace(world, d0, d1, d2); - - case 3: - return new EntityMinecartTNT(world, d0, d1, d2); - - case 4: - return new EntityMinecartMobSpawner(world, d0, d1, d2); - - case 5: - return new EntityMinecartHopper(world, d0, d1, d2); - - case 6: - return new EntityMinecartCommandBlock(world, d0, d1, d2); - - default: - return new EntityMinecartRideable(world, d0, d1, d2); - } - } - - protected boolean g_() { - return false; - } - - protected void c() { - this.datawatcher.a(17, new Integer(0)); - this.datawatcher.a(18, new Integer(1)); - this.datawatcher.a(19, new Float(0.0F)); - this.datawatcher.a(20, new Integer(0)); - this.datawatcher.a(21, new Integer(6)); - this.datawatcher.a(22, Byte.valueOf((byte) 0)); - } - - public AxisAlignedBB h(Entity entity) { - return entity.S() ? entity.boundingBox : null; - } - - public AxisAlignedBB J() { - return null; - } - - public boolean S() { - return true; - } - - public EntityMinecartAbstract(World world, double d0, double d1, double d2) { - this(world); - this.setPosition(d0, d1, d2); - this.motX = 0.0D; - this.motY = 0.0D; - this.motZ = 0.0D; - this.lastX = d0; - this.lastY = d1; - this.lastZ = d2; - - this.world.getServer().getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleCreateEvent((Vehicle) this.getBukkitEntity())); // CraftBukkit - } - - public double ae() { - return (double) this.length * 0.0D - 0.30000001192092896D; - } - - public boolean damageEntity(DamageSource damagesource, float f) { - if (!this.world.isStatic && !this.dead) { - if (this.isInvulnerable()) { - return false; - } else { - // CraftBukkit start - fire VehicleDamageEvent - Vehicle vehicle = (Vehicle) this.getBukkitEntity(); - org.bukkit.entity.Entity passenger = (damagesource.getEntity() == null) ? null : damagesource.getEntity().getBukkitEntity(); - - VehicleDamageEvent event = new VehicleDamageEvent(vehicle, passenger, f); - this.world.getServer().getPluginManager().callEvent(event); - - if (event.isCancelled()) { - return true; - } - - f = (float) event.getDamage(); - // CraftBukkit end - - this.j(-this.l()); - this.c(10); - this.Q(); - this.setDamage(this.getDamage() + f * 10.0F); - boolean flag = damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).abilities.canInstantlyBuild; - - if (flag || this.getDamage() > 40.0F) { - if (this.passenger != null) { - this.passenger.mount(this); - } - - // CraftBukkit start - VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, passenger); - this.world.getServer().getPluginManager().callEvent(destroyEvent); - - if (destroyEvent.isCancelled()) { - this.setDamage(40); // Maximize damage so this doesn't get triggered again right away - return true; - } - // CraftBukkit end - - if (flag && !this.k_()) { - this.die(); - } else { - this.a(damagesource); - } - } - - return true; - } - } else { - return true; - } - } - - public void a(DamageSource damagesource) { - this.die(); - ItemStack itemstack = new ItemStack(Items.MINECART, 1); - - if (this.b != null) { - itemstack.c(this.b); - } - - this.a(itemstack, 0.0F); - } - - public boolean R() { - return !this.dead; - } - - public void die() { - super.die(); - } - - public void h() { - // CraftBukkit start - double prevX = this.locX; - double prevY = this.locY; - double prevZ = this.locZ; - float prevYaw = this.yaw; - float prevPitch = this.pitch; - // CraftBukkit end - - if (this.getType() > 0) { - this.c(this.getType() - 1); - } - - if (this.getDamage() > 0.0F) { - this.setDamage(this.getDamage() - 1.0F); - } - - if (this.locY < -64.0D) { - this.G(); - } - - int i; - - if (!this.world.isStatic && this.world instanceof WorldServer) { - this.world.methodProfiler.a("portal"); - MinecraftServer minecraftserver = ((WorldServer) this.world).getMinecraftServer(); - - i = this.D(); - if (this.an) { - if (true || minecraftserver.getAllowNether()) { // CraftBukkit - multi-world should still allow teleport even if default vanilla nether disabled - if (this.vehicle == null && this.ao++ >= i) { - this.ao = i; - this.portalCooldown = this.ai(); - byte b0; - - if (this.world.worldProvider.dimension == -1) { - b0 = 0; - } else { - b0 = -1; - } - - this.b(b0); - } - - this.an = false; - } - } else { - if (this.ao > 0) { - this.ao -= 4; - } - - if (this.ao < 0) { - this.ao = 0; - } - } - - if (this.portalCooldown > 0) { - --this.portalCooldown; - } - - this.world.methodProfiler.b(); - } - - if (this.world.isStatic) { - if (this.d > 0) { - double d0 = this.locX + (this.e - this.locX) / (double) this.d; - double d1 = this.locY + (this.f - this.locY) / (double) this.d; - double d2 = this.locZ + (this.g - this.locZ) / (double) this.d; - double d3 = MathHelper.g(this.h - (double) this.yaw); - - this.yaw = (float) ((double) this.yaw + d3 / (double) this.d); - this.pitch = (float) ((double) this.pitch + (this.i - (double) this.pitch) / (double) this.d); - --this.d; - this.setPosition(d0, d1, d2); - this.b(this.yaw, this.pitch); - } else { - this.setPosition(this.locX, this.locY, this.locZ); - this.b(this.yaw, this.pitch); - } - } else { - this.lastX = this.locX; - this.lastY = this.locY; - this.lastZ = this.locZ; - this.motY -= 0.03999999910593033D; - int j = MathHelper.floor(this.locX); - - i = MathHelper.floor(this.locY); - int k = MathHelper.floor(this.locZ); - - if (BlockMinecartTrackAbstract.b_(this.world, j, i - 1, k)) { - --i; - } - - double d4 = this.maxSpeed; // CraftBukkit - double d5 = 0.0078125D; - Block block = this.world.getType(j, i, k); - - if (BlockMinecartTrackAbstract.a(block)) { - int l = this.world.getData(j, i, k); - - this.a(j, i, k, d4, d5, block, l); - if (block == Blocks.ACTIVATOR_RAIL) { - this.a(j, i, k, (l & 8) != 0); - } - } else { - this.b(d4); - } - - this.I(); - this.pitch = 0.0F; - double d6 = this.lastX - this.locX; - double d7 = this.lastZ - this.locZ; - - if (d6 * d6 + d7 * d7 > 0.001D) { - this.yaw = (float) (Math.atan2(d7, d6) * 180.0D / 3.141592653589793D); - if (this.a) { - this.yaw += 180.0F; - } - } - - double d8 = (double) MathHelper.g(this.yaw - this.lastYaw); - - if (d8 < -170.0D || d8 >= 170.0D) { - this.yaw += 180.0F; - this.a = !this.a; - } - - this.b(this.yaw, this.pitch); - - // CraftBukkit start - org.bukkit.World bworld = this.world.getWorld(); - Location from = new Location(bworld, prevX, prevY, prevZ, prevYaw, prevPitch); - Location to = new Location(bworld, this.locX, this.locY, this.locZ, this.yaw, this.pitch); - Vehicle vehicle = (Vehicle) this.getBukkitEntity(); - - this.world.getServer().getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleUpdateEvent(vehicle)); - - if (!from.equals(to)) { - this.world.getServer().getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleMoveEvent(vehicle, from, to)); - } - // CraftBukkit end - - List list = this.world.getEntities(this, this.boundingBox.grow(0.20000000298023224D, 0.0D, 0.20000000298023224D)); - - if (list != null && !list.isEmpty()) { - for (int i1 = 0; i1 < list.size(); ++i1) { - Entity entity = (Entity) list.get(i1); - - if (entity != this.passenger && entity.S() && entity instanceof EntityMinecartAbstract) { - entity.collide(this); - } - } - } - - if (this.passenger != null && this.passenger.dead) { - if (this.passenger.vehicle == this) { - this.passenger.vehicle = null; - } - - this.passenger = null; - } - } - } - - public void a(int i, int j, int k, boolean flag) {} - - protected void b(double d0) { - if (this.motX < -d0) { - this.motX = -d0; - } - - if (this.motX > d0) { - this.motX = d0; - } - - if (this.motZ < -d0) { - this.motZ = -d0; - } - - if (this.motZ > d0) { - this.motZ = d0; - } - - if (this.onGround) { - // CraftBukkit start - replace magic numbers with our variables - this.motX *= this.derailedX; - this.motY *= this.derailedY; - this.motZ *= this.derailedZ; - // CraftBukkit end - } - - this.move(this.motX, this.motY, this.motZ); - if (!this.onGround) { - // CraftBukkit start - replace magic numbers with our variables - this.motX *= this.flyingX; - this.motY *= this.flyingY; - this.motZ *= this.flyingZ; - // CraftBukkit end - } - } - - protected void a(int i, int j, int k, double d0, double d1, Block block, int l) { - this.fallDistance = 0.0F; - Vec3D vec3d = this.a(this.locX, this.locY, this.locZ); - - this.locY = (double) j; - boolean flag = false; - boolean flag1 = false; - - if (block == Blocks.GOLDEN_RAIL) { - flag = (l & 8) != 0; - flag1 = !flag; - } - - if (((BlockMinecartTrackAbstract) block).e()) { - l &= 7; - } - - if (l >= 2 && l <= 5) { - this.locY = (double) (j + 1); - } - - if (l == 2) { - this.motX -= d1; - } - - if (l == 3) { - this.motX += d1; - } - - if (l == 4) { - this.motZ += d1; - } - - if (l == 5) { - this.motZ -= d1; - } - - int[][] aint = matrix[l]; - double d2 = (double) (aint[1][0] - aint[0][0]); - double d3 = (double) (aint[1][2] - aint[0][2]); - double d4 = Math.sqrt(d2 * d2 + d3 * d3); - double d5 = this.motX * d2 + this.motZ * d3; - - if (d5 < 0.0D) { - d2 = -d2; - d3 = -d3; - } - - double d6 = Math.sqrt(this.motX * this.motX + this.motZ * this.motZ); - - if (d6 > 2.0D) { - d6 = 2.0D; - } - - this.motX = d6 * d2 / d4; - this.motZ = d6 * d3 / d4; - double d7; - double d8; - double d9; - double d10; - - if (this.passenger != null && this.passenger instanceof EntityLiving) { - d7 = (double) ((EntityLiving) this.passenger).be; - if (d7 > 0.0D) { - d8 = -Math.sin((double) (this.passenger.yaw * 3.1415927F / 180.0F)); - d9 = Math.cos((double) (this.passenger.yaw * 3.1415927F / 180.0F)); - d10 = this.motX * this.motX + this.motZ * this.motZ; - if (d10 < 0.01D) { - this.motX += d8 * 0.1D; - this.motZ += d9 * 0.1D; - flag1 = false; - } - } - } - - if (flag1) { - d7 = Math.sqrt(this.motX * this.motX + this.motZ * this.motZ); - if (d7 < 0.03D) { - this.motX *= 0.0D; - this.motY *= 0.0D; - this.motZ *= 0.0D; - } else { - this.motX *= 0.5D; - this.motY *= 0.0D; - this.motZ *= 0.5D; - } - } - - d7 = 0.0D; - d8 = (double) i + 0.5D + (double) aint[0][0] * 0.5D; - d9 = (double) k + 0.5D + (double) aint[0][2] * 0.5D; - d10 = (double) i + 0.5D + (double) aint[1][0] * 0.5D; - double d11 = (double) k + 0.5D + (double) aint[1][2] * 0.5D; - - d2 = d10 - d8; - d3 = d11 - d9; - double d12; - double d13; - - if (d2 == 0.0D) { - this.locX = (double) i + 0.5D; - d7 = this.locZ - (double) k; - } else if (d3 == 0.0D) { - this.locZ = (double) k + 0.5D; - d7 = this.locX - (double) i; - } else { - d12 = this.locX - d8; - d13 = this.locZ - d9; - d7 = (d12 * d2 + d13 * d3) * 2.0D; - } - - this.locX = d8 + d2 * d7; - this.locZ = d9 + d3 * d7; - this.setPosition(this.locX, this.locY + (double) this.height, this.locZ); - d12 = this.motX; - d13 = this.motZ; - if (this.passenger != null) { - d12 *= 0.75D; - d13 *= 0.75D; - } - - if (d12 < -d0) { - d12 = -d0; - } - - if (d12 > d0) { - d12 = d0; - } - - if (d13 < -d0) { - d13 = -d0; - } - - if (d13 > d0) { - d13 = d0; - } - - this.move(d12, 0.0D, d13); - if (aint[0][1] != 0 && MathHelper.floor(this.locX) - i == aint[0][0] && MathHelper.floor(this.locZ) - k == aint[0][2]) { - this.setPosition(this.locX, this.locY + (double) aint[0][1], this.locZ); - } else if (aint[1][1] != 0 && MathHelper.floor(this.locX) - i == aint[1][0] && MathHelper.floor(this.locZ) - k == aint[1][2]) { - this.setPosition(this.locX, this.locY + (double) aint[1][1], this.locZ); - } - - this.i(); - Vec3D vec3d1 = this.a(this.locX, this.locY, this.locZ); - - if (vec3d1 != null && vec3d != null) { - double d14 = (vec3d.b - vec3d1.b) * 0.05D; - - d6 = Math.sqrt(this.motX * this.motX + this.motZ * this.motZ); - if (d6 > 0.0D) { - this.motX = this.motX / d6 * (d6 + d14); - this.motZ = this.motZ / d6 * (d6 + d14); - } - - this.setPosition(this.locX, vec3d1.b, this.locZ); - } - - int i1 = MathHelper.floor(this.locX); - int j1 = MathHelper.floor(this.locZ); - - if (i1 != i || j1 != k) { - d6 = Math.sqrt(this.motX * this.motX + this.motZ * this.motZ); - this.motX = d6 * (double) (i1 - i); - this.motZ = d6 * (double) (j1 - k); - } - - if (flag) { - double d15 = Math.sqrt(this.motX * this.motX + this.motZ * this.motZ); - - if (d15 > 0.01D) { - double d16 = 0.06D; - - this.motX += this.motX / d15 * d16; - this.motZ += this.motZ / d15 * d16; - } else if (l == 1) { - if (this.world.getType(i - 1, j, k).r()) { - this.motX = 0.02D; - } else if (this.world.getType(i + 1, j, k).r()) { - this.motX = -0.02D; - } - } else if (l == 0) { - if (this.world.getType(i, j, k - 1).r()) { - this.motZ = 0.02D; - } else if (this.world.getType(i, j, k + 1).r()) { - this.motZ = -0.02D; - } - } - } - } - - protected void i() { - if (this.passenger != null || !this.slowWhenEmpty) { // CraftBukkit - add !this.slowWhenEmpty - this.motX *= 0.996999979019165D; - this.motY *= 0.0D; - this.motZ *= 0.996999979019165D; - } else { - this.motX *= 0.9599999785423279D; - this.motY *= 0.0D; - this.motZ *= 0.9599999785423279D; - } - } - - public Vec3D a(double d0, double d1, double d2) { - int i = MathHelper.floor(d0); - int j = MathHelper.floor(d1); - int k = MathHelper.floor(d2); - - if (BlockMinecartTrackAbstract.b_(this.world, i, j - 1, k)) { - --j; - } - - Block block = this.world.getType(i, j, k); - - if (BlockMinecartTrackAbstract.a(block)) { - int l = this.world.getData(i, j, k); - - d1 = (double) j; - if (((BlockMinecartTrackAbstract) block).e()) { - l &= 7; - } - - if (l >= 2 && l <= 5) { - d1 = (double) (j + 1); - } - - int[][] aint = matrix[l]; - double d3 = 0.0D; - double d4 = (double) i + 0.5D + (double) aint[0][0] * 0.5D; - double d5 = (double) j + 0.5D + (double) aint[0][1] * 0.5D; - double d6 = (double) k + 0.5D + (double) aint[0][2] * 0.5D; - double d7 = (double) i + 0.5D + (double) aint[1][0] * 0.5D; - double d8 = (double) j + 0.5D + (double) aint[1][1] * 0.5D; - double d9 = (double) k + 0.5D + (double) aint[1][2] * 0.5D; - double d10 = d7 - d4; - double d11 = (d8 - d5) * 2.0D; - double d12 = d9 - d6; - - if (d10 == 0.0D) { - d0 = (double) i + 0.5D; - d3 = d2 - (double) k; - } else if (d12 == 0.0D) { - d2 = (double) k + 0.5D; - d3 = d0 - (double) i; - } else { - double d13 = d0 - d4; - double d14 = d2 - d6; - - d3 = (d13 * d10 + d14 * d12) * 2.0D; - } - - d0 = d4 + d10 * d3; - d1 = d5 + d11 * d3; - d2 = d6 + d12 * d3; - if (d11 < 0.0D) { - ++d1; - } - - if (d11 > 0.0D) { - d1 += 0.5D; - } - - return Vec3D.a(d0, d1, d2); - } else { - return null; - } - } - - protected void a(NBTTagCompound nbttagcompound) { - if (nbttagcompound.getBoolean("CustomDisplayTile")) { - this.k(nbttagcompound.getInt("DisplayTile")); - this.l(nbttagcompound.getInt("DisplayData")); - this.m(nbttagcompound.getInt("DisplayOffset")); - } - - if (nbttagcompound.hasKeyOfType("CustomName", 8) && nbttagcompound.getString("CustomName").length() > 0) { - this.b = nbttagcompound.getString("CustomName"); - } - } - - protected void b(NBTTagCompound nbttagcompound) { - if (this.t()) { - nbttagcompound.setBoolean("CustomDisplayTile", true); - nbttagcompound.setInt("DisplayTile", this.n().getMaterial() == Material.AIR ? 0 : Block.getId(this.n())); - nbttagcompound.setInt("DisplayData", this.p()); - nbttagcompound.setInt("DisplayOffset", this.r()); - } - - if (this.b != null && this.b.length() > 0) { - nbttagcompound.setString("CustomName", this.b); - } - } - - public void collide(Entity entity) { - if (!this.world.isStatic) { - if (entity != this.passenger) { - // CraftBukkit start - Vehicle vehicle = (Vehicle) this.getBukkitEntity(); - org.bukkit.entity.Entity hitEntity = (entity == null) ? null : entity.getBukkitEntity(); - - VehicleEntityCollisionEvent collisionEvent = new VehicleEntityCollisionEvent(vehicle, hitEntity); - this.world.getServer().getPluginManager().callEvent(collisionEvent); - - if (collisionEvent.isCancelled()) { - return; - } - // CraftBukkit end - - if (entity instanceof EntityLiving && !(entity instanceof EntityHuman) && !(entity instanceof EntityIronGolem) && this.m() == 0 && this.motX * this.motX + this.motZ * this.motZ > 0.01D && this.passenger == null && entity.vehicle == null) { - entity.mount(this); - } - - double d0 = entity.locX - this.locX; - double d1 = entity.locZ - this.locZ; - double d2 = d0 * d0 + d1 * d1; - - // CraftBukkit - collision - if (d2 >= 9.999999747378752E-5D && !collisionEvent.isCollisionCancelled()) { - d2 = (double) MathHelper.sqrt(d2); - d0 /= d2; - d1 /= d2; - double d3 = 1.0D / d2; - - if (d3 > 1.0D) { - d3 = 1.0D; - } - - d0 *= d3; - d1 *= d3; - d0 *= 0.10000000149011612D; - d1 *= 0.10000000149011612D; - d0 *= (double) (1.0F - this.Y); - d1 *= (double) (1.0F - this.Y); - d0 *= 0.5D; - d1 *= 0.5D; - if (entity instanceof EntityMinecartAbstract) { - double d4 = entity.locX - this.locX; - double d5 = entity.locZ - this.locZ; - Vec3D vec3d = Vec3D.a(d4, 0.0D, d5).a(); - Vec3D vec3d1 = Vec3D.a((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) { - return; - } - - double d7 = entity.motX + this.motX; - double d8 = entity.motZ + this.motZ; - - if (((EntityMinecartAbstract) entity).m() == 2 && this.m() != 2) { - this.motX *= 0.20000000298023224D; - this.motZ *= 0.20000000298023224D; - this.g(entity.motX - d0, 0.0D, entity.motZ - d1); - entity.motX *= 0.949999988079071D; - entity.motZ *= 0.949999988079071D; - } else if (((EntityMinecartAbstract) entity).m() != 2 && this.m() == 2) { - entity.motX *= 0.20000000298023224D; - entity.motZ *= 0.20000000298023224D; - entity.g(this.motX + d0, 0.0D, this.motZ + d1); - this.motX *= 0.949999988079071D; - this.motZ *= 0.949999988079071D; - } else { - d7 /= 2.0D; - d8 /= 2.0D; - this.motX *= 0.20000000298023224D; - this.motZ *= 0.20000000298023224D; - this.g(d7 - d0, 0.0D, d8 - d1); - entity.motX *= 0.20000000298023224D; - entity.motZ *= 0.20000000298023224D; - entity.g(d7 + d0, 0.0D, d8 + d1); - } - } else { - this.g(-d0, 0.0D, -d1); - entity.g(d0 / 4.0D, 0.0D, d1 / 4.0D); - } - } - } - } - } - - public void setDamage(float f) { - this.datawatcher.watch(19, Float.valueOf(f)); - } - - public float getDamage() { - return this.datawatcher.getFloat(19); - } - - public void c(int i) { - this.datawatcher.watch(17, Integer.valueOf(i)); - } - - public int getType() { - return this.datawatcher.getInt(17); - } - - public void j(int i) { - this.datawatcher.watch(18, Integer.valueOf(i)); - } - - public int l() { - return this.datawatcher.getInt(18); - } - - public abstract int m(); - - public Block n() { - if (!this.t()) { - return this.o(); - } else { - int i = this.getDataWatcher().getInt(20) & '\uffff'; - - return Block.getById(i); - } - } - - public Block o() { - return Blocks.AIR; - } - - public int p() { - return !this.t() ? this.q() : this.getDataWatcher().getInt(20) >> 16; - } - - public int q() { - return 0; - } - - public int r() { - return !this.t() ? this.s() : this.getDataWatcher().getInt(21); - } - - public int s() { - return 6; - } - - public void k(int i) { - this.getDataWatcher().watch(20, Integer.valueOf(i & '\uffff' | this.p() << 16)); - this.a(true); - } - - public void l(int i) { - this.getDataWatcher().watch(20, Integer.valueOf(Block.getId(this.n()) & '\uffff' | i << 16)); - this.a(true); - } - - public void m(int i) { - this.getDataWatcher().watch(21, Integer.valueOf(i)); - this.a(true); - } - - public boolean t() { - return this.getDataWatcher().getByte(22) == 1; - } - - public void a(boolean flag) { - this.getDataWatcher().watch(22, Byte.valueOf((byte) (flag ? 1 : 0))); - } - - public void a(String s) { - this.b = s; - } - - public String getName() { - return this.b != null ? this.b : super.getName(); - } - - public boolean k_() { - return this.b != null; - } - - public String u() { - return this.b; - } - - // CraftBukkit start - Methods for getting and setting flying and derailed velocity modifiers - public Vector getFlyingVelocityMod() { - return new Vector(flyingX, flyingY, flyingZ); - } - - public void setFlyingVelocityMod(Vector flying) { - flyingX = flying.getX(); - flyingY = flying.getY(); - flyingZ = flying.getZ(); - } - - public Vector getDerailedVelocityMod() { - return new Vector(derailedX, derailedY, derailedZ); - } - - public void setDerailedVelocityMod(Vector derailed) { - derailedX = derailed.getX(); - derailedY = derailed.getY(); - derailedZ = derailed.getZ(); - } - // CraftBukkit end -} diff --git a/src/main/java/net/minecraft/server/EntityMinecartCommandBlockListener.java b/src/main/java/net/minecraft/server/EntityMinecartCommandBlockListener.java deleted file mode 100644 index 5b452856..00000000 --- a/src/main/java/net/minecraft/server/EntityMinecartCommandBlockListener.java +++ /dev/null @@ -1,25 +0,0 @@ -package net.minecraft.server; - -// CraftBukkit - package-private -> public -public class EntityMinecartCommandBlockListener extends CommandBlockListenerAbstract { - - final EntityMinecartCommandBlock a; - - EntityMinecartCommandBlockListener(EntityMinecartCommandBlock entityminecartcommandblock) { - this.a = entityminecartcommandblock; - this.sender = (org.bukkit.craftbukkit.entity.CraftMinecartCommand) entityminecartcommandblock.getBukkitEntity(); // CraftBukkit - Set the sender - } - - public void e() { - this.a.getDataWatcher().watch(23, this.getCommand()); - this.a.getDataWatcher().watch(24, ChatSerializer.a(this.h())); - } - - public ChunkCoordinates getChunkCoordinates() { - return new ChunkCoordinates(MathHelper.floor(this.a.locX), MathHelper.floor(this.a.locY + 0.5D), MathHelper.floor(this.a.locZ)); - } - - public World getWorld() { - return this.a.world; - } -} diff --git a/src/main/java/net/minecraft/server/EntityMinecartContainer.java b/src/main/java/net/minecraft/server/EntityMinecartContainer.java deleted file mode 100644 index 13b75ff8..00000000 --- a/src/main/java/net/minecraft/server/EntityMinecartContainer.java +++ /dev/null @@ -1,243 +0,0 @@ -package net.minecraft.server; - -// CraftBukkit start -import java.util.List; - -import org.bukkit.craftbukkit.entity.CraftHumanEntity; -import org.bukkit.entity.HumanEntity; -import org.bukkit.inventory.InventoryHolder; -// CraftBukkit end - -public abstract class EntityMinecartContainer extends EntityMinecartAbstract implements IInventory { - - private ItemStack[] items = new ItemStack[27]; // CraftBukkit - 36 -> 27 - private boolean b = true; - - // CraftBukkit start - public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>(); - 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 InventoryHolder getOwner() { - org.bukkit.entity.Entity cart = getBukkitEntity(); - if(cart instanceof InventoryHolder) return (InventoryHolder) cart; - return null; - } - - public void setMaxStackSize(int size) { - maxStack = size; - } - // CraftBukkit end - - public EntityMinecartContainer(World world) { - super(world); - } - - public EntityMinecartContainer(World world, double d0, double d1, double d2) { - super(world, d0, d1, d2); - } - - public void a(DamageSource damagesource) { - super.a(damagesource); - - 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; - - while (itemstack.count > 0) { - int j = this.random.nextInt(21) + 10; - - 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.getItem(), j, itemstack.getData())); - 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); - } - } - } - } - - public ItemStack getItem(int i) { - return this.items[i]; - } - - public ItemStack splitStack(int i, int j) { - if (this.items[i] != null) { - ItemStack itemstack; - - if (this.items[i].count <= j) { - itemstack = this.items[i]; - this.items[i] = null; - return itemstack; - } else { - itemstack = this.items[i].a(j); - if (this.items[i].count == 0) { - this.items[i] = null; - } - - return itemstack; - } - } else { - return null; - } - } - - public ItemStack splitWithoutUpdate(int i) { - if (this.items[i] != null) { - ItemStack itemstack = this.items[i]; - - this.items[i] = null; - return itemstack; - } else { - return null; - } - } - - public void setItem(int i, ItemStack itemstack) { - this.items[i] = itemstack; - if (itemstack != null && itemstack.count > this.getMaxStackSize()) { - itemstack.count = this.getMaxStackSize(); - } - } - - public void update() {} - - public boolean a(EntityHuman entityhuman) { - return this.dead ? false : entityhuman.f(this) <= 64.0D; - } - - public void startOpen() {} - - public void closeContainer() {} - - public boolean b(int i, ItemStack itemstack) { - return true; - } - - public String getInventoryName() { - return this.k_() ? this.u() : "container.minecart"; - } - - public int getMaxStackSize() { - return maxStack; // CraftBukkit - } - - public void b(int i) { - this.b = false; - super.b(i); - } - - public void die() { - if (this.b) { - 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; - - while (itemstack.count > 0) { - int j = this.random.nextInt(21) + 10; - - 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.getItem(), j, itemstack.getData())); - - if (itemstack.hasTag()) { - entityitem.getItemStack().setTag((NBTTagCompound) itemstack.getTag().clone()); - } - - 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); - } - } - } - } - - super.die(); - } - - protected void b(NBTTagCompound nbttagcompound) { - super.b(nbttagcompound); - NBTTagList nbttaglist = new NBTTagList(); - - for (int i = 0; i < this.items.length; ++i) { - if (this.items[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - - nbttagcompound1.setByte("Slot", (byte) i); - this.items[i].save(nbttagcompound1); - nbttaglist.add(nbttagcompound1); - } - } - - nbttagcompound.set("Items", nbttaglist); - } - - protected void a(NBTTagCompound nbttagcompound) { - super.a(nbttagcompound); - NBTTagList nbttaglist = nbttagcompound.getList("Items", 10); - - this.items = new ItemStack[this.getSize()]; - - for (int i = 0; i < nbttaglist.size(); ++i) { - NBTTagCompound nbttagcompound1 = nbttaglist.get(i); - int j = nbttagcompound1.getByte("Slot") & 255; - - if (j >= 0 && j < this.items.length) { - this.items[j] = ItemStack.createStack(nbttagcompound1); - } - } - } - - public boolean c(EntityHuman entityhuman) { - if (!this.world.isStatic) { - entityhuman.openContainer(this); - } - - return true; - } - - protected void i() { - int i = 15 - Container.b((IInventory) this); - float f = 0.98F + (float) i * 0.001F; - - this.motX *= (double) f; - this.motY *= 0.0D; - this.motZ *= (double) f; - } -} diff --git a/src/main/java/net/minecraft/server/EntityMonster.java b/src/main/java/net/minecraft/server/EntityMonster.java deleted file mode 100644 index 49aef649..00000000 --- a/src/main/java/net/minecraft/server/EntityMonster.java +++ /dev/null @@ -1,177 +0,0 @@ -package net.minecraft.server; - -import org.bukkit.event.entity.EntityCombustByEntityEvent; -import org.bukkit.event.entity.EntityTargetEvent; // CraftBukkit - -public abstract class EntityMonster extends EntityCreature implements IMonster { - - public EntityMonster(World world) { - super(world); - this.b = 5; - } - - public void e() { - this.bb(); - float f = this.d(1.0F); - - if (f > 0.5F) { - this.aU += 2; - } - - super.e(); - } - - public void h() { - super.h(); - if (!this.world.isStatic && this.world.difficulty == EnumDifficulty.PEACEFUL) { - this.die(); - } - } - - protected String H() { - return "game.hostile.swim"; - } - - protected String O() { - return "game.hostile.swim.splash"; - } - - protected Entity findTarget() { - EntityHuman entityhuman = this.world.findNearbyVulnerablePlayer(this, 16.0D); - - return entityhuman != null && this.hasLineOfSight(entityhuman) ? entityhuman : null; - } - - public boolean damageEntity(DamageSource damagesource, float f) { - if (this.isInvulnerable()) { - return false; - } else if (super.damageEntity(damagesource, f)) { - Entity entity = damagesource.getEntity(); - - if (this.passenger != entity && this.vehicle != entity) { - if (entity != this) { - // CraftBukkit start - We still need to call events for entities without goals - if (entity != this.target && (this instanceof EntityBlaze || this instanceof EntityEnderman || this instanceof EntitySpider || this instanceof EntityGiantZombie || this instanceof EntitySilverfish)) { - EntityTargetEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTargetEvent(this, entity, EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY); - - if (!event.isCancelled()) { - if (event.getTarget() == null) { - this.target = null; - } else { - this.target = ((org.bukkit.craftbukkit.entity.CraftEntity) event.getTarget()).getHandle(); - } - } - } else { - this.target = entity; - } - // CraftBukkit end - } - - return true; - } else { - return true; - } - } else { - return false; - } - } - - protected String aT() { - return "game.hostile.hurt"; - } - - protected String aU() { - return "game.hostile.die"; - } - - protected String o(int i) { - return i > 4 ? "game.hostile.hurt.fall.big" : "game.hostile.hurt.fall.small"; - } - - public boolean n(Entity entity) { - float f = (float) this.getAttributeInstance(GenericAttributes.e).getValue(); - int i = 0; - - if (entity instanceof EntityLiving) { - f += EnchantmentManager.a((EntityLiving) this, (EntityLiving) entity); - i += EnchantmentManager.getKnockbackEnchantmentLevel(this, (EntityLiving) entity); - } - - boolean flag = entity.damageEntity(DamageSource.mobAttack(this), f); - - if (flag) { - if (i > 0) { - entity.g((double) (-MathHelper.sin(this.yaw * 3.1415927F / 180.0F) * (float) i * 0.5F), 0.1D, (double) (MathHelper.cos(this.yaw * 3.1415927F / 180.0F) * (float) i * 0.5F)); - this.motX *= 0.6D; - this.motZ *= 0.6D; - } - - int j = EnchantmentManager.getFireAspectEnchantmentLevel(this); - - if (j > 0) { - // CraftBukkit start - Call a combust event when somebody hits with a fire enchanted item - EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), j * 4); - org.bukkit.Bukkit.getPluginManager().callEvent(combustEvent); - - if (!combustEvent.isCancelled()) { - entity.setOnFire(combustEvent.getDuration()); - } - // CraftBukkit end - } - - if (entity instanceof EntityLiving) { - EnchantmentManager.a((EntityLiving) entity, (Entity) this); - } - - EnchantmentManager.b(this, entity); - } - - 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.n(entity); - } - } - - public float a(int i, int j, int k) { - return 0.5F - this.world.n(i, j, k); - } - - protected boolean j_() { - int i = MathHelper.floor(this.locX); - int j = MathHelper.floor(this.boundingBox.b); - int k = MathHelper.floor(this.locZ); - - if (this.world.b(EnumSkyBlock.SKY, i, j, k) > this.random.nextInt(32)) { - return false; - } else { - int l = this.world.getLightLevel(i, j, k); - - if (this.world.P()) { - int i1 = this.world.j; - - this.world.j = 10; - l = this.world.getLightLevel(i, j, k); - this.world.j = i1; - } - - return l <= this.random.nextInt(8); - } - } - - public boolean canSpawn() { - return this.world.difficulty != EnumDifficulty.PEACEFUL && this.j_() && super.canSpawn(); - } - - protected void aD() { - super.aD(); - this.getAttributeMap().b(GenericAttributes.e); - } - - protected boolean aG() { - return true; - } -} diff --git a/src/main/java/net/minecraft/server/EntityMushroomCow.java b/src/main/java/net/minecraft/server/EntityMushroomCow.java deleted file mode 100644 index b4e43061..00000000 --- a/src/main/java/net/minecraft/server/EntityMushroomCow.java +++ /dev/null @@ -1,72 +0,0 @@ -package net.minecraft.server; - -import org.bukkit.event.player.PlayerShearEntityEvent; // CraftBukkit - -public class EntityMushroomCow extends EntityCow { - - public EntityMushroomCow(World world) { - super(world); - this.a(0.9F, 1.3F); - } - - public boolean a(EntityHuman entityhuman) { - ItemStack itemstack = entityhuman.inventory.getItemInHand(); - - if (itemstack != null && itemstack.getItem() == Items.BOWL && this.getAge() >= 0) { - if (itemstack.count == 1) { - entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, new ItemStack(Items.MUSHROOM_SOUP)); - return true; - } - - if (entityhuman.inventory.pickup(new ItemStack(Items.MUSHROOM_SOUP)) && !entityhuman.abilities.canInstantlyBuild) { - entityhuman.inventory.splitStack(entityhuman.inventory.itemInHandIndex, 1); - return true; - } - } - - if (itemstack != null && itemstack.getItem() == Items.SHEARS && this.getAge() >= 0) { - // CraftBukkit start - PlayerShearEntityEvent event = new PlayerShearEntityEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), this.getBukkitEntity()); - this.world.getServer().getPluginManager().callEvent(event); - - if (event.isCancelled()) { - return false; - } - // CraftBukkit end - - this.die(); - 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.aM = this.aM; - this.world.addEntity(entitycow); - - for (int i = 0; i < 5; ++i) { - this.world.addEntity(new EntityItem(this.world, this.locX, this.locY + (double) this.length, this.locZ, new ItemStack(Blocks.RED_MUSHROOM))); - } - - itemstack.damage(1, entityhuman); - this.makeSound("mob.sheep.shear", 1.0F, 1.0F); - } - - return true; - } else { - return super.a(entityhuman); - } - } - - public EntityMushroomCow c(EntityAgeable entityageable) { - return new EntityMushroomCow(this.world); - } - - public EntityCow b(EntityAgeable entityageable) { - return this.c(entityageable); - } - - public EntityAgeable createChild(EntityAgeable entityageable) { - return this.c(entityageable); - } -} diff --git a/src/main/java/net/minecraft/server/EntityOcelot.java b/src/main/java/net/minecraft/server/EntityOcelot.java deleted file mode 100644 index aba37489..00000000 --- a/src/main/java/net/minecraft/server/EntityOcelot.java +++ /dev/null @@ -1,232 +0,0 @@ -package net.minecraft.server; - -public class EntityOcelot extends EntityTameableAnimal { - - private PathfinderGoalTempt bq; - - public EntityOcelot(World world) { - super(world); - this.a(0.6F, 0.8F); - this.getNavigation().a(true); - this.goalSelector.a(1, new PathfinderGoalFloat(this)); - this.goalSelector.a(2, this.bp); - this.goalSelector.a(3, this.bq = new PathfinderGoalTempt(this, 0.6D, Items.RAW_FISH, true)); - this.goalSelector.a(4, new PathfinderGoalAvoidPlayer(this, EntityHuman.class, 16.0F, 0.8D, 1.33D)); - this.goalSelector.a(5, new PathfinderGoalFollowOwner(this, 1.0D, 10.0F, 5.0F)); - this.goalSelector.a(6, new PathfinderGoalJumpOnBlock(this, 1.33D)); - this.goalSelector.a(7, new PathfinderGoalLeapAtTarget(this, 0.3F)); - this.goalSelector.a(8, new PathfinderGoalOcelotAttack(this)); - this.goalSelector.a(9, new PathfinderGoalBreed(this, 0.8D)); - this.goalSelector.a(10, new PathfinderGoalRandomStroll(this, 0.8D)); - this.goalSelector.a(11, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 10.0F)); - this.targetSelector.a(1, new PathfinderGoalRandomTargetNonTamed(this, EntityChicken.class, 750, false)); - } - - protected void c() { - super.c(); - this.datawatcher.a(18, Byte.valueOf((byte) 0)); - } - - public void bp() { - if (this.getControllerMove().a()) { - double d0 = this.getControllerMove().b(); - - if (d0 == 0.6D) { - this.setSneaking(true); - this.setSprinting(false); - } else if (d0 == 1.33D) { - this.setSneaking(false); - this.setSprinting(true); - } else { - this.setSneaking(false); - this.setSprinting(false); - } - } else { - this.setSneaking(false); - this.setSprinting(false); - } - } - - protected boolean isTypeNotPersistent() { - return !this.isTamed() /*&& this.ticksLived > 2400*/; // CraftBukkit - } - - public boolean bk() { - return true; - } - - protected void aD() { - super.aD(); - this.getAttributeInstance(GenericAttributes.maxHealth).setValue(10.0D); - this.getAttributeInstance(GenericAttributes.d).setValue(0.30000001192092896D); - } - - protected void b(float f) {} - - public void b(NBTTagCompound nbttagcompound) { - super.b(nbttagcompound); - nbttagcompound.setInt("CatType", this.getCatType()); - } - - public void a(NBTTagCompound nbttagcompound) { - super.a(nbttagcompound); - this.setCatType(nbttagcompound.getInt("CatType")); - } - - protected String t() { - return this.isTamed() ? (this.ce() ? "mob.cat.purr" : (this.random.nextInt(4) == 0 ? "mob.cat.purreow" : "mob.cat.meow")) : ""; - } - - protected String aT() { - return "mob.cat.hitt"; - } - - protected String aU() { - return "mob.cat.hitt"; - } - - protected float bf() { - return 0.4F; - } - - protected Item getLoot() { - return Items.LEATHER; - } - - public boolean n(Entity entity) { - return entity.damageEntity(DamageSource.mobAttack(this), 3.0F); - } - - public boolean damageEntity(DamageSource damagesource, float f) { - if (this.isInvulnerable()) { - return false; - } else { - this.bp.setSitting(false); - return super.damageEntity(damagesource, f); - } - } - - protected void dropDeathLoot(boolean flag, int i) {} - - public boolean a(EntityHuman entityhuman) { - ItemStack itemstack = entityhuman.inventory.getItemInHand(); - - if (this.isTamed()) { - if (this.e(entityhuman) && !this.world.isStatic && !this.c(itemstack)) { - this.bp.setSitting(!this.isSitting()); - } - } else if (this.bq.f() && itemstack != null && itemstack.getItem() == Items.RAW_FISH && entityhuman.f(this) < 9.0D) { - if (!entityhuman.abilities.canInstantlyBuild) { - --itemstack.count; - } - - if (itemstack.count <= 0) { - entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, (ItemStack) null); - } - - if (!this.world.isStatic) { - // CraftBukkit - added event call and isCancelled check - if (this.random.nextInt(3) == 0 && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this, entityhuman).isCancelled()) { - this.setTamed(true); - this.setCatType(1 + this.world.random.nextInt(3)); - this.setOwnerUUID(entityhuman.getUniqueID().toString()); - this.i(true); - this.bp.setSitting(true); - this.world.broadcastEntityEffect(this, (byte) 7); - } else { - this.i(false); - this.world.broadcastEntityEffect(this, (byte) 6); - } - } - - return true; - } - - return super.a(entityhuman); - } - - public EntityOcelot b(EntityAgeable entityageable) { - EntityOcelot entityocelot = new EntityOcelot(this.world); - - if (this.isTamed()) { - entityocelot.setOwnerUUID(this.getOwnerUUID()); - entityocelot.setTamed(true); - entityocelot.setCatType(this.getCatType()); - } - - return entityocelot; - } - - public boolean c(ItemStack itemstack) { - return itemstack != null && itemstack.getItem() == Items.RAW_FISH; - } - - public boolean mate(EntityAnimal entityanimal) { - if (entityanimal == this) { - return false; - } else if (!this.isTamed()) { - return false; - } else if (!(entityanimal instanceof EntityOcelot)) { - return false; - } else { - EntityOcelot entityocelot = (EntityOcelot) entityanimal; - - return !entityocelot.isTamed() ? false : this.ce() && entityocelot.ce(); - } - } - - public int getCatType() { - return this.datawatcher.getByte(18); - } - - public void setCatType(int i) { - this.datawatcher.watch(18, Byte.valueOf((byte) i)); - } - - public boolean canSpawn() { - if (this.world.random.nextInt(3) == 0) { - return false; - } else { - if (this.world.b(this.boundingBox) && this.world.getCubes(this, this.boundingBox).isEmpty() && !this.world.containsLiquid(this.boundingBox)) { - int i = MathHelper.floor(this.locX); - int j = MathHelper.floor(this.boundingBox.b); - int k = MathHelper.floor(this.locZ); - - if (j < 63) { - return false; - } - - Block block = this.world.getType(i, j - 1, k); - - if (block == Blocks.GRASS || block.getMaterial() == Material.LEAVES) { - return true; - } - } - - return false; - } - } - - public String getName() { - return this.hasCustomName() ? this.getCustomName() : (this.isTamed() ? LocaleI18n.get("entity.Cat.name") : super.getName()); - } - - public GroupDataEntity prepare(GroupDataEntity groupdataentity) { - groupdataentity = super.prepare(groupdataentity); - 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, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.OCELOT_BABY); // CraftBukkit - add SpawnReason - } - } - - return groupdataentity; - } - - public EntityAgeable createChild(EntityAgeable entityageable) { - return this.b(entityageable); - } -} diff --git a/src/main/java/net/minecraft/server/EntityPainting.java b/src/main/java/net/minecraft/server/EntityPainting.java deleted file mode 100644 index 2c3a233d..00000000 --- a/src/main/java/net/minecraft/server/EntityPainting.java +++ /dev/null @@ -1,81 +0,0 @@ -package net.minecraft.server; - -import java.util.ArrayList; - -public class EntityPainting extends EntityHanging { - - public EnumArt art; - - public EntityPainting(World world) { - super(world); - 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) { - super(world, i, j, k, l); - ArrayList arraylist = new ArrayList(); - EnumArt[] aenumart = EnumArt.values(); - int i1 = aenumart.length; - - for (int j1 = 0; j1 < i1; ++j1) { - EnumArt enumart = aenumart[j1]; - - this.art = enumart; - this.setDirection(l); - if (this.survives()) { - arraylist.add(enumart); - } - } - - if (!arraylist.isEmpty()) { - this.art = (EnumArt) arraylist.get(this.random.nextInt(arraylist.size())); - } - - this.setDirection(l); - } - - public void b(NBTTagCompound nbttagcompound) { - nbttagcompound.setString("Motive", this.art.B); - super.b(nbttagcompound); - } - - public void a(NBTTagCompound nbttagcompound) { - String s = nbttagcompound.getString("Motive"); - EnumArt[] aenumart = EnumArt.values(); - int i = aenumart.length; - - for (int j = 0; j < i; ++j) { - EnumArt enumart = aenumart[j]; - - if (enumart.B.equals(s)) { - this.art = enumart; - } - } - - if (this.art == null) { - this.art = EnumArt.KEBAB; - } - - super.a(nbttagcompound); - } - - public int f() { - return this.art.C; - } - - public int i() { - return this.art.D; - } - - public void b(Entity entity) { - if (entity instanceof EntityHuman) { - EntityHuman entityhuman = (EntityHuman) entity; - - if (entityhuman.abilities.canInstantlyBuild) { - return; - } - } - - this.a(new ItemStack(Items.PAINTING), 0.0F); - } -} diff --git a/src/main/java/net/minecraft/server/EntityPig.java b/src/main/java/net/minecraft/server/EntityPig.java deleted file mode 100644 index 98bfd08f..00000000 --- a/src/main/java/net/minecraft/server/EntityPig.java +++ /dev/null @@ -1,159 +0,0 @@ -package net.minecraft.server; - -import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit - -public class EntityPig extends EntityAnimal { - - private final PathfinderGoalPassengerCarrotStick bp; - - public EntityPig(World world) { - super(world); - this.a(0.9F, 0.9F); - this.getNavigation().a(true); - this.goalSelector.a(0, new PathfinderGoalFloat(this)); - this.goalSelector.a(1, new PathfinderGoalPanic(this, 1.25D)); - this.goalSelector.a(2, this.bp = new PathfinderGoalPassengerCarrotStick(this, 0.3F)); - this.goalSelector.a(3, new PathfinderGoalBreed(this, 1.0D)); - this.goalSelector.a(4, new PathfinderGoalTempt(this, 1.2D, Items.CARROT_STICK, false)); - this.goalSelector.a(4, new PathfinderGoalTempt(this, 1.2D, Items.CARROT, false)); - this.goalSelector.a(5, new PathfinderGoalFollowParent(this, 1.1D)); - this.goalSelector.a(6, new PathfinderGoalRandomStroll(this, 1.0D)); - this.goalSelector.a(7, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 6.0F)); - this.goalSelector.a(8, new PathfinderGoalRandomLookaround(this)); - } - - public boolean bk() { - return true; - } - - protected void aD() { - super.aD(); - this.getAttributeInstance(GenericAttributes.maxHealth).setValue(10.0D); - this.getAttributeInstance(GenericAttributes.d).setValue(0.25D); - } - - protected void bn() { - super.bn(); - } - - public boolean bE() { - ItemStack itemstack = ((EntityHuman) this.passenger).be(); - - return itemstack != null && itemstack.getItem() == Items.CARROT_STICK; - } - - protected void c() { - super.c(); - this.datawatcher.a(16, Byte.valueOf((byte) 0)); - } - - public void b(NBTTagCompound nbttagcompound) { - super.b(nbttagcompound); - nbttagcompound.setBoolean("Saddle", this.hasSaddle()); - } - - public void a(NBTTagCompound nbttagcompound) { - super.a(nbttagcompound); - this.setSaddle(nbttagcompound.getBoolean("Saddle")); - } - - protected String t() { - return "mob.pig.say"; - } - - protected String aT() { - return "mob.pig.say"; - } - - protected String aU() { - return "mob.pig.death"; - } - - protected void a(int i, int j, int k, Block block) { - this.makeSound("mob.pig.step", 0.15F, 1.0F); - } - - public boolean a(EntityHuman entityhuman) { - if (super.a(entityhuman)) { - return true; - } else if (this.hasSaddle() && !this.world.isStatic && (this.passenger == null || this.passenger == entityhuman)) { - entityhuman.mount(this); - return true; - } else { - return false; - } - } - - protected Item getLoot() { - return this.isBurning() ? Items.GRILLED_PORK : Items.PORK; - } - - protected void dropDeathLoot(boolean flag, int i) { - int j = this.random.nextInt(3) + 1 + this.random.nextInt(1 + i); - - for (int k = 0; k < j; ++k) { - if (this.isBurning()) { - this.a(Items.GRILLED_PORK, 1); - } else { - this.a(Items.PORK, 1); - } - } - - if (this.hasSaddle()) { - this.a(Items.SADDLE, 1); - } - } - - public boolean hasSaddle() { - return (this.datawatcher.getByte(16) & 1) != 0; - } - - public void setSaddle(boolean flag) { - if (flag) { - this.datawatcher.watch(16, Byte.valueOf((byte) 1)); - } else { - this.datawatcher.watch(16, Byte.valueOf((byte) 0)); - } - } - - public void a(EntityLightning entitylightning) { - if (!this.world.isStatic) { - EntityPigZombie entitypigzombie = new EntityPigZombie(this.world); - - // CraftBukkit start - if (CraftEventFactory.callPigZapEvent(this, entitylightning, entitypigzombie).isCancelled()) { - return; - } - // CraftBukkit end - - entitypigzombie.setEquipment(0, new ItemStack(Items.GOLD_SWORD)); - entitypigzombie.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, this.pitch); - // CraftBukkit - added a reason for spawning this creature - this.world.addEntity(entitypigzombie, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING); - this.die(); - } - } - - protected void b(float f) { - super.b(f); - if (f > 5.0F && this.passenger instanceof EntityHuman) { - ((EntityHuman) this.passenger).a((Statistic) AchievementList.u); - } - } - - public EntityPig b(EntityAgeable entityageable) { - return new EntityPig(this.world); - } - - public boolean c(ItemStack itemstack) { - return itemstack != null && itemstack.getItem() == Items.CARROT; - } - - public PathfinderGoalPassengerCarrotStick ca() { - return this.bp; - } - - public EntityAgeable createChild(EntityAgeable entityageable) { - return this.b(entityageable); - } -} diff --git a/src/main/java/net/minecraft/server/EntityPigZombie.java b/src/main/java/net/minecraft/server/EntityPigZombie.java deleted file mode 100644 index f2e895e8..00000000 --- a/src/main/java/net/minecraft/server/EntityPigZombie.java +++ /dev/null @@ -1,160 +0,0 @@ -package net.minecraft.server; - -import java.util.List; -import java.util.UUID; - -import org.bukkit.event.entity.EntityTargetEvent; // CraftBukkit - -public class EntityPigZombie extends EntityZombie { - - private static final UUID bq = UUID.fromString("49455A49-7EC5-45BA-B886-3B90B23A1718"); - private static final AttributeModifier br = (new AttributeModifier(bq, "Attacking speed boost", 0.45D, 0)).a(false); - public int angerLevel; // CraftBukkit - private -> public - private int soundDelay; - private Entity bu; - - public EntityPigZombie(World world) { - super(world); - this.fireProof = true; - } - - protected void aD() { - super.aD(); - this.getAttributeInstance(bp).setValue(0.0D); - this.getAttributeInstance(GenericAttributes.d).setValue(0.5D); - this.getAttributeInstance(GenericAttributes.e).setValue(5.0D); - } - - protected boolean bk() { - return false; - } - - public void h() { - if (this.bu != this.target && !this.world.isStatic) { - AttributeInstance attributeinstance = this.getAttributeInstance(GenericAttributes.d); - - attributeinstance.b(br); - if (this.target != null) { - attributeinstance.a(br); - } - } - - this.bu = this.target; - if (this.soundDelay > 0 && --this.soundDelay == 0) { - this.makeSound("mob.zombiepig.zpigangry", this.bf() * 2.0F, ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F) * 1.8F); - } - - super.h(); - } - - public boolean canSpawn() { - return this.world.difficulty != EnumDifficulty.PEACEFUL && this.world.b(this.boundingBox) && this.world.getCubes(this, this.boundingBox).isEmpty() && !this.world.containsLiquid(this.boundingBox); - } - - public void b(NBTTagCompound nbttagcompound) { - super.b(nbttagcompound); - nbttagcompound.setShort("Anger", (short) this.angerLevel); - } - - public void a(NBTTagCompound nbttagcompound) { - super.a(nbttagcompound); - this.angerLevel = nbttagcompound.getShort("Anger"); - } - - protected Entity findTarget() { - return this.angerLevel == 0 ? null : super.findTarget(); - } - - public boolean damageEntity(DamageSource damagesource, float f) { - if (this.isInvulnerable()) { - return false; - } else { - Entity entity = damagesource.getEntity(); - - if (entity instanceof EntityHuman) { - List list = this.world.getEntities(this, this.boundingBox.grow(32.0D, 32.0D, 32.0D)); - - for (int i = 0; i < list.size(); ++i) { - Entity entity1 = (Entity) list.get(i); - - if (entity1 instanceof EntityPigZombie) { - EntityPigZombie entitypigzombie = (EntityPigZombie) entity1; - - entitypigzombie.c(entity, EntityTargetEvent.TargetReason.PIG_ZOMBIE_TARGET); - } - } - - this.c(entity, EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY); - } - - return super.damageEntity(damagesource, f); - } - } - - // CraftBukkit start - private void c(Entity entity, EntityTargetEvent.TargetReason reason) { // add TargetReason - EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), entity.getBukkitEntity(), reason); - this.world.getServer().getPluginManager().callEvent(event); - - if (event.isCancelled()) { - return; - } - - if (event.getTarget() == null) { - this.target = null; - return; - } - entity = ((org.bukkit.craftbukkit.entity.CraftEntity) event.getTarget()).getHandle(); - // CraftBukkit end - - this.target = entity; - this.angerLevel = 400 + this.random.nextInt(400); - this.soundDelay = this.random.nextInt(40); - } - - protected String t() { - return "mob.zombiepig.zpig"; - } - - protected String aT() { - return "mob.zombiepig.zpighurt"; - } - - protected String aU() { - return "mob.zombiepig.zpigdeath"; - } - - protected void dropDeathLoot(boolean flag, int i) { - int j = this.random.nextInt(2 + i); - - int k; - - for (k = 0; k < j; ++k) { - this.a(Items.ROTTEN_FLESH, 1); - } - - j = this.random.nextInt(2 + i); - - for (k = 0; k < j; ++k) { - this.a(Items.GOLD_NUGGET, 1); - } - } - - public boolean a(EntityHuman entityhuman) { - return false; - } - - protected void getRareDrop(int i) { - this.a(Items.GOLD_INGOT, 1); - } - - protected void bC() { - this.setEquipment(0, new ItemStack(Items.GOLD_SWORD)); - } - - public GroupDataEntity prepare(GroupDataEntity groupdataentity) { - super.prepare(groupdataentity); - this.setVillager(false); - return groupdataentity; - } -} diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java deleted file mode 100644 index 84673b46..00000000 --- a/src/main/java/net/minecraft/server/EntityPlayer.java +++ /dev/null @@ -1,1112 +0,0 @@ -package net.minecraft.server; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; - -import net.minecraft.util.com.google.common.collect.Sets; -import net.minecraft.util.com.mojang.authlib.GameProfile; -import net.minecraft.util.io.netty.buffer.Unpooled; -import net.minecraft.util.org.apache.commons.io.Charsets; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -// CraftBukkit start -import org.bukkit.Bukkit; -import org.bukkit.WeatherType; -import org.bukkit.craftbukkit.CraftWorld; -import org.bukkit.craftbukkit.entity.CraftPlayer; -import org.bukkit.craftbukkit.event.CraftEventFactory; -import org.bukkit.craftbukkit.inventory.CraftItemStack; -import org.bukkit.event.inventory.InventoryType; -import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; -// CraftBukkit end - -public class EntityPlayer extends EntityHuman implements ICrafting { - - private static final Logger bL = LogManager.getLogger(); - private String locale = "en_US"; - public PlayerConnection playerConnection; - public final MinecraftServer server; - public final PlayerInteractManager playerInteractManager; - public double d; - public double e; - public final List chunkCoordIntPairQueue = new LinkedList(); - public final List removeQueue = new LinkedList(); // CraftBukkit - private -> public - private final ServerStatisticManager bO; - private float bP = Float.MIN_VALUE; - private float bQ = -1.0E8F; - private int bR = -99999999; - private boolean bS = true; - public int lastSentExp = -99999999; // CraftBukkit - private -> public - public int invulnerableTicks = 60; // CraftBukkit - private -> public - private EnumChatVisibility bV; - private boolean bW = true; - private long bX = System.currentTimeMillis(); - private int containerCounter; - public boolean g; - public int ping; - public boolean viewingCredits; - // CraftBukkit start - public String displayName; - public String listName; - public org.bukkit.Location compassTarget; - public int newExp = 0; - public int newLevel = 0; - public int newTotalExp = 0; - public boolean keepLevel = false; - public double maxHealthCache; - public boolean joining = true; - // CraftBukkit end - - public EntityPlayer(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile, PlayerInteractManager playerinteractmanager) { - super(worldserver, gameprofile); - playerinteractmanager.player = this; - this.playerInteractManager = playerinteractmanager; - ChunkCoordinates chunkcoordinates = worldserver.getSpawn(); - int i = chunkcoordinates.x; - int j = chunkcoordinates.z; - int k = chunkcoordinates.y; - - if (!worldserver.worldProvider.g && worldserver.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 = worldserver.i(i, j); - } - - this.server = minecraftserver; - this.bO = minecraftserver.getPlayerList().a((EntityHuman) this); - this.W = 0.0F; - this.height = 0.0F; - this.setPositionRotation((double) i + 0.5D, (double) k, (double) j + 0.5D, 0.0F, 0.0F); - - while (!worldserver.getCubes(this, this.boundingBox).isEmpty()) { - this.setPosition(this.locX, this.locY + 1.0D, this.locZ); - } - - // CraftBukkit start - this.displayName = this.getName(); - this.listName = this.getName(); - // this.canPickUpLoot = true; TODO - this.maxHealthCache = this.getMaxHealth(); - // CraftBukkit end - } - - public void a(NBTTagCompound nbttagcompound) { - super.a(nbttagcompound); - if (nbttagcompound.hasKeyOfType("playerGameType", 99)) { - if (MinecraftServer.getServer().getForceGamemode()) { - this.playerInteractManager.setGameMode(MinecraftServer.getServer().getGamemode()); - } else { - this.playerInteractManager.setGameMode(EnumGamemode.getById(nbttagcompound.getInt("playerGameType"))); - } - } - this.getBukkitEntity().readExtraData(nbttagcompound); // CraftBukkit - } - - public void b(NBTTagCompound nbttagcompound) { - super.b(nbttagcompound); - nbttagcompound.setInt("playerGameType", this.playerInteractManager.getGameMode().getId()); - this.getBukkitEntity().setExtraData(nbttagcompound); // CraftBukkit - } - - // CraftBukkit start - World fallback code, either respawn location or global spawn - public void spawnIn(World world) { - super.spawnIn(world); - if (world == null) { - this.dead = false; - ChunkCoordinates position = null; - if (this.spawnWorld != null && !this.spawnWorld.equals("")) { - CraftWorld cworld = (CraftWorld) Bukkit.getServer().getWorld(this.spawnWorld); - if (cworld != null && this.getBed() != null) { - world = cworld.getHandle(); - position = EntityHuman.getBed(cworld.getHandle(), this.getBed(), false); - } - } - if (world == null || position == null) { - world = ((CraftWorld) Bukkit.getServer().getWorlds().get(0)).getHandle(); - position = world.getSpawn(); - } - this.world = world; - this.setPosition(position.x + 0.5, position.y, position.z + 0.5); - } - this.dimension = ((WorldServer) this.world).dimension; - this.playerInteractManager.a((WorldServer) world); - } - // CraftBukkit end - - public void levelDown(int i) { - super.levelDown(i); - this.lastSentExp = -1; - } - - public void syncInventory() { - this.activeContainer.addSlotListener(this); - } - - protected void e_() { - this.height = 0.0F; - } - - public float getHeadHeight() { - return 1.62F; - } - - public void h() { - // CraftBukkit start - if (this.joining) { - this.joining = false; - } - // CraftBukkit end - - this.playerInteractManager.a(); - --this.invulnerableTicks; - if (this.noDamageTicks > 0) { - --this.noDamageTicks; - } - - this.activeContainer.b(); - if (!this.world.isStatic && !this.activeContainer.a((EntityHuman) this)) { - this.closeInventory(); - this.activeContainer = this.defaultContainer; - } - - while (!this.removeQueue.isEmpty()) { - int i = Math.min(this.removeQueue.size(), 127); - int[] aint = new int[i]; - Iterator iterator = this.removeQueue.iterator(); - int j = 0; - - while (iterator.hasNext() && j < i) { - aint[j++] = ((Integer) iterator.next()).intValue(); - iterator.remove(); - } - - this.playerConnection.sendPacket(new PacketPlayOutEntityDestroy(aint)); - } - - if (!this.chunkCoordIntPairQueue.isEmpty()) { - ArrayList arraylist = new ArrayList(); - Iterator iterator1 = this.chunkCoordIntPairQueue.iterator(); - ArrayList arraylist1 = new ArrayList(); - - Chunk chunk; - - while (iterator1.hasNext() && arraylist.size() < PacketPlayOutMapChunkBulk.c()) { - ChunkCoordIntPair chunkcoordintpair = (ChunkCoordIntPair) iterator1.next(); - - if (chunkcoordintpair != null) { - if (this.world.isLoaded(chunkcoordintpair.x << 4, 0, chunkcoordintpair.z << 4)) { - chunk = this.world.getChunkAt(chunkcoordintpair.x, chunkcoordintpair.z); - if (chunk.isReady()) { - arraylist.add(chunk); - arraylist1.addAll(chunk.tileEntities.values()); // CraftBukkit - Get tile entities directly from the chunk instead of the world - iterator1.remove(); - } - } - } else { - iterator1.remove(); - } - } - - if (!arraylist.isEmpty()) { - this.playerConnection.sendPacket(new PacketPlayOutMapChunkBulk(arraylist)); - Iterator iterator2 = arraylist1.iterator(); - - while (iterator2.hasNext()) { - TileEntity tileentity = (TileEntity) iterator2.next(); - - this.b(tileentity); - } - - iterator2 = arraylist.iterator(); - - while (iterator2.hasNext()) { - chunk = (Chunk) iterator2.next(); - this.r().getTracker().a(this, chunk); - } - } - } - } - - public void i() { - try { - super.h(); - - for (int i = 0; i < this.inventory.getSize(); ++i) { - ItemStack itemstack = this.inventory.getItem(i); - - if (itemstack != null && itemstack.getItem().h()) { - Packet packet = ((ItemWorldMapBase) itemstack.getItem()).c(itemstack, this.world, this); - - if (packet != null) { - this.playerConnection.sendPacket(packet); - } - } - } - - // CraftBukkit - Optionally scale health - if (this.getHealth() != this.bQ || this.bR != this.foodData.getFoodLevel() || this.foodData.getSaturationLevel() == 0.0F != this.bS) { - this.playerConnection.sendPacket(new PacketPlayOutUpdateHealth(this.getBukkitEntity().getScaledHealth(), this.foodData.getFoodLevel(), this.foodData.getSaturationLevel())); - this.bQ = this.getHealth(); - this.bR = this.foodData.getFoodLevel(); - this.bS = this.foodData.getSaturationLevel() == 0.0F; - } - - if (this.getHealth() + this.getAbsorptionHearts() != this.bP) { - this.bP = this.getHealth() + this.getAbsorptionHearts(); - // CraftBukkit - Update ALL the scores! - this.world.getServer().getScoreboardManager().updateAllScoresForList(IScoreboardCriteria.f, this.getName(), com.google.common.collect.ImmutableList.of(this)); - } - - // CraftBukkit start - Force max health updates - if (this.maxHealthCache != this.getMaxHealth()) { - this.getBukkitEntity().updateScaledHealth(); - } - // CraftBukkit end - - if (this.expTotal != this.lastSentExp) { - this.lastSentExp = this.expTotal; - this.playerConnection.sendPacket(new PacketPlayOutExperience(this.exp, this.expTotal, this.expLevel)); - } - - if (this.ticksLived % 20 * 5 == 0 && !this.getStatisticManager().hasAchievement(AchievementList.L)) { - this.j(); - } - - // CraftBukkit start - initialize oldLevel and fire PlayerLevelChangeEvent - if (this.oldLevel == -1) { - this.oldLevel = this.expLevel; - } - - if (this.oldLevel != this.expLevel) { - CraftEventFactory.callPlayerLevelChangeEvent(this.world.getServer().getPlayer((EntityPlayer) this), this.oldLevel, this.expLevel); - this.oldLevel = this.expLevel; - } - // CraftBukkit end - } catch (Throwable throwable) { - CrashReport crashreport = CrashReport.a(throwable, "Ticking player"); - CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Player being ticked"); - - this.a(crashreportsystemdetails); - throw new ReportedException(crashreport); - } - } - - protected void j() { - BiomeBase biomebase = this.world.getBiome(MathHelper.floor(this.locX), MathHelper.floor(this.locZ)); - - if (biomebase != null) { - String s = biomebase.af; - AchievementSet achievementset = (AchievementSet) this.getStatisticManager().b((Statistic) AchievementList.L); // CraftBukkit - fix decompile error - - if (achievementset == null) { - achievementset = (AchievementSet) this.getStatisticManager().a(AchievementList.L, new AchievementSet()); - } - - achievementset.add(s); - if (this.getStatisticManager().b(AchievementList.L) && achievementset.size() == BiomeBase.n.size()) { - HashSet hashset = Sets.newHashSet(BiomeBase.n); - Iterator iterator = achievementset.iterator(); - - while (iterator.hasNext()) { - String s1 = (String) iterator.next(); - Iterator iterator1 = hashset.iterator(); - - while (iterator1.hasNext()) { - BiomeBase biomebase1 = (BiomeBase) iterator1.next(); - - if (biomebase1.af.equals(s1)) { - iterator1.remove(); - } - } - - if (hashset.isEmpty()) { - break; - } - } - - if (hashset.isEmpty()) { - this.a((Statistic) AchievementList.L); - } - } - } - } - - public void die(DamageSource damagesource) { - // CraftBukkit start - fire PlayerDeathEvent - if (this.dead) { - return; - } - - java.util.List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>(); - boolean keepInventory = this.world.getGameRules().getBoolean("keepInventory"); - - if (!keepInventory) { - for (int i = 0; i < this.inventory.items.length; ++i) { - if (this.inventory.items[i] != null) { - loot.add(CraftItemStack.asCraftMirror(this.inventory.items[i])); - } - } - - for (int i = 0; i < this.inventory.armor.length; ++i) { - if (this.inventory.armor[i] != null) { - loot.add(CraftItemStack.asCraftMirror(this.inventory.armor[i])); - } - } - } - - IChatBaseComponent chatmessage = this.aW().b(); - - String deathmessage = chatmessage.c(); - org.bukkit.event.entity.PlayerDeathEvent event = CraftEventFactory.callPlayerDeathEvent(this, loot, deathmessage, keepInventory); - - String deathMessage = event.getDeathMessage(); - - if (deathMessage != null && deathMessage.length() > 0) { - if (deathMessage.equals(deathmessage)) { - this.server.getPlayerList().sendMessage(chatmessage); - } else { - this.server.getPlayerList().sendMessage(org.bukkit.craftbukkit.util.CraftChatMessage.fromString(deathMessage)); - } - } - - // we clean the player's inventory after the EntityDeathEvent is called so plugins can get the exact state of the inventory. - if (!event.getKeepInventory()) { - for (int i = 0; i < this.inventory.items.length; ++i) { - this.inventory.items[i] = null; - } - - for (int i = 0; i < this.inventory.armor.length; ++i) { - this.inventory.armor[i] = null; - } - } - - this.closeInventory(); - // CraftBukkit end - - // CraftBukkit - Get our scores instead - Collection<ScoreboardScore> collection = this.world.getServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.c, this.getName(), new java.util.ArrayList<ScoreboardScore>()); - Iterator iterator = collection.iterator(); - - while (iterator.hasNext()) { - ScoreboardScore scoreboardscore = (ScoreboardScore) iterator.next(); // CraftBukkit - Use our scores instead - - scoreboardscore.incrementScore(); - } - - EntityLiving entityliving = this.aX(); - - if (entityliving != null) { - int i = EntityTypes.a(entityliving); - MonsterEggInfo monsteregginfo = (MonsterEggInfo) EntityTypes.eggInfo.get(Integer.valueOf(i)); - - if (monsteregginfo != null) { - this.a(monsteregginfo.e, 1); - } - - entityliving.b(this, this.ba); - } - - this.a(StatisticList.v, 1); - this.aW().g(); - } - - public boolean damageEntity(DamageSource damagesource, float f) { - if (this.isInvulnerable()) { - return false; - } else { - // CraftBukkit - this.server.getPvP() -> this.world.pvpMode - boolean flag = this.server.X() && this.world.pvpMode && "fall".equals(damagesource.translationIndex); - - if (!flag && this.invulnerableTicks > 0 && damagesource != DamageSource.OUT_OF_WORLD) { - return false; - } else { - if (damagesource instanceof EntityDamageSource) { - Entity entity = damagesource.getEntity(); - - if (entity instanceof EntityHuman && !this.a((EntityHuman) entity)) { - return false; - } - - if (entity instanceof EntityArrow) { - EntityArrow entityarrow = (EntityArrow) entity; - - if (entityarrow.shooter instanceof EntityHuman && !this.a((EntityHuman) entityarrow.shooter)) { - return false; - } - } - } - - return super.damageEntity(damagesource, f); - } - } - } - - public boolean a(EntityHuman entityhuman) { - // CraftBukkit - this.server.getPvP() -> this.world.pvpMode - return !this.world.pvpMode ? false : super.a(entityhuman); - } - - public void b(int i) { - if (this.dimension == 1 && i == 1) { - this.a((Statistic) AchievementList.D); - this.world.kill(this); - this.viewingCredits = true; - this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(4, 0.0F)); - } else { - if (this.dimension == 0 && i == 1) { - this.a((Statistic) AchievementList.C); - // CraftBukkit start - Rely on custom portal management - /* - ChunkCoordinates chunkcoordinates = this.server.getWorldServer(i).getDimensionSpawn(); - - if (chunkcoordinates != null) { - this.playerConnection.a((double) chunkcoordinates.x, (double) chunkcoordinates.y, (double) chunkcoordinates.z, 0.0F, 0.0F); - } - - i = 1; - */ - // CraftBukkit end - } else { - this.a((Statistic) AchievementList.y); - } - - // CraftBukkit start - TeleportCause cause = (this.dimension == 1 || i == 1) ? TeleportCause.END_PORTAL : TeleportCause.NETHER_PORTAL; - this.server.getPlayerList().changeDimension(this, i, cause); - // CraftBukkit end - this.lastSentExp = -1; - this.bQ = -1.0F; - this.bR = -1; - } - } - - private void b(TileEntity tileentity) { - if (tileentity != null) { - Packet packet = tileentity.getUpdatePacket(); - - if (packet != null) { - this.playerConnection.sendPacket(packet); - } - } - } - - public void receive(Entity entity, int i) { - super.receive(entity, i); - this.activeContainer.b(); - } - - public EnumBedResult a(int i, int j, int k) { - EnumBedResult enumbedresult = super.a(i, j, k); - - if (enumbedresult == EnumBedResult.OK) { - PacketPlayOutBed packetplayoutbed = new PacketPlayOutBed(this, i, j, k); - - this.r().getTracker().a((Entity) this, (Packet) packetplayoutbed); - this.playerConnection.a(this.locX, this.locY, this.locZ, this.yaw, this.pitch); - this.playerConnection.sendPacket(packetplayoutbed); - } - - return enumbedresult; - } - - public void a(boolean flag, boolean flag1, boolean flag2) { - if (!this.sleeping) return; // CraftBukkit - Can't leave bed if not in one! - - if (this.isSleeping()) { - this.r().getTracker().sendPacketToEntity(this, new PacketPlayOutAnimation(this, 2)); - } - - super.a(flag, flag1, flag2); - if (this.playerConnection != null) { - this.playerConnection.a(this.locX, this.locY, this.locZ, this.yaw, this.pitch); - } - } - - public void mount(Entity entity) { - // CraftBukkit start - this.setPassengerOf(entity); - } - - public void setPassengerOf(Entity entity) { - // mount(null) doesn't really fly for overloaded methods, - // so this method is needed - Entity currentVehicle = this.vehicle; - - super.setPassengerOf(entity); - - // Check if the vehicle actually changed. - if (currentVehicle != this.vehicle) { - this.playerConnection.sendPacket(new PacketPlayOutAttachEntity(0, this, this.vehicle)); - this.playerConnection.a(this.locX, this.locY, this.locZ, this.yaw, this.pitch); - } - // CraftBukkit end - } - - protected void a(double d0, boolean flag) {} - - public void b(double d0, boolean flag) { - super.a(d0, flag); - } - - public void a(TileEntity tileentity) { - if (tileentity instanceof TileEntitySign) { - ((TileEntitySign) tileentity).a((EntityHuman) this); - this.playerConnection.sendPacket(new PacketPlayOutOpenSignEditor(tileentity.x, tileentity.y, tileentity.z)); - } - } - - public int nextContainerCounter() { // CraftBukkit - private void -> public int - this.containerCounter = this.containerCounter % 100 + 1; - return this.containerCounter; // CraftBukkit - } - - public void startCrafting(int i, int j, int k) { - // 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 - - this.nextContainerCounter(); - this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, 1, "Crafting", 9, true)); - this.activeContainer = container; // CraftBukkit - Use container we passed to event - this.activeContainer.windowId = this.containerCounter; - this.activeContainer.addSlotListener(this); - } - - public void startEnchanting(int i, int j, int k, String s) { - // 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 - - this.nextContainerCounter(); - this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, 4, s == null ? "" : s, 9, s != null)); - this.activeContainer = container; // CraftBukkit - Use container we passed to event - this.activeContainer.windowId = this.containerCounter; - 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.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, 8, "Repairing", 9, true)); - 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 - Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerChest(this.inventory, iinventory)); - if (container == null) { - iinventory.closeContainer(); - return; - } - // CraftBukkit end - - this.nextContainerCounter(); - this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, 0, iinventory.getInventoryName(), iinventory.getSize(), iinventory.k_())); - this.activeContainer = container; // CraftBukkit - Use container we passed to event - this.activeContainer.windowId = this.containerCounter; - this.activeContainer.addSlotListener(this); - } - - public void openHopper(TileEntityHopper tileentityhopper) { - // CraftBukkit start - Inventory open hook - Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerHopper(this.inventory, tileentityhopper)); - if (container == null) { - tileentityhopper.closeContainer(); - return; - } - // CraftBukkit end - - this.nextContainerCounter(); - this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, 9, tileentityhopper.getInventoryName(), tileentityhopper.getSize(), tileentityhopper.k_())); - this.activeContainer = container; // CraftBukkit - Use container we passed to event - this.activeContainer.windowId = this.containerCounter; - this.activeContainer.addSlotListener(this); - } - - public void openMinecartHopper(EntityMinecartHopper entityminecarthopper) { - // CraftBukkit start - Inventory open hook - Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerHopper(this.inventory, entityminecarthopper)); - if (container == null) { - entityminecarthopper.closeContainer(); - return; - } - // CraftBukkit end - - this.nextContainerCounter(); - this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, 9, entityminecarthopper.getInventoryName(), entityminecarthopper.getSize(), entityminecarthopper.k_())); - this.activeContainer = container; // CraftBukkit - Use container we passed to event - this.activeContainer.windowId = this.containerCounter; - this.activeContainer.addSlotListener(this); - } - - public void openFurnace(TileEntityFurnace tileentityfurnace) { - // CraftBukkit start - Inventory open hook - Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerFurnace(this.inventory, tileentityfurnace)); - if (container == null) { - tileentityfurnace.closeContainer(); - return; - } - // CraftBukkit end - - this.nextContainerCounter(); - this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, 2, tileentityfurnace.getInventoryName(), tileentityfurnace.getSize(), tileentityfurnace.k_())); - this.activeContainer = container; // CraftBukkit - Use container we passed to event - this.activeContainer.windowId = this.containerCounter; - this.activeContainer.addSlotListener(this); - } - - public void openDispenser(TileEntityDispenser tileentitydispenser) { - // CraftBukkit start - Inventory open hook - Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerDispenser(this.inventory, tileentitydispenser)); - if (container == null) { - tileentitydispenser.closeContainer(); - return; - } - // CraftBukkit end - - this.nextContainerCounter(); - this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, tileentitydispenser instanceof TileEntityDropper ? 10 : 3, tileentitydispenser.getInventoryName(), tileentitydispenser.getSize(), tileentitydispenser.k_())); - this.activeContainer = container; // CraftBukkit - Use container we passed to event - this.activeContainer.windowId = this.containerCounter; - this.activeContainer.addSlotListener(this); - } - - public void openBrewingStand(TileEntityBrewingStand tileentitybrewingstand) { - // CraftBukkit start - Inventory open hook - Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerBrewingStand(this.inventory, tileentitybrewingstand)); - if (container == null) { - tileentitybrewingstand.closeContainer(); - return; - } - // CraftBukkit end - - this.nextContainerCounter(); - this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, 5, tileentitybrewingstand.getInventoryName(), tileentitybrewingstand.getSize(), tileentitybrewingstand.k_())); - this.activeContainer = container; // CraftBukkit - Use container we passed to event - this.activeContainer.windowId = this.containerCounter; - 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) { - tileentitybeacon.closeContainer(); - return; - } - // CraftBukkit end - - this.nextContainerCounter(); - this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, 7, tileentitybeacon.getInventoryName(), tileentitybeacon.getSize(), tileentitybeacon.k_())); - this.activeContainer = container; // CraftBukkit - Use container we passed to event - this.activeContainer.windowId = this.containerCounter; - this.activeContainer.addSlotListener(this); - } - - public void openTrade(IMerchant imerchant, String s) { - // 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 - Use container we passed to event - this.activeContainer.windowId = this.containerCounter; - this.activeContainer.addSlotListener(this); - InventoryMerchant inventorymerchant = ((ContainerMerchant) this.activeContainer).getMerchantInventory(); - - this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, 6, s == null ? "" : s, inventorymerchant.getSize(), s != null)); - MerchantRecipeList merchantrecipelist = imerchant.getOffers(this); - - if (merchantrecipelist != null) { - PacketDataSerializer packetdataserializer = new PacketDataSerializer(Unpooled.buffer()); - - try { - packetdataserializer.writeInt(this.containerCounter); - merchantrecipelist.a(packetdataserializer); - this.playerConnection.sendPacket(new PacketPlayOutCustomPayload("MC|TrList", packetdataserializer)); - } catch (Exception ioexception) { // CraftBukkit - IOException -> Exception - bL.error("Couldn\'t send trade list", ioexception); - } finally { - packetdataserializer.release(); - } - } - } - - public void openHorseInventory(EntityHorse entityhorse, IInventory iinventory) { - // CraftBukkit start - Inventory open hook - Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerHorse(this.inventory, iinventory, entityhorse)); - if (container == null) { - iinventory.closeContainer(); - return; - } - // CraftBukkit end - - if (this.activeContainer != this.defaultContainer) { - this.closeInventory(); - } - - this.nextContainerCounter(); - this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, 11, iinventory.getInventoryName(), iinventory.getSize(), iinventory.k_(), entityhorse.getId())); - this.activeContainer = container; // CraftBukkit - Use container we passed to event - this.activeContainer.windowId = this.containerCounter; - this.activeContainer.addSlotListener(this); - } - - public void a(Container container, int i, ItemStack itemstack) { - if (!(container.getSlot(i) instanceof SlotResult)) { - if (!this.g) { - this.playerConnection.sendPacket(new PacketPlayOutSetSlot(container.windowId, i, itemstack)); - } - } - } - - public void updateInventory(Container container) { - this.a(container, container.a()); - } - - public void a(Container container, List list) { - this.playerConnection.sendPacket(new PacketPlayOutWindowItems(container.windowId, list)); - this.playerConnection.sendPacket(new PacketPlayOutSetSlot(-1, -1, this.inventory.getCarried())); - // CraftBukkit start - Send a Set Slot to update the crafting result slot - if (java.util.EnumSet.of(InventoryType.CRAFTING,InventoryType.WORKBENCH).contains(container.getBukkitView().getType())) { - this.playerConnection.sendPacket(new PacketPlayOutSetSlot(container.windowId, 0, container.getSlot(0).getItem())); - } - // CraftBukkit end - } - - public void setContainerData(Container container, int i, int j) { - this.playerConnection.sendPacket(new PacketPlayOutWindowData(container.windowId, i, j)); - } - - public void closeInventory() { - CraftEventFactory.handleInventoryCloseEvent(this); // CraftBukkit - this.playerConnection.sendPacket(new PacketPlayOutCloseWindow(this.activeContainer.windowId)); - this.m(); - } - - public void broadcastCarriedItem() { - if (!this.g) { - this.playerConnection.sendPacket(new PacketPlayOutSetSlot(-1, -1, this.inventory.getCarried())); - } - } - - public void m() { - this.activeContainer.b((EntityHuman) this); - this.activeContainer = this.defaultContainer; - } - - public void a(float f, float f1, boolean flag, boolean flag1) { - if (this.vehicle != null) { - if (f >= -1.0F && f <= 1.0F) { - this.bd = f; - } - - if (f1 >= -1.0F && f1 <= 1.0F) { - this.be = f1; - } - - this.bc = flag; - this.setSneaking(flag1); - } - } - - public void a(Statistic statistic, int i) { - if (statistic != null) { - this.bO.b(this, statistic, i); - Iterator iterator = this.getScoreboard().getObjectivesForCriteria(statistic.k()).iterator(); - - while (iterator.hasNext()) { - ScoreboardObjective scoreboardobjective = (ScoreboardObjective) iterator.next(); - - this.getScoreboard().getPlayerScoreForObjective(this.getName(), scoreboardobjective).incrementScore(); - } - - if (this.bO.e()) { - this.bO.a(this); - } - } - } - - public void n() { - if (this.passenger != null) { - this.passenger.mount(this); - } - - if (this.sleeping) { - this.a(true, false, false); - } - } - - public void triggerHealthUpdate() { - this.bQ = -1.0E8F; - this.lastSentExp = -1; // CraftBukkit - Added to reset - } - - public void b(IChatBaseComponent ichatbasecomponent) { - this.playerConnection.sendPacket(new PacketPlayOutChat(ichatbasecomponent)); - } - - protected void p() { - this.playerConnection.sendPacket(new PacketPlayOutEntityStatus(this, (byte) 9)); - super.p(); - } - - public void a(ItemStack itemstack, int i) { - super.a(itemstack, i); - if (itemstack != null && itemstack.getItem() != null && itemstack.getItem().d(itemstack) == EnumAnimation.EAT) { - this.r().getTracker().sendPacketToEntity(this, new PacketPlayOutAnimation(this, 3)); - } - } - - public void copyTo(EntityHuman entityhuman, boolean flag) { - super.copyTo(entityhuman, flag); - this.lastSentExp = -1; - this.bQ = -1.0F; - this.bR = -1; - this.removeQueue.addAll(((EntityPlayer) entityhuman).removeQueue); - } - - protected void a(MobEffect mobeffect) { - super.a(mobeffect); - this.playerConnection.sendPacket(new PacketPlayOutEntityEffect(this.getId(), mobeffect)); - } - - protected void a(MobEffect mobeffect, boolean flag) { - super.a(mobeffect, flag); - this.playerConnection.sendPacket(new PacketPlayOutEntityEffect(this.getId(), mobeffect)); - } - - protected void b(MobEffect mobeffect) { - super.b(mobeffect); - this.playerConnection.sendPacket(new PacketPlayOutRemoveEntityEffect(this.getId(), mobeffect)); - } - - public void enderTeleportTo(double d0, double d1, double d2) { - this.playerConnection.a(d0, d1, d2, this.yaw, this.pitch); - } - - public void b(Entity entity) { - this.r().getTracker().sendPacketToEntity(this, new PacketPlayOutAnimation(entity, 4)); - } - - public void c(Entity entity) { - this.r().getTracker().sendPacketToEntity(this, new PacketPlayOutAnimation(entity, 5)); - } - - public void updateAbilities() { - if (this.playerConnection != null) { - this.playerConnection.sendPacket(new PacketPlayOutAbilities(this.abilities)); - } - } - - public WorldServer r() { - return (WorldServer) this.world; - } - - public void a(EnumGamemode enumgamemode) { - this.playerInteractManager.setGameMode(enumgamemode); - this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(3, (float) enumgamemode.getId())); - } - - // CraftBukkit start - Support multi-line messages - public void sendMessage(IChatBaseComponent[] ichatbasecomponent) { - for (IChatBaseComponent component : ichatbasecomponent) { - this.sendMessage(component); - } - } - // CraftBukkit end - - public void sendMessage(IChatBaseComponent ichatbasecomponent) { - this.playerConnection.sendPacket(new PacketPlayOutChat(ichatbasecomponent)); - } - - public boolean a(int i, String s) { - if ("seed".equals(s) && !this.server.X()) { - return true; - } else if (!"tell".equals(s) && !"help".equals(s) && !"me".equals(s)) { - if (this.server.getPlayerList().isOp(this.getProfile())) { - OpListEntry oplistentry = (OpListEntry) this.server.getPlayerList().getOPs().get(this.getProfile()); - - return oplistentry != null ? oplistentry.a() >= i : this.server.l() >= i; - } else { - return false; - } - } else { - return true; - } - } - - public String s() { - String s = this.playerConnection.networkManager.getSocketAddress().toString(); - - s = s.substring(s.indexOf("/") + 1); - s = s.substring(0, s.indexOf(":")); - return s; - } - - public void a(PacketPlayInSettings packetplayinsettings) { - this.locale = packetplayinsettings.c(); - int i = 256 >> packetplayinsettings.d(); - - if (i > 3 && i < 20) { - ; - } - - this.bV = packetplayinsettings.e(); - this.bW = packetplayinsettings.f(); - if (this.server.N() && this.server.M().equals(this.getName())) { - this.server.a(packetplayinsettings.g()); - } - - this.b(1, !packetplayinsettings.h()); - } - - public EnumChatVisibility getChatFlags() { - return this.bV; - } - - public void setResourcePack(String s) { - this.playerConnection.sendPacket(new PacketPlayOutCustomPayload("MC|RPack", s.getBytes(Charsets.UTF_8))); - } - - public ChunkCoordinates getChunkCoordinates() { - return new ChunkCoordinates(MathHelper.floor(this.locX), MathHelper.floor(this.locY + 0.5D), MathHelper.floor(this.locZ)); - } - - public void v() { - this.bX = MinecraftServer.ar(); - } - - public ServerStatisticManager getStatisticManager() { - return this.bO; - } - - public void d(Entity entity) { - if (entity instanceof EntityHuman) { - this.playerConnection.sendPacket(new PacketPlayOutEntityDestroy(new int[] { entity.getId()})); - } else { - this.removeQueue.add(Integer.valueOf(entity.getId())); - } - } - - public long x() { - return this.bX; - } - - // CraftBukkit start - Add per-player time and weather. - public long timeOffset = 0; - public boolean relativeTime = true; - - public long getPlayerTime() { - if (this.relativeTime) { - // Adds timeOffset to the current server time. - return this.world.getDayTime() + this.timeOffset; - } else { - // Adds timeOffset to the beginning of this day. - return this.world.getDayTime() - (this.world.getDayTime() % 24000) + this.timeOffset; - } - } - - public WeatherType weather = null; - - public WeatherType getPlayerWeather() { - return this.weather; - } - - public void setPlayerWeather(WeatherType type, boolean plugin) { - if (!plugin && this.weather != null) { - return; - } - - if (plugin) { - this.weather = type; - } - - if (type == WeatherType.DOWNFALL) { - this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(2, 0)); - // this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(7, this.world.j(1.0F))); - // this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(8, this.world.h(1.0F))); - } else { - this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(1, 0)); - } - } - - public void resetPlayerWeather() { - this.weather = null; - this.setPlayerWeather(this.world.getWorldData().hasStorm() ? WeatherType.DOWNFALL : WeatherType.CLEAR, false); - } - - @Override - public String toString() { - return super.toString() + "(" + this.getName() + " at " + this.locX + "," + this.locY + "," + this.locZ + ")"; - } - - public void reset() { - float exp = 0; - boolean keepInventory = this.world.getGameRules().getBoolean("keepInventory"); - - if (this.keepLevel || keepInventory) { - exp = this.exp; - this.newTotalExp = this.expTotal; - this.newLevel = this.expLevel; - } - - this.setHealth(this.getMaxHealth()); - this.fireTicks = 0; - this.fallDistance = 0; - this.foodData = new FoodMetaData(this); - this.expLevel = this.newLevel; - this.expTotal = this.newTotalExp; - this.exp = 0; - this.deathTicks = 0; - this.removeAllEffects(); - this.updateEffects = true; - this.activeContainer = this.defaultContainer; - this.killer = null; - this.lastDamager = null; - this.combatTracker = new CombatTracker(this); - this.lastSentExp = -1; - if (this.keepLevel || keepInventory) { - this.exp = exp; - } else { - this.giveExp(this.newExp); - } - this.keepLevel = false; - } - - @Override - public CraftPlayer getBukkitEntity() { - return (CraftPlayer) super.getBukkitEntity(); - } - // CraftBukkit end -} diff --git a/src/main/java/net/minecraft/server/EntityPotion.java b/src/main/java/net/minecraft/server/EntityPotion.java deleted file mode 100644 index 69db29f6..00000000 --- a/src/main/java/net/minecraft/server/EntityPotion.java +++ /dev/null @@ -1,157 +0,0 @@ -package net.minecraft.server; - -import java.util.Iterator; -import java.util.List; - -// CraftBukkit start -import java.util.HashMap; - -import org.bukkit.craftbukkit.entity.CraftLivingEntity; -import org.bukkit.entity.LivingEntity; -// CraftBukkit end - -public class EntityPotion extends EntityProjectile { - - public ItemStack item; // CraftBukkit private -> public - - public EntityPotion(World world) { - super(world); - } - - public EntityPotion(World world, EntityLiving entityliving, int i) { - this(world, entityliving, new ItemStack(Items.POTION, 1, i)); - } - - public EntityPotion(World world, EntityLiving entityliving, ItemStack itemstack) { - super(world, entityliving); - this.item = itemstack; - } - - public EntityPotion(World world, double d0, double d1, double d2, ItemStack itemstack) { - super(world, d0, d1, d2); - this.item = itemstack; - } - - protected float i() { - return 0.05F; - } - - protected float e() { - return 0.5F; - } - - protected float f() { - return -20.0F; - } - - public void setPotionValue(int i) { - if (this.item == null) { - this.item = new ItemStack(Items.POTION, 1, 0); - } - - this.item.setData(i); - } - - public int getPotionValue() { - if (this.item == null) { - this.item = new ItemStack(Items.POTION, 1, 0); - } - - return this.item.getData(); - } - - protected void a(MovingObjectPosition movingobjectposition) { - if (!this.world.isStatic) { - List list = Items.POTION.g(this.item); - - if (true || list != null && !list.isEmpty()) { // CraftBukkit - Call event even if no effects to apply - AxisAlignedBB axisalignedbb = this.boundingBox.grow(4.0D, 2.0D, 4.0D); - List list1 = this.world.a(EntityLiving.class, axisalignedbb); - - if (list1 != null) { // CraftBukkit - Run code even if there are no entities around - Iterator iterator = list1.iterator(); - - // CraftBukkit - HashMap<LivingEntity, Double> affected = new HashMap<LivingEntity, Double>(); - - while (iterator.hasNext()) { - EntityLiving entityliving = (EntityLiving) iterator.next(); - double d0 = this.f(entityliving); - - if (d0 < 16.0D) { - double d1 = 1.0D - Math.sqrt(d0) / 4.0D; - - if (entityliving == movingobjectposition.entity) { - d1 = 1.0D; - } - - // CraftBukkit start - affected.put((LivingEntity) entityliving.getBukkitEntity(), d1); - } - } - - org.bukkit.event.entity.PotionSplashEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPotionSplashEvent(this, affected); - if (!event.isCancelled() && list != null && !list.isEmpty()) { // do not process effects if there are no effects to process - for (LivingEntity victim : event.getAffectedEntities()) { - if (!(victim instanceof CraftLivingEntity)) { - continue; - } - - EntityLiving entityliving = ((CraftLivingEntity) victim).getHandle(); - double d1 = event.getIntensity(victim); - // CraftBukkit end - - Iterator iterator1 = list.iterator(); - - while (iterator1.hasNext()) { - MobEffect mobeffect = (MobEffect) iterator1.next(); - int i = mobeffect.getEffectId(); - - // CraftBukkit start - Abide by PVP settings - for players only! - if (!this.world.pvpMode && this.getShooter() instanceof EntityPlayer && entityliving instanceof EntityPlayer && entityliving != this.getShooter()) { - // Block SLOWER_MOVEMENT, SLOWER_DIG, HARM, BLINDNESS, HUNGER, WEAKNESS and POISON potions - if (i == 2 || i == 4 || i == 7 || i == 15 || i == 17 || i == 18 || i == 19) continue; - } - // CraftBukkit end - - if (MobEffectList.byId[i].isInstant()) { - // CraftBukkit - Added 'this' - MobEffectList.byId[i].applyInstantEffect(this.getShooter(), entityliving, mobeffect.getAmplifier(), d1, this); - } else { - int j = (int) (d1 * (double) mobeffect.getDuration() + 0.5D); - - if (j > 20) { - entityliving.addEffect(new MobEffect(i, j, mobeffect.getAmplifier())); - } - } - } - } - } - } - } - - 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); - if (nbttagcompound.hasKeyOfType("Potion", 10)) { - this.item = ItemStack.createStack(nbttagcompound.getCompound("Potion")); - } else { - this.setPotionValue(nbttagcompound.getInt("potionValue")); - } - - if (this.item == null) { - this.die(); - } - } - - public void b(NBTTagCompound nbttagcompound) { - super.b(nbttagcompound); - if (this.item != null) { - nbttagcompound.set("Potion", this.item.save(new NBTTagCompound())); - } - } -} diff --git a/src/main/java/net/minecraft/server/EntityProjectile.java b/src/main/java/net/minecraft/server/EntityProjectile.java deleted file mode 100644 index 7f8a33bc..00000000 --- a/src/main/java/net/minecraft/server/EntityProjectile.java +++ /dev/null @@ -1,249 +0,0 @@ -package net.minecraft.server; - -import java.util.List; - -public abstract class EntityProjectile extends Entity implements IProjectile { - - private int blockX = -1; - private int blockY = -1; - private int blockZ = -1; - private Block inBlockId; - protected boolean inGround; - public int shake; - public EntityLiving shooter; // CraftBukkit - private -> public - public String shooterName; // CraftBukkit - private -> public - private int i; - private int at; - - public EntityProjectile(World world) { - super(world); - this.a(0.25F, 0.25F); - } - - protected void c() {} - - public EntityProjectile(World world, EntityLiving entityliving) { - super(world); - this.shooter = entityliving; - this.projectileSource = (org.bukkit.entity.LivingEntity) entityliving.getBukkitEntity(); // CraftBukkit - this.a(0.25F, 0.25F); - this.setPositionRotation(entityliving.locX, entityliving.locY + (double) entityliving.getHeadHeight(), entityliving.locZ, entityliving.yaw, entityliving.pitch); - this.locX -= (double) (MathHelper.cos(this.yaw / 180.0F * 3.1415927F) * 0.16F); - this.locY -= 0.10000000149011612D; - this.locZ -= (double) (MathHelper.sin(this.yaw / 180.0F * 3.1415927F) * 0.16F); - this.setPosition(this.locX, this.locY, this.locZ); - this.height = 0.0F; - float f = 0.4F; - - this.motX = (double) (-MathHelper.sin(this.yaw / 180.0F * 3.1415927F) * MathHelper.cos(this.pitch / 180.0F * 3.1415927F) * f); - this.motZ = (double) (MathHelper.cos(this.yaw / 180.0F * 3.1415927F) * MathHelper.cos(this.pitch / 180.0F * 3.1415927F) * f); - this.motY = (double) (-MathHelper.sin((this.pitch + this.f()) / 180.0F * 3.1415927F) * f); - this.shoot(this.motX, this.motY, this.motZ, this.e(), 1.0F); - } - - public EntityProjectile(World world, double d0, double d1, double d2) { - super(world); - this.i = 0; - this.a(0.25F, 0.25F); - this.setPosition(d0, d1, d2); - this.height = 0.0F; - } - - protected float e() { - return 1.5F; - } - - protected float f() { - return 0.0F; - } - - 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; - d1 /= (double) f2; - d2 /= (double) f2; - d0 += this.random.nextGaussian() * 0.007499999832361937D * (double) f1; - d1 += this.random.nextGaussian() * 0.007499999832361937D * (double) f1; - d2 += this.random.nextGaussian() * 0.007499999832361937D * (double) f1; - d0 *= (double) f; - d1 *= (double) f; - d2 *= (double) f; - this.motX = d0; - this.motY = d1; - this.motZ = d2; - float f3 = MathHelper.sqrt(d0 * d0 + d2 * d2); - - this.lastYaw = this.yaw = (float) (Math.atan2(d0, d2) * 180.0D / 3.1415927410125732D); - this.lastPitch = this.pitch = (float) (Math.atan2(d1, (double) f3) * 180.0D / 3.1415927410125732D); - this.i = 0; - } - - public void h() { - this.S = this.locX; - this.T = this.locY; - this.U = this.locZ; - super.h(); - if (this.shake > 0) { - --this.shake; - } - - if (this.inGround) { - if (this.world.getType(this.blockX, this.blockY, this.blockZ) == this.inBlockId) { - ++this.i; - if (this.i == 1200) { - this.die(); - } - - return; - } - - this.inGround = false; - this.motX *= (double) (this.random.nextFloat() * 0.2F); - this.motY *= (double) (this.random.nextFloat() * 0.2F); - this.motZ *= (double) (this.random.nextFloat() * 0.2F); - this.i = 0; - this.at = 0; - } else { - ++this.at; - } - - Vec3D vec3d = Vec3D.a(this.locX, this.locY, this.locZ); - Vec3D vec3d1 = Vec3D.a(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ); - MovingObjectPosition movingobjectposition = this.world.a(vec3d, vec3d1); - - vec3d = Vec3D.a(this.locX, this.locY, this.locZ); - vec3d1 = Vec3D.a(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ); - if (movingobjectposition != null) { - vec3d1 = Vec3D.a(movingobjectposition.pos.a, movingobjectposition.pos.b, movingobjectposition.pos.c); - } - - if (!this.world.isStatic) { - Entity entity = null; - List list = this.world.getEntities(this, this.boundingBox.a(this.motX, this.motY, this.motZ).grow(1.0D, 1.0D, 1.0D)); - double d0 = 0.0D; - EntityLiving entityliving = this.getShooter(); - - for (int i = 0; i < list.size(); ++i) { - Entity entity1 = (Entity) list.get(i); - - if (entity1.R() && (entity1 != entityliving || this.at >= 5)) { - float f = 0.3F; - AxisAlignedBB axisalignedbb = entity1.boundingBox.grow((double) f, (double) f, (double) f); - MovingObjectPosition movingobjectposition1 = axisalignedbb.a(vec3d, vec3d1); - - if (movingobjectposition1 != null) { - double d1 = vec3d.distanceSquared(movingobjectposition1.pos); // CraftBukkit - distance efficiency - - if (d1 < d0 || d0 == 0.0D) { - entity = entity1; - d0 = d1; - } - } - } - } - - if (entity != null) { - movingobjectposition = new MovingObjectPosition(entity); - } - } - - if (movingobjectposition != null) { - if (movingobjectposition.type == EnumMovingObjectType.BLOCK && this.world.getType(movingobjectposition.b, movingobjectposition.c, movingobjectposition.d) == Blocks.PORTAL) { - this.ah(); - } else { - this.a(movingobjectposition); - // CraftBukkit start - if (this.dead) { - org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this); - } - // CraftBukkit end - } - } - - this.locX += this.motX; - this.locY += this.motY; - 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); - - for (this.pitch = (float) (Math.atan2(this.motY, (double) f1) * 180.0D / 3.1415927410125732D); this.pitch - this.lastPitch < -180.0F; this.lastPitch -= 360.0F) { - ; - } - - while (this.pitch - this.lastPitch >= 180.0F) { - this.lastPitch += 360.0F; - } - - while (this.yaw - this.lastYaw < -180.0F) { - this.lastYaw -= 360.0F; - } - - while (this.yaw - this.lastYaw >= 180.0F) { - this.lastYaw += 360.0F; - } - - this.pitch = this.lastPitch + (this.pitch - this.lastPitch) * 0.2F; - this.yaw = this.lastYaw + (this.yaw - this.lastYaw) * 0.2F; - float f2 = 0.99F; - float f3 = this.i(); - - if (this.M()) { - for (int j = 0; j < 4; ++j) { - float f4 = 0.25F; - - 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; - } - - this.motX *= (double) f2; - this.motY *= (double) f2; - this.motZ *= (double) f2; - this.motY -= (double) f3; - this.setPosition(this.locX, this.locY, this.locZ); - } - - protected float i() { - return 0.03F; - } - - protected abstract void a(MovingObjectPosition movingobjectposition); - - public void b(NBTTagCompound nbttagcompound) { - nbttagcompound.setShort("xTile", (short) this.blockX); - nbttagcompound.setShort("yTile", (short) this.blockY); - nbttagcompound.setShort("zTile", (short) this.blockZ); - nbttagcompound.setByte("inTile", (byte) Block.getId(this.inBlockId)); - nbttagcompound.setByte("shake", (byte) this.shake); - nbttagcompound.setByte("inGround", (byte) (this.inGround ? 1 : 0)); - if ((this.shooterName == null || this.shooterName.length() == 0) && this.shooter != null && this.shooter instanceof EntityHuman) { - this.shooterName = this.shooter.getName(); - } - - nbttagcompound.setString("ownerName", this.shooterName == null ? "" : this.shooterName); - } - - public void a(NBTTagCompound nbttagcompound) { - this.blockX = nbttagcompound.getShort("xTile"); - this.blockY = nbttagcompound.getShort("yTile"); - this.blockZ = nbttagcompound.getShort("zTile"); - this.inBlockId = Block.getById(nbttagcompound.getByte("inTile") & 255); - this.shake = nbttagcompound.getByte("shake") & 255; - this.inGround = nbttagcompound.getByte("inGround") == 1; - this.shooterName = nbttagcompound.getString("ownerName"); - if (this.shooterName != null && this.shooterName.length() == 0) { - this.shooterName = null; - } - } - - public EntityLiving getShooter() { - if (this.shooter == null && this.shooterName != null && this.shooterName.length() > 0) { - this.shooter = this.world.a(this.shooterName); - } - - return this.shooter; - } -} diff --git a/src/main/java/net/minecraft/server/EntitySheep.java b/src/main/java/net/minecraft/server/EntitySheep.java deleted file mode 100644 index 381ae787..00000000 --- a/src/main/java/net/minecraft/server/EntitySheep.java +++ /dev/null @@ -1,219 +0,0 @@ -package net.minecraft.server; - -import java.util.Random; - -// CraftBukkit start -import org.bukkit.event.entity.SheepRegrowWoolEvent; -import org.bukkit.event.player.PlayerShearEntityEvent; -// CraftBukkit end - -public class EntitySheep extends EntityAnimal { - - private final InventoryCrafting bq = new InventoryCrafting(new ContainerSheepBreed(this), 2, 1); - public static final float[][] bp = new float[][] { { 1.0F, 1.0F, 1.0F}, { 0.85F, 0.5F, 0.2F}, { 0.7F, 0.3F, 0.85F}, { 0.4F, 0.6F, 0.85F}, { 0.9F, 0.9F, 0.2F}, { 0.5F, 0.8F, 0.1F}, { 0.95F, 0.5F, 0.65F}, { 0.3F, 0.3F, 0.3F}, { 0.6F, 0.6F, 0.6F}, { 0.3F, 0.5F, 0.6F}, { 0.5F, 0.25F, 0.7F}, { 0.2F, 0.3F, 0.7F}, { 0.4F, 0.3F, 0.2F}, { 0.4F, 0.5F, 0.2F}, { 0.6F, 0.2F, 0.2F}, { 0.1F, 0.1F, 0.1F}}; - private int br; - private PathfinderGoalEatTile bs = new PathfinderGoalEatTile(this); - - public EntitySheep(World world) { - super(world); - this.a(0.9F, 1.3F); - this.getNavigation().a(true); - this.goalSelector.a(0, new PathfinderGoalFloat(this)); - this.goalSelector.a(1, new PathfinderGoalPanic(this, 1.25D)); - this.goalSelector.a(2, new PathfinderGoalBreed(this, 1.0D)); - this.goalSelector.a(3, new PathfinderGoalTempt(this, 1.1D, Items.WHEAT, false)); - this.goalSelector.a(4, new PathfinderGoalFollowParent(this, 1.1D)); - this.goalSelector.a(5, this.bs); - this.goalSelector.a(6, new PathfinderGoalRandomStroll(this, 1.0D)); - this.goalSelector.a(7, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 6.0F)); - this.goalSelector.a(8, new PathfinderGoalRandomLookaround(this)); - this.bq.setItem(0, new ItemStack(Items.INK_SACK, 1, 0)); - this.bq.setItem(1, new ItemStack(Items.INK_SACK, 1, 0)); - this.bq.resultInventory = new InventoryCraftResult(); // CraftBukkit - add result slot for event - } - - protected boolean bk() { - return true; - } - - protected void bn() { - this.br = this.bs.f(); - super.bn(); - } - - public void e() { - if (this.world.isStatic) { - this.br = Math.max(0, this.br - 1); - } - - super.e(); - } - - protected void aD() { - super.aD(); - this.getAttributeInstance(GenericAttributes.maxHealth).setValue(8.0D); - this.getAttributeInstance(GenericAttributes.d).setValue(0.23000000417232513D); - } - - protected void c() { - super.c(); - this.datawatcher.a(16, new Byte((byte) 0)); - } - - protected void dropDeathLoot(boolean flag, int i) { - if (!this.isSheared()) { - this.a(new ItemStack(Item.getItemOf(Blocks.WOOL), 1, this.getColor()), 0.0F); - } - } - - protected Item getLoot() { - return Item.getItemOf(Blocks.WOOL); - } - - public boolean a(EntityHuman entityhuman) { - ItemStack itemstack = entityhuman.inventory.getItemInHand(); - - if (itemstack != null && itemstack.getItem() == Items.SHEARS && !this.isSheared() && !this.isBaby()) { - if (!this.world.isStatic) { - // CraftBukkit start - PlayerShearEntityEvent event = new PlayerShearEntityEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), this.getBukkitEntity()); - this.world.getServer().getPluginManager().callEvent(event); - - if (event.isCancelled()) { - return false; - } - // CraftBukkit end - - this.setSheared(true); - int i = 1 + this.random.nextInt(3); - - for (int j = 0; j < i; ++j) { - EntityItem entityitem = this.a(new ItemStack(Item.getItemOf(Blocks.WOOL), 1, this.getColor()), 1.0F); - - entityitem.motY += (double) (this.random.nextFloat() * 0.05F); - entityitem.motX += (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F); - entityitem.motZ += (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F); - } - } - - itemstack.damage(1, entityhuman); - this.makeSound("mob.sheep.shear", 1.0F, 1.0F); - } - - return super.a(entityhuman); - } - - public void b(NBTTagCompound nbttagcompound) { - super.b(nbttagcompound); - nbttagcompound.setBoolean("Sheared", this.isSheared()); - nbttagcompound.setByte("Color", (byte) this.getColor()); - } - - public void a(NBTTagCompound nbttagcompound) { - super.a(nbttagcompound); - this.setSheared(nbttagcompound.getBoolean("Sheared")); - this.setColor(nbttagcompound.getByte("Color")); - } - - protected String t() { - return "mob.sheep.say"; - } - - protected String aT() { - return "mob.sheep.say"; - } - - protected String aU() { - return "mob.sheep.say"; - } - - protected void a(int i, int j, int k, Block block) { - this.makeSound("mob.sheep.step", 0.15F, 1.0F); - } - - public int getColor() { - return this.datawatcher.getByte(16) & 15; - } - - public void setColor(int i) { - byte b0 = this.datawatcher.getByte(16); - - this.datawatcher.watch(16, Byte.valueOf((byte) (b0 & 240 | i & 15))); - } - - public boolean isSheared() { - return (this.datawatcher.getByte(16) & 16) != 0; - } - - public void setSheared(boolean flag) { - byte b0 = this.datawatcher.getByte(16); - - if (flag) { - this.datawatcher.watch(16, Byte.valueOf((byte) (b0 | 16))); - } else { - this.datawatcher.watch(16, Byte.valueOf((byte) (b0 & -17))); - } - } - - public static int a(Random random) { - int i = random.nextInt(100); - - return i < 5 ? 15 : (i < 10 ? 7 : (i < 15 ? 8 : (i < 18 ? 12 : (random.nextInt(500) == 0 ? 6 : 0)))); - } - - public EntitySheep b(EntityAgeable entityageable) { - EntitySheep entitysheep = (EntitySheep) entityageable; - EntitySheep entitysheep1 = new EntitySheep(this.world); - int i = this.a(this, entitysheep); - - entitysheep1.setColor(15 - i); - return entitysheep1; - } - - public void p() { - // CraftBukkit start - SheepRegrowWoolEvent event = new SheepRegrowWoolEvent((org.bukkit.entity.Sheep) this.getBukkitEntity()); - this.world.getServer().getPluginManager().callEvent(event); - - if (!event.isCancelled()) { - this.setSheared(false); - } - // CraftBukkit end - - if (this.isBaby()) { - this.a(60); - } - } - - public GroupDataEntity prepare(GroupDataEntity groupdataentity) { - groupdataentity = super.prepare(groupdataentity); - this.setColor(a(this.world.random)); - return groupdataentity; - } - - private int a(EntityAnimal entityanimal, EntityAnimal entityanimal1) { - int i = this.b(entityanimal); - int j = this.b(entityanimal1); - - this.bq.getItem(0).setData(i); - this.bq.getItem(1).setData(j); - ItemStack itemstack = CraftingManager.getInstance().craft(this.bq, ((EntitySheep) entityanimal).world); - int k; - - if (itemstack != null && itemstack.getItem() == Items.INK_SACK) { - k = itemstack.getData(); - } else { - k = this.world.random.nextBoolean() ? i : j; - } - - return k; - } - - private int b(EntityAnimal entityanimal) { - return 15 - ((EntitySheep) entityanimal).getColor(); - } - - public EntityAgeable createChild(EntityAgeable entityageable) { - return this.b(entityageable); - } -} diff --git a/src/main/java/net/minecraft/server/EntitySilverfish.java b/src/main/java/net/minecraft/server/EntitySilverfish.java deleted file mode 100644 index ac5714f0..00000000 --- a/src/main/java/net/minecraft/server/EntitySilverfish.java +++ /dev/null @@ -1,171 +0,0 @@ -package net.minecraft.server; - -import net.minecraft.util.org.apache.commons.lang3.tuple.ImmutablePair; - -import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit - -public class EntitySilverfish extends EntityMonster { - - private int bp; - - public EntitySilverfish(World world) { - super(world); - this.a(0.3F, 0.7F); - } - - protected void aD() { - super.aD(); - this.getAttributeInstance(GenericAttributes.maxHealth).setValue(8.0D); - this.getAttributeInstance(GenericAttributes.d).setValue(0.6000000238418579D); - this.getAttributeInstance(GenericAttributes.e).setValue(1.0D); - } - - protected boolean g_() { - return false; - } - - protected Entity findTarget() { - double d0 = 8.0D; - - return this.world.findNearbyVulnerablePlayer(this, d0); - } - - protected String t() { - return "mob.silverfish.say"; - } - - protected String aT() { - return "mob.silverfish.hit"; - } - - protected String aU() { - return "mob.silverfish.kill"; - } - - public boolean damageEntity(DamageSource damagesource, float f) { - if (this.isInvulnerable()) { - return false; - } else { - if (this.bp <= 0 && (damagesource instanceof EntityDamageSource || damagesource == DamageSource.MAGIC)) { - this.bp = 20; - } - - return super.damageEntity(damagesource, f); - } - } - - 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; - this.n(entity); - } - } - - protected void a(int i, int j, int k, Block block) { - this.makeSound("mob.silverfish.step", 0.15F, 1.0F); - } - - protected Item getLoot() { - return Item.getById(0); - } - - public void h() { - this.aM = this.yaw; - super.h(); - } - - protected void bq() { - super.bq(); - if (!this.world.isStatic) { - int i; - int j; - int k; - int l; - - if (this.bp > 0) { - --this.bp; - if (this.bp == 0) { - i = MathHelper.floor(this.locX); - j = MathHelper.floor(this.locY); - k = MathHelper.floor(this.locZ); - boolean flag = false; - - for (int i1 = 0; !flag && i1 <= 5 && i1 >= -5; i1 = i1 <= 0 ? 1 - i1 : 0 - i1) { - for (l = 0; !flag && l <= 10 && l >= -10; l = l <= 0 ? 1 - l : 0 - l) { - for (int j1 = 0; !flag && j1 <= 10 && j1 >= -10; j1 = j1 <= 0 ? 1 - j1 : 0 - j1) { - if (this.world.getType(i + l, j + i1, k + j1) == Blocks.MONSTER_EGGS) { - // CraftBukkit start - if (CraftEventFactory.callEntityChangeBlockEvent(this, i + l, j + i1, k + j1, Blocks.AIR, 0).isCancelled()) { - continue; - } - // CraftBukkit end - if (!this.world.getGameRules().getBoolean("mobGriefing")) { - int k1 = this.world.getData(i + l, j + i1, k + j1); - ImmutablePair immutablepair = BlockMonsterEggs.b(k1); - - this.world.setTypeAndData(i + l, j + i1, k + j1, (Block) immutablepair.getLeft(), ((Integer) immutablepair.getRight()).intValue(), 3); - } else { - this.world.setAir(i + l, j + i1, k + j1, false); - } - - Blocks.MONSTER_EGGS.postBreak(this.world, i + l, j + i1, k + j1, 0); - if (this.random.nextBoolean()) { - flag = true; - break; - } - } - } - } - } - } - } - - if (this.target == null && !this.bS()) { - i = MathHelper.floor(this.locX); - j = MathHelper.floor(this.locY + 0.5D); - k = MathHelper.floor(this.locZ); - int l1 = this.random.nextInt(6); - Block block = this.world.getType(i + Facing.b[l1], j + Facing.c[l1], k + Facing.d[l1]); - - l = this.world.getData(i + Facing.b[l1], j + Facing.c[l1], k + Facing.d[l1]); - if (BlockMonsterEggs.a(block)) { - // CraftBukkit start - if (CraftEventFactory.callEntityChangeBlockEvent(this, i + Facing.b[l1], j + Facing.c[l1], k + Facing.d[l1], Blocks.MONSTER_EGGS, Block.getId(BlockMonsterEggs.getById(l))).isCancelled()) { - return; - } - // CraftBukkit end - - this.world.setTypeAndData(i + Facing.b[l1], j + Facing.c[l1], k + Facing.d[l1], Blocks.MONSTER_EGGS, BlockMonsterEggs.a(block, l), 3); - this.s(); - this.die(); - } else { - this.bQ(); - } - } else if (this.target != null && !this.bS()) { - this.target = null; - } - } - } - - public float a(int i, int j, int k) { - return this.world.getType(i, j - 1, k) == Blocks.STONE ? 10.0F : super.a(i, j, k); - } - - protected boolean j_() { - return true; - } - - public boolean canSpawn() { - if (super.canSpawn()) { - EntityHuman entityhuman = this.world.findNearbyPlayer(this, 5.0D); - - return entityhuman == null; - } else { - return false; - } - } - - 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 deleted file mode 100644 index 479936f3..00000000 --- a/src/main/java/net/minecraft/server/EntitySkeleton.java +++ /dev/null @@ -1,294 +0,0 @@ -package net.minecraft.server; - -import java.util.Calendar; - -import org.bukkit.event.entity.EntityCombustEvent; // CraftBukkit - -public class EntitySkeleton extends EntityMonster implements IRangedEntity { - - private PathfinderGoalArrowAttack bp = new PathfinderGoalArrowAttack(this, 1.0D, 20, 60, 15.0F); - private PathfinderGoalMeleeAttack bq = new PathfinderGoalMeleeAttack(this, EntityHuman.class, 1.2D, false); - - public EntitySkeleton(World world) { - super(world); - this.goalSelector.a(1, new PathfinderGoalFloat(this)); - this.goalSelector.a(2, new PathfinderGoalRestrictSun(this)); - this.goalSelector.a(3, new PathfinderGoalFleeSun(this, 1.0D)); - this.goalSelector.a(5, new PathfinderGoalRandomStroll(this, 1.0D)); - 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, 0, true)); - if (world != null && !world.isStatic) { - this.bZ(); - } - } - - protected void aD() { - super.aD(); - this.getAttributeInstance(GenericAttributes.d).setValue(0.25D); - } - - protected void c() { - super.c(); - this.datawatcher.a(13, new Byte((byte) 0)); - } - - public boolean bk() { - return true; - } - - protected String t() { - return "mob.skeleton.say"; - } - - protected String aT() { - return "mob.skeleton.hurt"; - } - - protected String aU() { - return "mob.skeleton.death"; - } - - protected void a(int i, int j, int k, Block block) { - this.makeSound("mob.skeleton.step", 0.15F, 1.0F); - } - - public boolean n(Entity entity) { - if (super.n(entity)) { - if (this.getSkeletonType() == 1 && entity instanceof EntityLiving) { - ((EntityLiving) entity).addEffect(new MobEffect(MobEffectList.WITHER.id, 200)); - } - - return true; - } else { - return false; - } - } - - public EnumMonsterType getMonsterType() { - return EnumMonsterType.UNDEAD; - } - - public void e() { - if (this.world.w() && !this.world.isStatic) { - float f = this.d(1.0F); - - if (f > 0.5F && this.random.nextFloat() * 30.0F < (f - 0.4F) * 2.0F && this.world.i(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.g()) { - itemstack.setData(itemstack.j() + this.random.nextInt(2)); - if (itemstack.j() >= itemstack.l()) { - 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()); - } - // CraftBukkit end - } - } - } - - if (this.world.isStatic && this.getSkeletonType() == 1) { - this.a(0.72F, 2.34F); - } - - super.e(); - } - - public void ab() { - super.ab(); - if (this.vehicle instanceof EntityCreature) { - EntityCreature entitycreature = (EntityCreature) this.vehicle; - - this.aM = entitycreature.aM; - } - } - - public void die(DamageSource damagesource) { - super.die(damagesource); - if (damagesource.i() instanceof EntityArrow && damagesource.getEntity() instanceof EntityHuman) { - EntityHuman entityhuman = (EntityHuman) damagesource.getEntity(); - double d0 = entityhuman.locX - this.locX; - double d1 = entityhuman.locZ - this.locZ; - - if (d0 * d0 + d1 * d1 >= 2500.0D) { - entityhuman.a((Statistic) AchievementList.v); - } - } - } - - protected Item getLoot() { - return Items.ARROW; - } - - protected void dropDeathLoot(boolean flag, int i) { - int j; - int k; - - if (this.getSkeletonType() == 1) { - j = this.random.nextInt(3 + i) - 1; - - for (k = 0; k < j; ++k) { - this.a(Items.COAL, 1); - } - } else { - j = this.random.nextInt(3 + i); - - for (k = 0; k < j; ++k) { - this.a(Items.ARROW, 1); - } - } - - j = this.random.nextInt(3 + i); - - for (k = 0; k < j; ++k) { - this.a(Items.BONE, 1); - } - } - - protected void getRareDrop(int i) { - if (this.getSkeletonType() == 1) { - this.a(new ItemStack(Items.SKULL, 1, 1), 0.0F); - } - } - - protected void bC() { - super.bC(); - this.setEquipment(0, new ItemStack(Items.BOW)); - } - - public GroupDataEntity prepare(GroupDataEntity groupdataentity) { - groupdataentity = super.prepare(groupdataentity); - if (this.world.worldProvider instanceof WorldProviderHell && this.aI().nextInt(5) > 0) { - this.goalSelector.a(4, this.bq); - this.setSkeletonType(1); - this.setEquipment(0, new ItemStack(Items.STONE_SWORD)); - this.getAttributeInstance(GenericAttributes.e).setValue(4.0D); - } else { - this.goalSelector.a(4, this.bp); - this.bC(); - this.bD(); - } - - this.h(this.random.nextFloat() < 0.55F * this.world.b(this.locX, this.locY, this.locZ)); - if (this.getEquipment(4) == null) { - Calendar calendar = this.world.V(); - - 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 ? Blocks.JACK_O_LANTERN : Blocks.PUMPKIN)); - this.dropChances[4] = 0.0F; - } - } - - return groupdataentity; - } - - public void bZ() { - this.goalSelector.a((PathfinderGoal) this.bq); - this.goalSelector.a((PathfinderGoal) this.bp); - ItemStack itemstack = this.be(); - - if (itemstack != null && itemstack.getItem() == Items.BOW) { - this.goalSelector.a(4, this.bp); - } else { - this.goalSelector.a(4, this.bq); - } - } - - public void a(EntityLiving entityliving, float f) { - EntityArrow entityarrow = new EntityArrow(this.world, this, entityliving, 1.6F, (float) (14 - this.world.difficulty.a() * 4)); - int i = EnchantmentManager.getEnchantmentLevel(Enchantment.ARROW_DAMAGE.id, this.be()); - int j = EnchantmentManager.getEnchantmentLevel(Enchantment.ARROW_KNOCKBACK.id, this.be()); - - entityarrow.b((double) (f * 2.0F) + this.random.nextGaussian() * 0.25D + (double) ((float) this.world.difficulty.a() * 0.11F)); - if (i > 0) { - entityarrow.b(entityarrow.e() + (double) i * 0.5D + 0.5D); - } - - if (j > 0) { - entityarrow.setKnockbackStrength(j); - } - - if (EnchantmentManager.getEnchantmentLevel(Enchantment.ARROW_FIRE.id, this.be()) > 0 || this.getSkeletonType() == 1) { - // CraftBukkit start - call EntityCombustEvent - EntityCombustEvent event = new EntityCombustEvent(entityarrow.getBukkitEntity(), 100); - this.world.getServer().getPluginManager().callEvent(event); - - if (!event.isCancelled()) { - entityarrow.setOnFire(event.getDuration()); - } - // CraftBukkit end - } - - // CraftBukkit start - org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(this, this.be(), entityarrow, 0.8F); - if (event.isCancelled()) { - event.getProjectile().remove(); - return; - } - - if (event.getProjectile() == entityarrow.getBukkitEntity()) { - world.addEntity(entityarrow); - } - // CraftBukkit end - - this.makeSound("random.bow", 1.0F, 1.0F / (this.aI().nextFloat() * 0.4F + 0.8F)); - // this.world.addEntity(entityarrow); // CraftBukkit - moved up - } - - 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.34F); - } else { - this.a(0.6F, 1.8F); - } - } - - public void a(NBTTagCompound nbttagcompound) { - super.a(nbttagcompound); - if (nbttagcompound.hasKeyOfType("SkeletonType", 99)) { - byte b0 = nbttagcompound.getByte("SkeletonType"); - - this.setSkeletonType(b0); - } - - this.bZ(); - } - - public void b(NBTTagCompound nbttagcompound) { - super.b(nbttagcompound); - nbttagcompound.setByte("SkeletonType", (byte) this.getSkeletonType()); - } - - public void setEquipment(int i, ItemStack itemstack) { - super.setEquipment(i, itemstack); - if (!this.world.isStatic && i == 0) { - this.bZ(); - } - } - - public double ad() { - return super.ad() - 0.5D; - } -} diff --git a/src/main/java/net/minecraft/server/EntitySlime.java b/src/main/java/net/minecraft/server/EntitySlime.java deleted file mode 100644 index 65cd24dd..00000000 --- a/src/main/java/net/minecraft/server/EntitySlime.java +++ /dev/null @@ -1,265 +0,0 @@ -package net.minecraft.server; - -// CraftBukkit start -import org.bukkit.craftbukkit.entity.CraftEntity; -import org.bukkit.craftbukkit.event.CraftEventFactory; -import org.bukkit.event.entity.EntityTargetEvent; -import org.bukkit.event.entity.SlimeSplitEvent; -// CraftBukkit end - -public class EntitySlime extends EntityInsentient implements IMonster { - - public float h; - public float i; - public float bm; - private int jumpDelay; - private Entity lastTarget; // CraftBukkit - - public EntitySlime(World world) { - super(world); - int i = 1 << this.random.nextInt(3); - - this.height = 0.0F; - this.jumpDelay = this.random.nextInt(20) + 10; - this.setSize(i); - } - - protected void c() { - super.c(); - this.datawatcher.a(16, new Byte((byte) 1)); - } - - // CraftBukkit - protected -> public - public void setSize(int i) { - this.datawatcher.watch(16, new Byte((byte) i)); - this.a(0.6F * (float) i, 0.6F * (float) i); - this.setPosition(this.locX, this.locY, this.locZ); - this.getAttributeInstance(GenericAttributes.maxHealth).setValue((double) (i * i)); - this.setHealth(this.getMaxHealth()); - this.b = i; - } - - public int getSize() { - return this.datawatcher.getByte(16); - } - - public void b(NBTTagCompound nbttagcompound) { - super.b(nbttagcompound); - nbttagcompound.setInt("Size", this.getSize() - 1); - } - - public void a(NBTTagCompound nbttagcompound) { - super.a(nbttagcompound); - int i = nbttagcompound.getInt("Size"); - - if (i < 0) { - i = 0; - } - - this.setSize(i + 1); - } - - protected String bP() { - return "slime"; - } - - protected String bV() { - return "mob.slime." + (this.getSize() > 1 ? "big" : "small"); - } - - public void h() { - if (!this.world.isStatic && this.world.difficulty == EnumDifficulty.PEACEFUL && this.getSize() > 0) { - this.dead = true; - } - - this.i += (this.h - this.i) * 0.5F; - this.bm = this.i; - boolean flag = this.onGround; - - super.h(); - int i; - - if (this.onGround && !flag) { - i = this.getSize(); - - for (int j = 0; j < i * 8; ++j) { - float f = this.random.nextFloat() * 3.1415927F * 2.0F; - float f1 = this.random.nextFloat() * 0.5F + 0.5F; - float f2 = MathHelper.sin(f) * (float) i * 0.5F * f1; - float f3 = MathHelper.cos(f) * (float) i * 0.5F * f1; - - this.world.addParticle(this.bP(), this.locX + (double) f2, this.boundingBox.b, this.locZ + (double) f3, 0.0D, 0.0D, 0.0D); - } - - if (this.bW()) { - this.makeSound(this.bV(), this.bf(), ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F) / 0.8F); - } - - this.h = -0.5F; - } else if (!this.onGround && flag) { - this.h = 1.0F; - } - - this.bS(); - if (this.world.isStatic) { - i = this.getSize(); - this.a(0.6F * (float) i, 0.6F * (float) i); - } - } - - protected void bq() { - this.w(); - // CraftBukkit start - Entity entityhuman = this.world.findNearbyVulnerablePlayer(this, 16.0D); // EntityHuman -> Entity - EntityTargetEvent event = null; - - if (entityhuman != null && !entityhuman.equals(lastTarget)) { - event = CraftEventFactory.callEntityTargetEvent(this, entityhuman, EntityTargetEvent.TargetReason.CLOSEST_PLAYER); - } else if (lastTarget != null && entityhuman == null) { - event = CraftEventFactory.callEntityTargetEvent(this, entityhuman, EntityTargetEvent.TargetReason.FORGOT_TARGET); - } - - if (event != null && !event.isCancelled()) { - entityhuman = event.getTarget() == null ? null : ((CraftEntity) event.getTarget()).getHandle(); - } - - this.lastTarget = entityhuman; - // CraftBukkit end - - if (entityhuman != null) { - this.a(entityhuman, 10.0F, 20.0F); - } - - if (this.onGround && this.jumpDelay-- <= 0) { - this.jumpDelay = this.bR(); - if (entityhuman != null) { - this.jumpDelay /= 3; - } - - this.bc = true; - if (this.bY()) { - this.makeSound(this.bV(), this.bf(), ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F) * 0.8F); - } - - this.bd = 1.0F - this.random.nextFloat() * 2.0F; - this.be = (float) (1 * this.getSize()); - } else { - this.bc = false; - if (this.onGround) { - this.bd = this.be = 0.0F; - } - } - } - - protected void bS() { - this.h *= 0.6F; - } - - protected int bR() { - return this.random.nextInt(20) + 10; - } - - protected EntitySlime bQ() { - return new EntitySlime(this.world); - } - - public void die() { - int i = this.getSize(); - - if (!this.world.isStatic && i > 1 && this.getHealth() <= 0.0F) { - int j = 2 + this.random.nextInt(3); - - // CraftBukkit start - SlimeSplitEvent event = new SlimeSplitEvent((org.bukkit.entity.Slime) this.getBukkitEntity(), j); - this.world.getServer().getPluginManager().callEvent(event); - - if (!event.isCancelled() && event.getCount() > 0) { - j = event.getCount(); - } else { - super.die(); - return; - } - // CraftBukkit end - - for (int k = 0; k < j; ++k) { - float f = ((float) (k % 2) - 0.5F) * (float) i / 4.0F; - float f1 = ((float) (k / 2) - 0.5F) * (float) i / 4.0F; - EntitySlime entityslime = this.bQ(); - - entityslime.setSize(i / 2); - entityslime.setPositionRotation(this.locX + (double) f, this.locY + 0.5D, this.locZ + (double) f1, this.random.nextFloat() * 360.0F, 0.0F); - this.world.addEntity(entityslime, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SLIME_SPLIT); // CraftBukkit - SpawnReason - } - } - - super.die(); - } - - public void b_(EntityHuman entityhuman) { - if (this.bT()) { - int i = this.getSize(); - - if (this.hasLineOfSight(entityhuman) && this.f(entityhuman) < 0.6D * (double) i * 0.6D * (double) i && entityhuman.damageEntity(DamageSource.mobAttack(this), (float) this.bU())) { - this.makeSound("mob.attack", 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); - } - } - } - - protected boolean bT() { - return this.getSize() > 1; - } - - protected int bU() { - return this.getSize(); - } - - protected String aT() { - return "mob.slime." + (this.getSize() > 1 ? "big" : "small"); - } - - protected String aU() { - return "mob.slime." + (this.getSize() > 1 ? "big" : "small"); - } - - protected Item getLoot() { - return this.getSize() == 1 ? Items.SLIME_BALL : Item.getById(0); - } - - public boolean canSpawn() { - Chunk chunk = this.world.getChunkAtWorldCoords(MathHelper.floor(this.locX), MathHelper.floor(this.locZ)); - - if (this.world.getWorldData().getType() == WorldType.FLAT && this.random.nextInt(4) != 1) { - return false; - } else { - if (this.getSize() == 1 || this.world.difficulty != EnumDifficulty.PEACEFUL) { - BiomeBase biomebase = this.world.getBiome(MathHelper.floor(this.locX), MathHelper.floor(this.locZ)); - - if (biomebase == BiomeBase.SWAMPLAND && this.locY > 50.0D && this.locY < 70.0D && this.random.nextFloat() < 0.5F && this.random.nextFloat() < this.world.y() && 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 bf() { - return 0.4F * (float) this.getSize(); - } - - public int x() { - return 0; - } - - protected boolean bY() { - return this.getSize() > 0; - } - - protected boolean bW() { - return this.getSize() > 2; - } -} diff --git a/src/main/java/net/minecraft/server/EntitySmallFireball.java b/src/main/java/net/minecraft/server/EntitySmallFireball.java deleted file mode 100644 index 4d61eec2..00000000 --- a/src/main/java/net/minecraft/server/EntitySmallFireball.java +++ /dev/null @@ -1,85 +0,0 @@ -package net.minecraft.server; - -import org.bukkit.event.entity.EntityCombustByEntityEvent; // CraftBukkit - -public class EntitySmallFireball extends EntityFireball { - - public EntitySmallFireball(World world) { - super(world); - this.a(0.3125F, 0.3125F); - } - - public EntitySmallFireball(World world, EntityLiving entityliving, double d0, double d1, double d2) { - super(world, entityliving, d0, d1, d2); - this.a(0.3125F, 0.3125F); - } - - public EntitySmallFireball(World world, double d0, double d1, double d2, double d3, double d4, double d5) { - super(world, d0, d1, d2, d3, d4, d5); - this.a(0.3125F, 0.3125F); - } - - protected void a(MovingObjectPosition movingobjectposition) { - if (!this.world.isStatic) { - if (movingobjectposition.entity != null) { - if (!movingobjectposition.entity.isFireproof() && movingobjectposition.entity.damageEntity(DamageSource.fireball(this, this.shooter), 5.0F)) { - // CraftBukkit start - Entity damage by entity event + combust event - EntityCombustByEntityEvent event = new EntityCombustByEntityEvent((org.bukkit.entity.Projectile) this.getBukkitEntity(), movingobjectposition.entity.getBukkitEntity(), 5); - movingobjectposition.entity.world.getServer().getPluginManager().callEvent(event); - - if (!event.isCancelled()) { - movingobjectposition.entity.setOnFire(event.getDuration()); - } - // CraftBukkit end - } - } else { - int i = movingobjectposition.b; - int j = movingobjectposition.c; - int k = movingobjectposition.d; - - switch (movingobjectposition.face) { - case 0: - --j; - break; - - case 1: - ++j; - break; - - case 2: - --k; - break; - - case 3: - ++k; - break; - - case 4: - --i; - break; - - case 5: - ++i; - } - - if (this.world.isEmpty(i, j, k)) { - // CraftBukkit start - if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, i, j, k, this).isCancelled()) { - this.world.setTypeUpdate(i, j, k, Blocks.FIRE); - } - // CraftBukkit end - } - } - - this.die(); - } - } - - public boolean R() { - return false; - } - - public boolean damageEntity(DamageSource damagesource, float f) { - return false; - } -} diff --git a/src/main/java/net/minecraft/server/EntitySnowman.java b/src/main/java/net/minecraft/server/EntitySnowman.java deleted file mode 100644 index 2811fb46..00000000 --- a/src/main/java/net/minecraft/server/EntitySnowman.java +++ /dev/null @@ -1,89 +0,0 @@ -package net.minecraft.server; - -// CraftBukkit start -import org.bukkit.craftbukkit.event.CraftEventFactory; -import org.bukkit.craftbukkit.util.CraftMagicNumbers; -import org.bukkit.event.block.EntityBlockFormEvent; -// CraftBukkit end - -public class EntitySnowman extends EntityGolem implements IRangedEntity { - - public EntitySnowman(World world) { - super(world); - this.a(0.4F, 1.8F); - this.getNavigation().a(true); - this.goalSelector.a(1, new PathfinderGoalArrowAttack(this, 1.25D, 20, 10.0F)); - this.goalSelector.a(2, new PathfinderGoalRandomStroll(this, 1.0D)); - 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, EntityInsentient.class, 0, true, false, IMonster.a)); - } - - public boolean bk() { - return true; - } - - protected void aD() { - super.aD(); - this.getAttributeInstance(GenericAttributes.maxHealth).setValue(4.0D); - this.getAttributeInstance(GenericAttributes.d).setValue(0.20000000298023224D); - } - - public void e() { - super.e(); - int i = MathHelper.floor(this.locX); - int j = MathHelper.floor(this.locY); - int k = MathHelper.floor(this.locZ); - - if (this.L()) { - this.damageEntity(DamageSource.DROWN, 1.0F); - } - - if (this.world.getBiome(i, k).a(i, j, k) > 1.0F) { - this.damageEntity(CraftEventFactory.MELTING, 1.0F); // CraftBukkit - DamageSource.BURN -> CraftEventFactory.MELTING - } - - for (int l = 0; l < 4; ++l) { - i = MathHelper.floor(this.locX + (double) ((float) (l % 2 * 2 - 1) * 0.25F)); - j = MathHelper.floor(this.locY); - k = MathHelper.floor(this.locZ + (double) ((float) (l / 2 % 2 * 2 - 1) * 0.25F)); - if (this.world.getType(i, j, k).getMaterial() == Material.AIR && this.world.getBiome(i, k).a(i, j, k) < 0.8F && Blocks.SNOW.canPlace(this.world, i, j, k)) { - // CraftBukkit start - org.bukkit.block.BlockState blockState = this.world.getWorld().getBlockAt(i, j, k).getState(); - blockState.setType(CraftMagicNumbers.getMaterial(Blocks.SNOW)); - - EntityBlockFormEvent event = new EntityBlockFormEvent(this.getBukkitEntity(), blockState.getBlock(), blockState); - this.world.getServer().getPluginManager().callEvent(event); - - if(!event.isCancelled()) { - blockState.update(true); - } - // CraftBukkit end - } - } - } - - protected Item getLoot() { - return Items.SNOW_BALL; - } - - protected void dropDeathLoot(boolean flag, int i) { - int j = this.random.nextInt(16); - - for (int k = 0; k < j; ++k) { - this.a(Items.SNOW_BALL, 1); - } - } - - public void a(EntityLiving entityliving, float f) { - 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 f1 = MathHelper.sqrt(d0 * d0 + d2 * d2) * 0.2F; - - entitysnowball.shoot(d0, d1 + (double) f1, d2, 1.6F, 12.0F); - this.makeSound("random.bow", 1.0F, 1.0F / (this.aI().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 deleted file mode 100644 index 99704478..00000000 --- a/src/main/java/net/minecraft/server/EntitySpider.java +++ /dev/null @@ -1,162 +0,0 @@ -package net.minecraft.server; - -import org.bukkit.event.entity.EntityTargetEvent; // CraftBukkit - -public class EntitySpider extends EntityMonster { - - public EntitySpider(World world) { - super(world); - this.a(1.4F, 0.9F); - } - - protected void c() { - super.c(); - this.datawatcher.a(16, new Byte((byte) 0)); - } - - public void h() { - super.h(); - if (!this.world.isStatic) { - this.a(this.positionChanged); - } - } - - protected void aD() { - super.aD(); - this.getAttributeInstance(GenericAttributes.maxHealth).setValue(16.0D); - this.getAttributeInstance(GenericAttributes.d).setValue(0.800000011920929D); - } - - protected Entity findTarget() { - float f = this.d(1.0F); - - if (f < 0.5F) { - double d0 = 16.0D; - - return this.world.findNearbyVulnerablePlayer(this, d0); - } else { - return null; - } - } - - protected String t() { - return "mob.spider.say"; - } - - protected String aT() { - return "mob.spider.say"; - } - - protected String aU() { - return "mob.spider.death"; - } - - protected void a(int i, int j, int k, Block block) { - this.makeSound("mob.spider.step", 0.15F, 1.0F); - } - - protected void a(Entity entity, float f) { - float f1 = this.d(1.0F); - - if (f1 > 0.5F && this.random.nextInt(100) == 0) { - // CraftBukkit start - EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), null, EntityTargetEvent.TargetReason.FORGOT_TARGET); - this.world.getServer().getPluginManager().callEvent(event); - - if (!event.isCancelled()) { - if (event.getTarget() == null) { - this.target = null; - } else { - this.target = ((org.bukkit.craftbukkit.entity.CraftEntity) event.getTarget()).getHandle(); - } - return; - } - // CraftBukkit end - } else { - if (f > 2.0F && f < 6.0F && this.random.nextInt(10) == 0) { - if (this.onGround) { - double d0 = entity.locX - this.locX; - double d1 = entity.locZ - this.locZ; - float f2 = MathHelper.sqrt(d0 * d0 + d1 * d1); - - this.motX = d0 / (double) f2 * 0.5D * 0.800000011920929D + this.motX * 0.20000000298023224D; - this.motZ = d1 / (double) f2 * 0.5D * 0.800000011920929D + this.motZ * 0.20000000298023224D; - this.motY = 0.4000000059604645D; - } - } else { - super.a(entity, f); - } - } - } - - protected Item getLoot() { - return Items.STRING; - } - - protected void dropDeathLoot(boolean flag, int i) { - super.dropDeathLoot(flag, i); - if (flag && (this.random.nextInt(3) == 0 || this.random.nextInt(1 + i) > 0)) { - this.a(Items.SPIDER_EYE, 1); - } - } - - public boolean h_() { - return this.bZ(); - } - - public void as() {} - - public EnumMonsterType getMonsterType() { - return EnumMonsterType.ARTHROPOD; - } - - public boolean d(MobEffect mobeffect) { - return mobeffect.getEffectId() == MobEffectList.POISON.id ? false : super.d(mobeffect); - } - - public boolean bZ() { - return (this.datawatcher.getByte(16) & 1) != 0; - } - - public void a(boolean flag) { - byte b0 = this.datawatcher.getByte(16); - - if (flag) { - b0 = (byte) (b0 | 1); - } else { - b0 &= -2; - } - - this.datawatcher.watch(16, Byte.valueOf(b0)); - } - - public GroupDataEntity prepare(GroupDataEntity groupdataentity) { - Object object = super.prepare(groupdataentity); - - 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.prepare((GroupDataEntity) null); - this.world.addEntity(entityskeleton, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.JOCKEY); // CraftBukkit - add SpawnReason - entityskeleton.mount(this); - } - - if (object == null) { - object = new GroupDataSpider(); - if (this.world.difficulty == EnumDifficulty.HARD && this.world.random.nextFloat() < 0.1F * this.world.b(this.locX, this.locY, this.locZ)) { - ((GroupDataSpider) object).a(this.world.random); - } - } - - if (object instanceof GroupDataSpider) { - int i = ((GroupDataSpider) object).a; - - if (i > 0 && MobEffectList.byId[i] != null) { - this.addEffect(new MobEffect(i, Integer.MAX_VALUE)); - } - } - - return (GroupDataEntity) object; - } -} diff --git a/src/main/java/net/minecraft/server/EntitySquid.java b/src/main/java/net/minecraft/server/EntitySquid.java deleted file mode 100644 index 6e6d612b..00000000 --- a/src/main/java/net/minecraft/server/EntitySquid.java +++ /dev/null @@ -1,151 +0,0 @@ -package net.minecraft.server; - -import org.bukkit.craftbukkit.TrigMath; // CraftBukkit - -public class EntitySquid extends EntityWaterAnimal { - - public float bp; - public float bq; - public float br; - public float bs; - public float bt; - public float bu; - public float bv; - public float bw; - private float bx; - private float by; - private float bz; - private float bA; - private float bB; - private float bC; - - public EntitySquid(World world) { - super(world); - this.a(0.95F, 0.95F); - this.by = 1.0F / (this.random.nextFloat() + 1.0F) * 0.2F; - } - - protected void aD() { - super.aD(); - this.getAttributeInstance(GenericAttributes.maxHealth).setValue(10.0D); - } - - protected String t() { - return null; - } - - protected String aT() { - return null; - } - - protected String aU() { - return null; - } - - protected float bf() { - return 0.4F; - } - - protected Item getLoot() { - return Item.getById(0); - } - - protected boolean g_() { - return false; - } - - protected void dropDeathLoot(boolean flag, int i) { - int j = this.random.nextInt(3 + i) + 1; - - for (int k = 0; k < j; ++k) { - this.a(new ItemStack(Items.INK_SACK, 1, 0), 0.0F); - } - } - - /* CraftBukkit start - Delegate to Entity to use existing inWater value - public boolean M() { - return this.world.a(this.boundingBox.grow(0.0D, -0.6000000238418579D, 0.0D), Material.WATER, (Entity) this); - } - // CraftBukkit end */ - - public void e() { - super.e(); - this.bq = this.bp; - this.bs = this.br; - this.bu = this.bt; - this.bw = this.bv; - this.bt += this.by; - if (this.bt > 6.2831855F) { - this.bt -= 6.2831855F; - if (this.random.nextInt(10) == 0) { - this.by = 1.0F / (this.random.nextFloat() + 1.0F) * 0.2F; - } - } - - if (this.M()) { - float f; - - if (this.bt < 3.1415927F) { - f = this.bt / 3.1415927F; - this.bv = MathHelper.sin(f * f * 3.1415927F) * 3.1415927F * 0.25F; - if ((double) f > 0.75D) { - this.bx = 1.0F; - this.bz = 1.0F; - } else { - this.bz *= 0.8F; - } - } else { - this.bv = 0.0F; - this.bx *= 0.9F; - this.bz *= 0.99F; - } - - if (!this.world.isStatic) { - this.motX = (double) (this.bA * this.bx); - this.motY = (double) (this.bB * this.bx); - this.motZ = (double) (this.bC * this.bx); - } - - f = MathHelper.sqrt(this.motX * this.motX + this.motZ * this.motZ); - // CraftBukkit - Math -> TrigMath - this.aM += (-((float) TrigMath.atan2(this.motX, this.motZ)) * 180.0F / 3.1415927F - this.aM) * 0.1F; - this.yaw = this.aM; - this.br += 3.1415927F * this.bz * 1.5F; - // CraftBukkit - Math -> TrigMath - this.bp += (-((float) TrigMath.atan2((double) f, this.motY)) * 180.0F / 3.1415927F - this.bp) * 0.1F; - } else { - this.bv = MathHelper.abs(MathHelper.sin(this.bt)) * 3.1415927F * 0.25F; - if (!this.world.isStatic) { - this.motX = 0.0D; - this.motY -= 0.08D; - this.motY *= 0.9800000190734863D; - this.motZ = 0.0D; - } - - this.bp = (float) ((double) this.bp + (double) (-90.0F - this.bp) * 0.02D); - } - } - - public void e(float f, float f1) { - this.move(this.motX, this.motY, this.motZ); - } - - protected void bq() { - ++this.aU; - if (this.aU > 100) { - this.bA = this.bB = this.bC = 0.0F; - } else if (this.random.nextInt(50) == 0 || !this.inWater || this.bA == 0.0F && this.bB == 0.0F && this.bC == 0.0F) { - float f = this.random.nextFloat() * 3.1415927F * 2.0F; - - this.bA = MathHelper.cos(f) * 0.2F; - this.bB = -0.1F + this.random.nextFloat() * 0.2F; - this.bC = MathHelper.sin(f) * 0.2F; - } - - this.w(); - } - - public boolean canSpawn() { - return this.locY > 45.0D && this.locY < 63.0D && super.canSpawn(); - } -} diff --git a/src/main/java/net/minecraft/server/EntityTNTPrimed.java b/src/main/java/net/minecraft/server/EntityTNTPrimed.java deleted file mode 100644 index 13cbc79b..00000000 --- a/src/main/java/net/minecraft/server/EntityTNTPrimed.java +++ /dev/null @@ -1,98 +0,0 @@ -package net.minecraft.server; - -import org.bukkit.event.entity.ExplosionPrimeEvent; // CraftBukkit - -public class EntityTNTPrimed extends Entity { - - public int fuseTicks; - private EntityLiving source; - public float yield = 4; // CraftBukkit - add field - public boolean isIncendiary = false; // CraftBukkit - add field - - public EntityTNTPrimed(World world) { - super(world); - this.k = true; - this.a(0.98F, 0.98F); - this.height = this.length / 2.0F; - } - - public EntityTNTPrimed(World world, double d0, double d1, double d2, EntityLiving entityliving) { - this(world); - this.setPosition(d0, d1, d2); - float f = (float) (Math.random() * 3.1415927410125732D * 2.0D); - - this.motX = (double) (-((float) Math.sin((double) f)) * 0.02F); - this.motY = 0.20000000298023224D; - this.motZ = (double) (-((float) Math.cos((double) f)) * 0.02F); - this.fuseTicks = 80; - this.lastX = d0; - this.lastY = d1; - this.lastZ = d2; - this.source = entityliving; - } - - protected void c() {} - - protected boolean g_() { - return false; - } - - public boolean R() { - return !this.dead; - } - - public void h() { - this.lastX = this.locX; - this.lastY = this.locY; - this.lastZ = this.locZ; - this.motY -= 0.03999999910593033D; - this.move(this.motX, this.motY, this.motZ); - this.motX *= 0.9800000190734863D; - this.motY *= 0.9800000190734863D; - this.motZ *= 0.9800000190734863D; - if (this.onGround) { - this.motX *= 0.699999988079071D; - this.motZ *= 0.699999988079071D; - this.motY *= -0.5D; - } - - if (this.fuseTicks-- <= 0) { - // CraftBukkit start - Need to reverse the order of the explosion and the entity death so we have a location for the event - if (!this.world.isStatic) { - this.explode(); - } - this.die(); - // CraftBukkit end - } else { - this.world.addParticle("smoke", this.locX, this.locY + 0.5D, this.locZ, 0.0D, 0.0D, 0.0D); - } - } - - private void explode() { - // CraftBukkit start - // float f = 4.0F; - - org.bukkit.craftbukkit.CraftServer server = this.world.getServer(); - - ExplosionPrimeEvent event = new ExplosionPrimeEvent((org.bukkit.entity.Explosive) org.bukkit.craftbukkit.entity.CraftEntity.getEntity(server, this)); - server.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(), true); - } - // CraftBukkit end - } - - protected void b(NBTTagCompound nbttagcompound) { - nbttagcompound.setByte("Fuse", (byte) this.fuseTicks); - } - - protected void a(NBTTagCompound nbttagcompound) { - this.fuseTicks = nbttagcompound.getByte("Fuse"); - } - - public EntityLiving getSource() { - return this.source; - } -} diff --git a/src/main/java/net/minecraft/server/EntityThrownExpBottle.java b/src/main/java/net/minecraft/server/EntityThrownExpBottle.java deleted file mode 100644 index 68625a48..00000000 --- a/src/main/java/net/minecraft/server/EntityThrownExpBottle.java +++ /dev/null @@ -1,53 +0,0 @@ -package net.minecraft.server; - -public class EntityThrownExpBottle extends EntityProjectile { - - public EntityThrownExpBottle(World world) { - super(world); - } - - public EntityThrownExpBottle(World world, EntityLiving entityliving) { - super(world, entityliving); - } - - public EntityThrownExpBottle(World world, double d0, double d1, double d2) { - super(world, d0, d1, d2); - } - - protected float i() { - return 0.07F; - } - - protected float e() { - return 0.7F; - } - - protected float f() { - return -20.0F; - } - - protected void a(MovingObjectPosition movingobjectposition) { - if (!this.world.isStatic) { - // CraftBukkit - moved to after event - // this.world.triggerEffect(2002, (int) Math.round(this.locX), (int) Math.round(this.locY), (int) Math.round(this.locZ), 0); - int i = 3 + this.world.random.nextInt(5) + this.world.random.nextInt(5); - - // CraftBukkit start - org.bukkit.event.entity.ExpBottleEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callExpBottleEvent(this, i); - i = event.getExperience(); - if (event.getShowEffect()) { - this.world.triggerEffect(2002, (int) Math.round(this.locX), (int) Math.round(this.locY), (int) Math.round(this.locZ), 0); - } - // CraftBukkit end - - while (i > 0) { - int j = EntityExperienceOrb.getOrbValue(i); - - i -= j; - this.world.addEntity(new EntityExperienceOrb(this.world, this.locX, this.locY, this.locZ, j)); - } - - this.die(); - } - } -} diff --git a/src/main/java/net/minecraft/server/EntityTracker.java b/src/main/java/net/minecraft/server/EntityTracker.java deleted file mode 100644 index 1af0e67e..00000000 --- a/src/main/java/net/minecraft/server/EntityTracker.java +++ /dev/null @@ -1,211 +0,0 @@ -package net.minecraft.server; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; -import java.util.concurrent.Callable; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -public class EntityTracker { - - private static final Logger a = LogManager.getLogger(); - private final WorldServer world; - private Set c = new HashSet(); - public IntHashMap trackedEntities = new IntHashMap(); // CraftBukkit - private -> public - private int e; - - public EntityTracker(WorldServer worldserver) { - this.world = worldserver; - this.e = worldserver.getMinecraftServer().getPlayerList().d(); - } - - public void track(Entity entity) { - if (entity instanceof EntityPlayer) { - this.addEntity(entity, 512, 2); - EntityPlayer entityplayer = (EntityPlayer) entity; - Iterator iterator = this.c.iterator(); - - while (iterator.hasNext()) { - EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry) iterator.next(); - - if (entitytrackerentry.tracker != entityplayer) { - entitytrackerentry.updatePlayer(entityplayer); - } - } - } else if (entity instanceof EntityFishingHook) { - this.addEntity(entity, 64, 5, true); - } else if (entity instanceof EntityArrow) { - this.addEntity(entity, 64, 20, false); - } else if (entity instanceof EntitySmallFireball) { - this.addEntity(entity, 64, 10, false); - } else if (entity instanceof EntityFireball) { - this.addEntity(entity, 64, 10, false); - } else if (entity instanceof EntitySnowball) { - this.addEntity(entity, 64, 10, true); - } else if (entity instanceof EntityEnderPearl) { - this.addEntity(entity, 64, 10, true); - } else if (entity instanceof EntityEnderSignal) { - this.addEntity(entity, 64, 4, true); - } else if (entity instanceof EntityEgg) { - this.addEntity(entity, 64, 10, true); - } else if (entity instanceof EntityPotion) { - this.addEntity(entity, 64, 10, true); - } else if (entity instanceof EntityThrownExpBottle) { - this.addEntity(entity, 64, 10, true); - } else if (entity instanceof EntityFireworks) { - this.addEntity(entity, 64, 10, true); - } else if (entity instanceof EntityItem) { - this.addEntity(entity, 64, 20, true); - } else if (entity instanceof EntityMinecartAbstract) { - this.addEntity(entity, 80, 3, true); - } else if (entity instanceof EntityBoat) { - 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) { - this.addEntity(entity, 160, 3, true); - } else if (entity instanceof EntityTNTPrimed) { - this.addEntity(entity, 160, 10, true); - } else if (entity instanceof EntityFallingBlock) { - this.addEntity(entity, 160, 20, true); - } else if (entity instanceof EntityHanging) { - this.addEntity(entity, 160, Integer.MAX_VALUE, false); - } else if (entity instanceof EntityExperienceOrb) { - this.addEntity(entity, 160, 20, true); - } else if (entity instanceof EntityEnderCrystal) { - this.addEntity(entity, 256, Integer.MAX_VALUE, false); - } - } - - public void addEntity(Entity entity, int i, int j) { - this.addEntity(entity, i, j, false); - } - - public void addEntity(Entity entity, int i, int j, boolean flag) { - if (i > this.e) { - i = this.e; - } - - try { - if (this.trackedEntities.b(entity.getId())) { - throw new IllegalStateException("Entity is already tracked!"); - } - - EntityTrackerEntry entitytrackerentry = new EntityTrackerEntry(entity, i, j, flag); - - this.c.add(entitytrackerentry); - this.trackedEntities.a(entity.getId(), entitytrackerentry); - entitytrackerentry.scanPlayers(this.world.players); - } catch (Throwable throwable) { - CrashReport crashreport = CrashReport.a(throwable, "Adding entity to track"); - CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Entity To Track"); - - crashreportsystemdetails.a("Tracking range", (i + " blocks")); - crashreportsystemdetails.a("Update interval", (Callable) (new CrashReportEntityTrackerUpdateInterval(this, j))); - entity.a(crashreportsystemdetails); - CrashReportSystemDetails crashreportsystemdetails1 = crashreport.a("Entity That Is Already Tracked"); - - ((EntityTrackerEntry) this.trackedEntities.get(entity.getId())).tracker.a(crashreportsystemdetails1); - - try { - throw new ReportedException(crashreport); - } catch (ReportedException reportedexception) { - a.error("\"Silently\" catching entity tracking error.", reportedexception); - } - } - } - - public void untrackEntity(Entity entity) { - if (entity instanceof EntityPlayer) { - EntityPlayer entityplayer = (EntityPlayer) entity; - Iterator iterator = this.c.iterator(); - - while (iterator.hasNext()) { - EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry) iterator.next(); - - entitytrackerentry.a(entityplayer); - } - } - - EntityTrackerEntry entitytrackerentry1 = (EntityTrackerEntry) this.trackedEntities.d(entity.getId()); - - if (entitytrackerentry1 != null) { - this.c.remove(entitytrackerentry1); - entitytrackerentry1.a(); - } - } - - public void updatePlayers() { - ArrayList arraylist = new ArrayList(); - Iterator iterator = this.c.iterator(); - - while (iterator.hasNext()) { - EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry) iterator.next(); - - entitytrackerentry.track(this.world.players); - if (entitytrackerentry.n && entitytrackerentry.tracker instanceof EntityPlayer) { - arraylist.add((EntityPlayer) entitytrackerentry.tracker); - } - } - - for (int i = 0; i < arraylist.size(); ++i) { - EntityPlayer entityplayer = (EntityPlayer) arraylist.get(i); - Iterator iterator1 = this.c.iterator(); - - while (iterator1.hasNext()) { - EntityTrackerEntry entitytrackerentry1 = (EntityTrackerEntry) iterator1.next(); - - if (entitytrackerentry1.tracker != entityplayer) { - entitytrackerentry1.updatePlayer(entityplayer); - } - } - } - } - - public void a(Entity entity, Packet packet) { - EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry) this.trackedEntities.get(entity.getId()); - - if (entitytrackerentry != null) { - entitytrackerentry.broadcast(packet); - } - } - - public void sendPacketToEntity(Entity entity, Packet packet) { - EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry) this.trackedEntities.get(entity.getId()); - - if (entitytrackerentry != null) { - entitytrackerentry.broadcastIncludingSelf(packet); - } - } - - public void untrackPlayer(EntityPlayer entityplayer) { - Iterator iterator = this.c.iterator(); - - while (iterator.hasNext()) { - EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry) iterator.next(); - - entitytrackerentry.clear(entityplayer); - } - } - - public void a(EntityPlayer entityplayer, Chunk chunk) { - Iterator iterator = this.c.iterator(); - - while (iterator.hasNext()) { - EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry) iterator.next(); - - if (entitytrackerentry.tracker != entityplayer && entitytrackerentry.tracker.ah == chunk.locX && entitytrackerentry.tracker.aj == chunk.locZ) { - entitytrackerentry.updatePlayer(entityplayer); - } - } - } -} diff --git a/src/main/java/net/minecraft/server/EntityTrackerEntry.java b/src/main/java/net/minecraft/server/EntityTrackerEntry.java deleted file mode 100644 index 0cf9ad5b..00000000 --- a/src/main/java/net/minecraft/server/EntityTrackerEntry.java +++ /dev/null @@ -1,523 +0,0 @@ -package net.minecraft.server; - -import java.util.Collection; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -// CraftBukkit start -import org.bukkit.entity.Player; -import org.bukkit.event.player.PlayerVelocityEvent; -// CraftBukkit end - -public class EntityTrackerEntry { - - private static final Logger p = LogManager.getLogger(); - public Entity tracker; - public int b; - public int c; - public int xLoc; - public int yLoc; - public int zLoc; - public int yRot; - public int xRot; - public int i; - public double j; - public double k; - public double l; - public int m; - private double q; - private double r; - private double s; - private boolean isMoving; - private boolean u; - private int v; - private Entity w; - private boolean x; - public boolean n; - public Set trackedPlayers = new HashSet(); - - public EntityTrackerEntry(Entity entity, int i, int j, boolean flag) { - this.tracker = entity; - this.b = i; - this.c = j; - this.u = flag; - this.xLoc = MathHelper.floor(entity.locX * 32.0D); - this.yLoc = MathHelper.floor(entity.locY * 32.0D); - 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.getHeadRotation() * 256.0F / 360.0F); - } - - public boolean equals(Object object) { - return object instanceof EntityTrackerEntry ? ((EntityTrackerEntry) object).tracker.getId() == this.tracker.getId() : false; - } - - public int hashCode() { - return this.tracker.getId(); - } - - public void track(List list) { - this.n = false; - if (!this.isMoving || this.tracker.e(this.q, this.r, this.s) > 16.0D) { - this.q = this.tracker.locX; - this.r = this.tracker.locY; - this.s = this.tracker.locZ; - this.isMoving = true; - this.n = true; - this.scanPlayers(list); - } - - if (this.w != this.tracker.vehicle || this.tracker.vehicle != null && this.m % 60 == 0) { - this.w = this.tracker.vehicle; - this.broadcast(new PacketPlayOutAttachEntity(0, this.tracker, this.tracker.vehicle)); - } - - if (this.tracker instanceof EntityItemFrame /*&& this.m % 10 == 0*/) { // CraftBukkit - Moved below, should always enter this block - EntityItemFrame i3 = (EntityItemFrame) this.tracker; - ItemStack i4 = i3.getItem(); - - if (this.m % 10 == 0 && i4 != null && i4.getItem() instanceof ItemWorldMap) { // CraftBukkit - Moved this.m % 10 logic here so item frames do not enter the other blocks - WorldMap i6 = Items.MAP.getSavedMap(i4, this.tracker.world); - Iterator i7 = this.trackedPlayers.iterator(); // CraftBukkit - - while (i7.hasNext()) { - EntityHuman i8 = (EntityHuman) i7.next(); - EntityPlayer i9 = (EntityPlayer) i8; - - i6.a(i9, i4); - Packet j0 = Items.MAP.c(i4, this.tracker.world, i9); - - if (j0 != null) { - i9.playerConnection.sendPacket(j0); - } - } - } - - this.b(); - } else if (this.m % this.c == 0 || this.tracker.al || this.tracker.getDataWatcher().a()) { - int i; - int j; - - if (this.tracker.vehicle == null) { - ++this.v; - i = this.tracker.as.a(this.tracker.locX); - j = MathHelper.floor(this.tracker.locY * 32.0D); - int k = this.tracker.as.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 || this.m % 60 == 0; - boolean flag1 = Math.abs(l - this.yRot) >= 4 || Math.abs(i1 - this.xRot) >= 4; - - // CraftBukkit start - Code moved from below - if (flag) { - this.xLoc = i; - this.yLoc = j; - this.zLoc = k; - } - - if (flag1) { - this.yRot = l; - this.xRot = i1; - } - // CraftBukkit end - - if (this.m > 0 || this.tracker instanceof EntityArrow) { - if (j1 >= -128 && j1 < 128 && k1 >= -128 && k1 < 128 && l1 >= -128 && l1 < 128 && this.v <= 400 && !this.x) { - if (flag && flag1) { - object = new PacketPlayOutRelEntityMoveLook(this.tracker.getId(), (byte) j1, (byte) k1, (byte) l1, (byte) l, (byte) i1); - } else if (flag) { - object = new PacketPlayOutRelEntityMove(this.tracker.getId(), (byte) j1, (byte) k1, (byte) l1); - } else if (flag1) { - object = new PacketPlayOutEntityLook(this.tracker.getId(), (byte) l, (byte) i1); - } - } else { - this.v = 0; - // CraftBukkit start - Refresh list of who can see a player before sending teleport packet - if (this.tracker instanceof EntityPlayer) { - this.scanPlayers(new java.util.ArrayList(this.trackedPlayers)); - } - // CraftBukkit end - object = new PacketPlayOutEntityTeleport(this.tracker.getId(), i, j, k, (byte) l, (byte) i1); - } - } - - if (this.u) { - double d0 = this.tracker.motX - this.j; - double d1 = this.tracker.motY - this.k; - double d2 = this.tracker.motZ - this.l; - double d3 = 0.02D; - double d4 = d0 * d0 + d1 * d1 + d2 * d2; - - if (d4 > d3 * d3 || d4 > 0.0D && this.tracker.motX == 0.0D && this.tracker.motY == 0.0D && this.tracker.motZ == 0.0D) { - this.j = this.tracker.motX; - this.k = this.tracker.motY; - this.l = this.tracker.motZ; - this.broadcast(new PacketPlayOutEntityVelocity(this.tracker.getId(), this.j, this.k, this.l)); - } - } - - if (object != null) { - this.broadcast((Packet) object); - } - - this.b(); - /* CraftBukkit start - Code moved up - if (flag) { - this.xLoc = i; - this.yLoc = j; - this.zLoc = k; - } - - if (flag1) { - this.yRot = l; - this.xRot = i1; - } - // CraftBukkit end */ - - this.x = false; - } 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 PacketPlayOutEntityLook(this.tracker.getId(), (byte) i, (byte) j)); - this.yRot = i; - this.xRot = j; - } - - this.xLoc = this.tracker.as.a(this.tracker.locX); - this.yLoc = MathHelper.floor(this.tracker.locY * 32.0D); - this.zLoc = this.tracker.as.a(this.tracker.locZ); - this.b(); - this.x = true; - } - - i = MathHelper.d(this.tracker.getHeadRotation() * 256.0F / 360.0F); - if (Math.abs(i - this.i) >= 4) { - this.broadcast(new PacketPlayOutEntityHeadRotation(this.tracker, (byte) i)); - this.i = i; - } - - this.tracker.al = false; - } - - ++this.m; - if (this.tracker.velocityChanged) { - // CraftBukkit start - Create PlayerVelocity event - boolean cancelled = false; - - if (this.tracker instanceof EntityPlayer) { - Player player = (Player) this.tracker.getBukkitEntity(); - org.bukkit.util.Vector velocity = player.getVelocity(); - - PlayerVelocityEvent event = new PlayerVelocityEvent(player, velocity); - this.tracker.world.getServer().getPluginManager().callEvent(event); - - if (event.isCancelled()) { - cancelled = true; - } else if (!velocity.equals(event.getVelocity())) { - player.setVelocity(velocity); - } - } - - if (!cancelled) { - this.broadcastIncludingSelf((Packet) (new PacketPlayOutEntityVelocity(this.tracker))); - } - // CraftBukkit end - - this.tracker.velocityChanged = false; - } - } - - private void b() { - DataWatcher datawatcher = this.tracker.getDataWatcher(); - - if (datawatcher.a()) { - this.broadcastIncludingSelf(new PacketPlayOutEntityMetadata(this.tracker.getId(), datawatcher, false)); - } - - if (this.tracker instanceof EntityLiving) { - AttributeMapServer attributemapserver = (AttributeMapServer) ((EntityLiving) this.tracker).getAttributeMap(); - Set set = attributemapserver.getAttributes(); - - if (!set.isEmpty()) { - // CraftBukkit start - Send scaled max health - if (this.tracker instanceof EntityPlayer) { - ((EntityPlayer) this.tracker).getBukkitEntity().injectScaledMaxHealth(set, false); - } - // CraftBukkit end - this.broadcastIncludingSelf(new PacketPlayOutUpdateAttributes(this.tracker.getId(), set)); - } - - set.clear(); - } - } - - public void broadcast(Packet packet) { - Iterator iterator = this.trackedPlayers.iterator(); - - while (iterator.hasNext()) { - EntityPlayer entityplayer = (EntityPlayer) iterator.next(); - - entityplayer.playerConnection.sendPacket(packet); - } - } - - public void broadcastIncludingSelf(Packet packet) { - this.broadcast(packet); - if (this.tracker instanceof EntityPlayer) { - ((EntityPlayer) this.tracker).playerConnection.sendPacket(packet); - } - } - - public void a() { - Iterator iterator = this.trackedPlayers.iterator(); - - while (iterator.hasNext()) { - EntityPlayer entityplayer = (EntityPlayer) iterator.next(); - - entityplayer.d(this.tracker); - } - } - - public void a(EntityPlayer entityplayer) { - if (this.trackedPlayers.contains(entityplayer)) { - entityplayer.d(this.tracker); - this.trackedPlayers.remove(entityplayer); - } - } - - public void updatePlayer(EntityPlayer entityplayer) { - if (entityplayer != this.tracker) { - double d0 = entityplayer.locX - (double) (this.xLoc / 32); - double d1 = entityplayer.locZ - (double) (this.zLoc / 32); - - if (d0 >= (double) (-this.b) && d0 <= (double) this.b && d1 >= (double) (-this.b) && d1 <= (double) this.b) { - if (!this.trackedPlayers.contains(entityplayer) && (this.d(entityplayer) || this.tracker.attachedToPlayer)) { - // CraftBukkit start - respect vanish API - if (this.tracker instanceof EntityPlayer) { - Player player = ((EntityPlayer) this.tracker).getBukkitEntity(); - if (!entityplayer.getBukkitEntity().canSee(player)) { - return; - } - } - - entityplayer.removeQueue.remove(Integer.valueOf(this.tracker.getId())); - // CraftBukkit end - - this.trackedPlayers.add(entityplayer); - Packet packet = this.c(); - - entityplayer.playerConnection.sendPacket(packet); - if (!this.tracker.getDataWatcher().d()) { - entityplayer.playerConnection.sendPacket(new PacketPlayOutEntityMetadata(this.tracker.getId(), this.tracker.getDataWatcher(), true)); - } - - if (this.tracker instanceof EntityLiving) { - AttributeMapServer attributemapserver = (AttributeMapServer) ((EntityLiving) this.tracker).getAttributeMap(); - Collection collection = attributemapserver.c(); - - // CraftBukkit start - If sending own attributes send scaled health instead of current maximum health - if (this.tracker.getId() == entityplayer.getId()) { - ((EntityPlayer) this.tracker).getBukkitEntity().injectScaledMaxHealth(collection, false); - } - // CraftBukkit end - if (!collection.isEmpty()) { - entityplayer.playerConnection.sendPacket(new PacketPlayOutUpdateAttributes(this.tracker.getId(), collection)); - } - } - - this.j = this.tracker.motX; - this.k = this.tracker.motY; - this.l = this.tracker.motZ; - if (this.u && !(packet instanceof PacketPlayOutSpawnEntityLiving)) { - entityplayer.playerConnection.sendPacket(new PacketPlayOutEntityVelocity(this.tracker.getId(), this.tracker.motX, this.tracker.motY, this.tracker.motZ)); - } - - if (this.tracker.vehicle != null) { - entityplayer.playerConnection.sendPacket(new PacketPlayOutAttachEntity(0, this.tracker, this.tracker.vehicle)); - } - - // CraftBukkit start - if (this.tracker.passenger != null) { - entityplayer.playerConnection.sendPacket(new PacketPlayOutAttachEntity(0, this.tracker.passenger, this.tracker)); - } - // CraftBukkit end - - if (this.tracker instanceof EntityInsentient && ((EntityInsentient) this.tracker).getLeashHolder() != null) { - entityplayer.playerConnection.sendPacket(new PacketPlayOutAttachEntity(1, this.tracker, ((EntityInsentient) this.tracker).getLeashHolder())); - } - - if (this.tracker instanceof EntityLiving) { - for (int i = 0; i < 5; ++i) { - ItemStack itemstack = ((EntityLiving) this.tracker).getEquipment(i); - - if (itemstack != null) { - entityplayer.playerConnection.sendPacket(new PacketPlayOutEntityEquipment(this.tracker.getId(), i, itemstack)); - } - } - } - - if (this.tracker instanceof EntityHuman) { - EntityHuman entityhuman = (EntityHuman) this.tracker; - - if (entityhuman.isSleeping()) { - entityplayer.playerConnection.sendPacket(new PacketPlayOutBed(entityhuman, MathHelper.floor(this.tracker.locX), MathHelper.floor(this.tracker.locY), MathHelper.floor(this.tracker.locZ))); - } - } - - // CraftBukkit start - Fix for nonsensical head yaw - this.i = MathHelper.d(this.tracker.getHeadRotation() * 256.0F / 360.0F); - this.broadcast(new PacketPlayOutEntityHeadRotation(this.tracker, (byte) i)); - // CraftBukkit end - - if (this.tracker instanceof EntityLiving) { - EntityLiving entityliving = (EntityLiving) this.tracker; - Iterator iterator = entityliving.getEffects().iterator(); - - while (iterator.hasNext()) { - MobEffect mobeffect = (MobEffect) iterator.next(); - - entityplayer.playerConnection.sendPacket(new PacketPlayOutEntityEffect(this.tracker.getId(), mobeffect)); - } - } - } - } else if (this.trackedPlayers.contains(entityplayer)) { - this.trackedPlayers.remove(entityplayer); - entityplayer.d(this.tracker); - } - } - } - - private boolean d(EntityPlayer entityplayer) { - return entityplayer.r().getPlayerChunkMap().a(entityplayer, this.tracker.ah, this.tracker.aj); - } - - public void scanPlayers(List list) { - for (int i = 0; i < list.size(); ++i) { - this.updatePlayer((EntityPlayer) list.get(i)); - } - } - - private Packet c() { - if (this.tracker.dead) { - // CraftBukkit start - Remove useless error spam, just return - // p.warn("Fetching addPacket for removed entity"); - return null; - // CraftBukkit end - } - - if (this.tracker instanceof EntityItem) { - return new PacketPlayOutSpawnEntity(this.tracker, 2, 1); - } else if (this.tracker instanceof EntityPlayer) { - return new PacketPlayOutNamedEntitySpawn((EntityHuman) this.tracker); - } else if (this.tracker instanceof EntityMinecartAbstract) { - EntityMinecartAbstract entityminecartabstract = (EntityMinecartAbstract) this.tracker; - - return new PacketPlayOutSpawnEntity(this.tracker, 10, entityminecartabstract.m()); - } else if (this.tracker instanceof EntityBoat) { - return new PacketPlayOutSpawnEntity(this.tracker, 1); - } else if (!(this.tracker instanceof IAnimal) && !(this.tracker instanceof EntityEnderDragon)) { - if (this.tracker instanceof EntityFishingHook) { - EntityHuman entityhuman = ((EntityFishingHook) this.tracker).owner; - - return new PacketPlayOutSpawnEntity(this.tracker, 90, entityhuman != null ? entityhuman.getId() : this.tracker.getId()); - } else if (this.tracker instanceof EntityArrow) { - Entity entity = ((EntityArrow) this.tracker).shooter; - - return new PacketPlayOutSpawnEntity(this.tracker, 60, entity != null ? entity.getId() : this.tracker.getId()); - } else if (this.tracker instanceof EntitySnowball) { - return new PacketPlayOutSpawnEntity(this.tracker, 61); - } else if (this.tracker instanceof EntityPotion) { - return new PacketPlayOutSpawnEntity(this.tracker, 73, ((EntityPotion) this.tracker).getPotionValue()); - } else if (this.tracker instanceof EntityThrownExpBottle) { - return new PacketPlayOutSpawnEntity(this.tracker, 75); - } else if (this.tracker instanceof EntityEnderPearl) { - return new PacketPlayOutSpawnEntity(this.tracker, 65); - } else if (this.tracker instanceof EntityEnderSignal) { - return new PacketPlayOutSpawnEntity(this.tracker, 72); - } else if (this.tracker instanceof EntityFireworks) { - return new PacketPlayOutSpawnEntity(this.tracker, 76); - } else { - PacketPlayOutSpawnEntity packetplayoutspawnentity; - - if (this.tracker instanceof EntityFireball) { - EntityFireball entityfireball = (EntityFireball) this.tracker; - - packetplayoutspawnentity = null; - byte b0 = 63; - - if (this.tracker instanceof EntitySmallFireball) { - b0 = 64; - } else if (this.tracker instanceof EntityWitherSkull) { - b0 = 66; - } - - if (entityfireball.shooter != null) { - packetplayoutspawnentity = new PacketPlayOutSpawnEntity(this.tracker, b0, ((EntityFireball) this.tracker).shooter.getId()); - } else { - packetplayoutspawnentity = new PacketPlayOutSpawnEntity(this.tracker, b0, 0); - } - - packetplayoutspawnentity.d((int) (entityfireball.dirX * 8000.0D)); - packetplayoutspawnentity.e((int) (entityfireball.dirY * 8000.0D)); - packetplayoutspawnentity.f((int) (entityfireball.dirZ * 8000.0D)); - return packetplayoutspawnentity; - } else if (this.tracker instanceof EntityEgg) { - return new PacketPlayOutSpawnEntity(this.tracker, 62); - } else if (this.tracker instanceof EntityTNTPrimed) { - return new PacketPlayOutSpawnEntity(this.tracker, 50); - } else if (this.tracker instanceof EntityEnderCrystal) { - return new PacketPlayOutSpawnEntity(this.tracker, 51); - } else if (this.tracker instanceof EntityFallingBlock) { - EntityFallingBlock entityfallingblock = (EntityFallingBlock) this.tracker; - - return new PacketPlayOutSpawnEntity(this.tracker, 70, Block.getId(entityfallingblock.f()) | entityfallingblock.data << 16); - } else if (this.tracker instanceof EntityPainting) { - return new PacketPlayOutSpawnEntityPainting((EntityPainting) this.tracker); - } else if (this.tracker instanceof EntityItemFrame) { - EntityItemFrame entityitemframe = (EntityItemFrame) this.tracker; - - packetplayoutspawnentity = new PacketPlayOutSpawnEntity(this.tracker, 71, entityitemframe.direction); - packetplayoutspawnentity.a(MathHelper.d((float) (entityitemframe.x * 32))); - packetplayoutspawnentity.b(MathHelper.d((float) (entityitemframe.y * 32))); - packetplayoutspawnentity.c(MathHelper.d((float) (entityitemframe.z * 32))); - return packetplayoutspawnentity; - } else if (this.tracker instanceof EntityLeash) { - EntityLeash entityleash = (EntityLeash) this.tracker; - - packetplayoutspawnentity = new PacketPlayOutSpawnEntity(this.tracker, 77); - packetplayoutspawnentity.a(MathHelper.d((float) (entityleash.x * 32))); - packetplayoutspawnentity.b(MathHelper.d((float) (entityleash.y * 32))); - packetplayoutspawnentity.c(MathHelper.d((float) (entityleash.z * 32))); - return packetplayoutspawnentity; - } else if (this.tracker instanceof EntityExperienceOrb) { - return new PacketPlayOutSpawnEntityExperienceOrb((EntityExperienceOrb) this.tracker); - } else { - throw new IllegalArgumentException("Don\'t know how to add " + this.tracker.getClass() + "!"); - } - } - } else { - this.i = MathHelper.d(this.tracker.getHeadRotation() * 256.0F / 360.0F); - return new PacketPlayOutSpawnEntityLiving((EntityLiving) this.tracker); - } - } - - public void clear(EntityPlayer entityplayer) { - if (this.trackedPlayers.contains(entityplayer)) { - this.trackedPlayers.remove(entityplayer); - entityplayer.d(this.tracker); - } - } -} diff --git a/src/main/java/net/minecraft/server/EntityWither.java b/src/main/java/net/minecraft/server/EntityWither.java deleted file mode 100644 index 75b3ca3a..00000000 --- a/src/main/java/net/minecraft/server/EntityWither.java +++ /dev/null @@ -1,477 +0,0 @@ -package net.minecraft.server; - -import java.util.Iterator; -import java.util.List; - -// CraftBukkit start -import org.bukkit.craftbukkit.event.CraftEventFactory; -import org.bukkit.event.entity.EntityRegainHealthEvent; -import org.bukkit.event.entity.ExplosionPrimeEvent; -// CraftBukkit end - -public class EntityWither extends EntityMonster implements IRangedEntity { - - private float[] bp = new float[2]; - private float[] bq = new float[2]; - private float[] br = new float[2]; - private float[] bs = new float[2]; - private int[] bt = new int[2]; - private int[] bu = new int[2]; - private int bv; - private static final IEntitySelector bw = new EntitySelectorNotUndead(); - - public EntityWither(World world) { - super(world); - this.setHealth(this.getMaxHealth()); - this.a(0.9F, 4.0F); - this.fireProof = true; - this.getNavigation().e(true); - this.goalSelector.a(0, new PathfinderGoalFloat(this)); - this.goalSelector.a(2, new PathfinderGoalArrowAttack(this, 1.0D, 40, 20.0F)); - this.goalSelector.a(5, new PathfinderGoalRandomStroll(this, 1.0D)); - 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, EntityInsentient.class, 0, false, false, bw)); - this.b = 50; - } - - protected void c() { - super.c(); - 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.ca()); - } - - public void a(NBTTagCompound nbttagcompound) { - super.a(nbttagcompound); - this.s(nbttagcompound.getInt("Invul")); - } - - protected String t() { - return "mob.wither.idle"; - } - - protected String aT() { - return "mob.wither.hurt"; - } - - protected String aU() { - return "mob.wither.death"; - } - - public void e() { - 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.cb() && 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.e(); - - int i; - - for (i = 0; i < 2; ++i) { - this.bs[i] = this.bq[i]; - this.br[i] = this.bp[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.bp[i] = this.b(this.bp[i], f1, 40.0F); - this.bq[i] = this.b(this.bq[i], f, 10.0F); - } else { - this.bq[i] = this.b(this.bq[i], this.aM, 10.0F); - } - } - - boolean flag = this.cb(); - - 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.ca() > 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 bn() { - int i; - - if (this.ca() > 0) { - i = this.ca() - 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.createExplosion(this, this.locX, this.locY + (double) this.getHeadHeight(), this.locZ, 7.0F, false, this.world.getGameRules().getBoolean("mobGriefing")); - // CraftBukkit start - Use relative location for far away sounds - //this.world.b(1013, (int) this.locX, (int) this.locY, (int) this.locZ, 0); - int viewDistance = ((WorldServer) this.world).getServer().getViewDistance() * 16; - for (EntityPlayer player : (List<EntityPlayer>) this.world.players) { - double deltaX = this.locX - player.locX; - double deltaZ = this.locZ - player.locZ; - double distanceSquared = deltaX * deltaX + deltaZ * deltaZ; - if (distanceSquared > viewDistance * viewDistance) { - double deltaLength = Math.sqrt(distanceSquared); - double relativeX = player.locX + (deltaX / deltaLength) * viewDistance; - double relativeZ = player.locZ + (deltaZ / deltaLength) * viewDistance; - player.playerConnection.sendPacket(new PacketPlayOutWorldEvent(1013, (int) relativeX, (int) this.locY, (int) relativeZ, 0, true)); - } else { - player.playerConnection.sendPacket(new PacketPlayOutWorldEvent(1013, (int) this.locX, (int) this.locY, (int) this.locZ, 0, true)); - } - } - // CraftBukkit end - } - - this.s(i); - if (this.ticksLived % 10 == 0) { - this.heal(10.0F, EntityRegainHealthEvent.RegainReason.WITHER_SPAWN); // CraftBukkit - } - } else { - super.bn(); - - int j; - - for (i = 1; i < 3; ++i) { - if (this.ticksLived >= this.bt[i - 1]) { - this.bt[i - 1] = this.ticksLived + 10 + this.random.nextInt(10); - if (this.world.difficulty == EnumDifficulty.NORMAL || this.world.difficulty == EnumDifficulty.HARD) { - int i1001 = i - 1; - int i1003 = this.bu[i - 1]; - - this.bu[i1001] = this.bu[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.bu[i - 1] = 0; - } - } - - j = this.t(i); - if (j > 0) { - Entity entity = this.world.getEntity(j); - - if (entity != null && entity.isAlive() && this.f(entity) <= 900.0D && this.hasLineOfSight(entity)) { - this.a(i + 1, (EntityLiving) entity); - this.bt[i - 1] = this.ticksLived + 40 + this.random.nextInt(20); - this.bu[i - 1] = 0; - } else { - this.b(i, 0); - } - } else { - List list = this.world.a(EntityLiving.class, this.boundingBox.grow(20.0D, 8.0D, 20.0D), bw); - - 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.hasLineOfSight(entityliving)) { - if (entityliving instanceof EntityHuman) { - if (!((EntityHuman) entityliving).abilities.isInvulnerable) { - this.b(i, entityliving.getId()); - } - } else { - this.b(i, entityliving.getId()); - } - break; - } - - list.remove(entityliving); - } - } - } - } - - if (this.getGoalTarget() != null) { - this.b(0, this.getGoalTarget().getId()); - } else { - this.b(0, 0); - } - - if (this.bv > 0) { - --this.bv; - if (this.bv == 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; - Block block = this.world.getType(j2, k2, l2); - - if (block.getMaterial() != Material.AIR && block != Blocks.BEDROCK && block != Blocks.ENDER_PORTAL && block != Blocks.ENDER_PORTAL_FRAME && block != Blocks.COMMAND) { - // CraftBukkit start - if (CraftEventFactory.callEntityChangeBlockEvent(this, j2, k2, l2, Blocks.AIR, 0).isCancelled()) { - continue; - } - // CraftBukkit end - - flag = this.world.setAir(j2, k2, l2, true) || flag; - } - } - } - } - - 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.0F, EntityRegainHealthEvent.RegainReason.REGEN); // CraftBukkit - } - } - } - - public void bZ() { - this.s(220); - this.setHealth(this.getMaxHealth() / 3.0F); - } - - public void as() {} - - public int aV() { - return 4; - } - - private double u(int i) { - if (i <= 0) { - return this.locX; - } else { - float f = (this.aM + (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.aM + (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.setCharged(true); - } - - entitywitherskull.locY = d4; - entitywitherskull.locX = d3; - entitywitherskull.locZ = d5; - this.world.addEntity(entitywitherskull); - } - - public void a(EntityLiving entityliving, float f) { - this.a(0, entityliving); - } - - public boolean damageEntity(DamageSource damagesource, float f) { - if (this.isInvulnerable()) { - return false; - } else if (damagesource == DamageSource.DROWN) { - return false; - } else if (this.ca() > 0) { - return false; - } else { - Entity entity; - - if (this.cb()) { - entity = damagesource.i(); - 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.bv <= 0) { - this.bv = 20; - } - - for (int i = 0; i < this.bu.length; ++i) { - this.bu[i] += 3; - } - - return super.damageEntity(damagesource, f); - } - } - } - - protected void dropDeathLoot(boolean flag, int i) { - this.a(Items.NETHER_STAR, 1); - if (!this.world.isStatic) { - Iterator iterator = this.world.a(EntityHuman.class, this.boundingBox.grow(50.0D, 100.0D, 50.0D)).iterator(); - - while (iterator.hasNext()) { - EntityHuman entityhuman = (EntityHuman) iterator.next(); - - entityhuman.a((Statistic) AchievementList.J); - } - } - } - - protected void w() { - this.aU = 0; - } - - protected void b(float f) {} - - public void addEffect(MobEffect mobeffect) {} - - protected boolean bk() { - return true; - } - - protected void aD() { - super.aD(); - this.getAttributeInstance(GenericAttributes.maxHealth).setValue(300.0D); - this.getAttributeInstance(GenericAttributes.d).setValue(0.6000000238418579D); - this.getAttributeInstance(GenericAttributes.b).setValue(40.0D); - } - - public int ca() { - 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 b(int i, int j) { - this.datawatcher.watch(17 + i, Integer.valueOf(j)); - } - - public boolean cb() { - return this.getHealth() <= this.getMaxHealth() / 2.0F; - } - - public EnumMonsterType getMonsterType() { - return EnumMonsterType.UNDEAD; - } - - public void mount(Entity entity) { - this.vehicle = null; - } -} diff --git a/src/main/java/net/minecraft/server/EntityWitherSkull.java b/src/main/java/net/minecraft/server/EntityWitherSkull.java deleted file mode 100644 index b797f8a4..00000000 --- a/src/main/java/net/minecraft/server/EntityWitherSkull.java +++ /dev/null @@ -1,93 +0,0 @@ -package net.minecraft.server; - -import org.bukkit.event.entity.ExplosionPrimeEvent; // CraftBukkit - -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 e() { - return this.isCharged() ? 0.73F : super.e(); - } - - public boolean isBurning() { - return false; - } - - public float a(Explosion explosion, World world, int i, int j, int k, Block block) { - float f = super.a(explosion, world, i, j, k, block); - - if (this.isCharged() && block != Blocks.BEDROCK && block != Blocks.ENDER_PORTAL && block != Blocks.ENDER_PORTAL_FRAME && block != Blocks.COMMAND) { - 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.0F) && !movingobjectposition.entity.isAlive()) { - this.shooter.heal(5.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.WITHER); // CraftBukkit - } - } else { - movingobjectposition.entity.damageEntity(DamageSource.MAGIC, 5.0F); - } - - if (movingobjectposition.entity instanceof EntityLiving) { - byte b0 = 0; - - if (this.world.difficulty == EnumDifficulty.NORMAL) { - b0 = 10; - } else if (this.world.difficulty == EnumDifficulty.HARD) { - 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 R() { - return false; - } - - public boolean damageEntity(DamageSource damagesource, float f) { - return false; - } - - protected void c() { - this.datawatcher.a(10, Byte.valueOf((byte) 0)); - } - - public boolean isCharged() { - return this.datawatcher.getByte(10) == 1; - } - - public void setCharged(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 deleted file mode 100644 index 8f1ebf2e..00000000 --- a/src/main/java/net/minecraft/server/EntityWolf.java +++ /dev/null @@ -1,379 +0,0 @@ -package net.minecraft.server; - -// CraftBukkit start -import org.bukkit.craftbukkit.event.CraftEventFactory; -import org.bukkit.event.entity.EntityTargetEvent.TargetReason; -// CraftBukkit end - -public class EntityWolf extends EntityTameableAnimal { - - private float bq; - private float br; - private boolean bs; - private boolean bt; - private float bu; - private float bv; - - public EntityWolf(World world) { - super(world); - this.a(0.6F, 0.8F); - this.getNavigation().a(true); - this.goalSelector.a(1, new PathfinderGoalFloat(this)); - this.goalSelector.a(2, this.bp); - this.goalSelector.a(3, new PathfinderGoalLeapAtTarget(this, 0.4F)); - this.goalSelector.a(4, new PathfinderGoalMeleeAttack(this, 1.0D, true)); - this.goalSelector.a(5, new PathfinderGoalFollowOwner(this, 1.0D, 10.0F, 2.0F)); - this.goalSelector.a(6, new PathfinderGoalBreed(this, 1.0D)); - this.goalSelector.a(7, new PathfinderGoalRandomStroll(this, 1.0D)); - 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)); - this.targetSelector.a(1, new PathfinderGoalOwnerHurtByTarget(this)); - this.targetSelector.a(2, new PathfinderGoalOwnerHurtTarget(this)); - this.targetSelector.a(3, new PathfinderGoalHurtByTarget(this, true)); - this.targetSelector.a(4, new PathfinderGoalRandomTargetNonTamed(this, EntitySheep.class, 200, false)); - this.setTamed(false); - } - - protected void aD() { - super.aD(); - this.getAttributeInstance(GenericAttributes.d).setValue(0.30000001192092896D); - if (this.isTamed()) { - this.getAttributeInstance(GenericAttributes.maxHealth).setValue(20.0D); - } else { - this.getAttributeInstance(GenericAttributes.maxHealth).setValue(8.0D); - } - } - - public boolean bk() { - return true; - } - - public void setGoalTarget(EntityLiving entityliving) { - super.setGoalTarget(entityliving); - if (entityliving == null) { - this.setAngry(false); - } else if (!this.isTamed()) { - this.setAngry(true); - } - } - - protected void bp() { - this.datawatcher.watch(18, Float.valueOf(this.getHealth())); - } - - protected void c() { - super.c(); - this.datawatcher.a(18, new Float(this.getHealth())); - this.datawatcher.a(19, new Byte((byte) 0)); - this.datawatcher.a(20, new Byte((byte) BlockCloth.b(1))); - } - - protected void a(int i, int j, int k, Block block) { - this.makeSound("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.hasKeyOfType("CollarColor", 99)) { - this.setCollarColor(nbttagcompound.getByte("CollarColor")); - } - } - - protected String t() { - // CraftBukkit - (getFloat(18) < 10) -> (getFloat(18) < this.getMaxHealth() / 2) - return this.isAngry() ? "mob.wolf.growl" : (this.random.nextInt(3) == 0 ? (this.isTamed() && this.datawatcher.getFloat(18) < (this.getMaxHealth() / 2) ? "mob.wolf.whine" : "mob.wolf.panting") : "mob.wolf.bark"); - } - - protected String aT() { - return "mob.wolf.hurt"; - } - - protected String aU() { - return "mob.wolf.death"; - } - - protected float bf() { - return 0.4F; - } - - protected Item getLoot() { - return Item.getById(-1); - } - - public void e() { - super.e(); - if (!this.world.isStatic && this.bs && !this.bt && !this.bS() && this.onGround) { - this.bt = true; - this.bu = 0.0F; - this.bv = 0.0F; - this.world.broadcastEntityEffect(this, (byte) 8); - } - } - - public void h() { - super.h(); - this.br = this.bq; - if (this.ck()) { - this.bq += (1.0F - this.bq) * 0.4F; - } else { - this.bq += (0.0F - this.bq) * 0.4F; - } - - if (this.ck()) { - this.g = 10; - } - - if (this.L()) { - this.bs = true; - this.bt = false; - this.bu = 0.0F; - this.bv = 0.0F; - } else if ((this.bs || this.bt) && this.bt) { - if (this.bu == 0.0F) { - this.makeSound("mob.wolf.shake", this.bf(), (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); - } - - this.bv = this.bu; - this.bu += 0.05F; - if (this.bv >= 2.0F) { - this.bs = false; - this.bt = false; - this.bv = 0.0F; - this.bu = 0.0F; - } - - if (this.bu > 0.4F) { - float f = (float) this.boundingBox.b; - int i = (int) (MathHelper.sin((this.bu - 0.4F) * 3.1415927F) * 7.0F); - - for (int j = 0; j < i; ++j) { - 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.addParticle("splash", this.locX + (double) f1, (double) (f + 0.8F), this.locZ + (double) f2, this.motX, this.motY, this.motZ); - } - } - } - } - - public float getHeadHeight() { - return this.length * 0.8F; - } - - public int x() { - return this.isSitting() ? 20 : super.x(); - } - - public boolean damageEntity(DamageSource damagesource, float f) { - if (this.isInvulnerable()) { - return false; - } else { - Entity entity = damagesource.getEntity(); - - this.bp.setSitting(false); - if (entity != null && !(entity instanceof EntityHuman) && !(entity instanceof EntityArrow)) { - f = (f + 1.0F) / 2.0F; - } - - return super.damageEntity(damagesource, f); - } - } - - public boolean n(Entity entity) { - int i = this.isTamed() ? 4 : 2; - - return entity.damageEntity(DamageSource.mobAttack(this), (float) i); - } - - public void setTamed(boolean flag) { - super.setTamed(flag); - if (flag) { - this.getAttributeInstance(GenericAttributes.maxHealth).setValue(20.0D); - } else { - this.getAttributeInstance(GenericAttributes.maxHealth).setValue(8.0D); - } - } - - public boolean a(EntityHuman entityhuman) { - ItemStack itemstack = entityhuman.inventory.getItemInHand(); - - if (this.isTamed()) { - if (itemstack != null) { - if (itemstack.getItem() instanceof ItemFood) { - ItemFood itemfood = (ItemFood) itemstack.getItem(); - - if (itemfood.i() && this.datawatcher.getFloat(18) < 20.0F) { - if (!entityhuman.abilities.canInstantlyBuild) { - --itemstack.count; - } - - this.heal((float) itemfood.getNutrition(itemstack), org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.EATING); // CraftBukkit - if (itemstack.count <= 0) { - entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, (ItemStack) null); - } - - return true; - } - } else if (itemstack.getItem() == Items.INK_SACK) { - int i = BlockCloth.b(itemstack.getData()); - - 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 (this.e(entityhuman) && !this.world.isStatic && !this.c(itemstack)) { - this.bp.setSitting(!this.isSitting()); - this.bc = false; - this.setPathEntity((PathEntity) null); - this.setTarget((Entity) null); - // CraftBukkit start - if (this.getGoalTarget() != null) { - CraftEventFactory.callEntityTargetEvent(this, null, TargetReason.FORGOT_TARGET); - } - // CraftBukkit end - this.setGoalTarget((EntityLiving) null); - } - } else if (itemstack != null && itemstack.getItem() == Items.BONE && !this.isAngry()) { - if (!entityhuman.abilities.canInstantlyBuild) { - --itemstack.count; - } - - if (itemstack.count <= 0) { - entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, (ItemStack) null); - } - - if (!this.world.isStatic) { - // CraftBukkit - added event call and isCancelled check. - if (this.random.nextInt(3) == 0 && !CraftEventFactory.callEntityTameEvent(this, entityhuman).isCancelled()) { - this.setTamed(true); - this.setPathEntity((PathEntity) null); - // CraftBukkit start - if (this.getGoalTarget() != null) { - CraftEventFactory.callEntityTargetEvent(this, null, TargetReason.FORGOT_TARGET); - } - // CraftBukkit end - this.setGoalTarget((EntityLiving) null); - this.bp.setSitting(true); - this.setHealth(this.getMaxHealth()); // CraftBukkit - 20.0 -> getMaxHealth() - this.setOwnerUUID(entityhuman.getUniqueID().toString()); - this.i(true); - this.world.broadcastEntityEffect(this, (byte) 7); - } else { - this.i(false); - this.world.broadcastEntityEffect(this, (byte) 6); - } - } - - return true; - } - - return super.a(entityhuman); - } - - public boolean c(ItemStack itemstack) { - return itemstack == null ? false : (!(itemstack.getItem() instanceof ItemFood) ? false : ((ItemFood) itemstack.getItem()).i()); - } - - public int bB() { - return 8; - } - - public boolean isAngry() { - return (this.datawatcher.getByte(16) & 2) != 0; - } - - public void setAngry(boolean flag) { - byte b0 = this.datawatcher.getByte(16); - - if (flag) { - this.datawatcher.watch(16, Byte.valueOf((byte) (b0 | 2))); - } else { - this.datawatcher.watch(16, Byte.valueOf((byte) (b0 & -3))); - } - } - - public int getCollarColor() { - return this.datawatcher.getByte(20) & 15; - } - - public void setCollarColor(int i) { - this.datawatcher.watch(20, Byte.valueOf((byte) (i & 15))); - } - - public EntityWolf b(EntityAgeable entityageable) { - EntityWolf entitywolf = new EntityWolf(this.world); - String s = this.getOwnerUUID(); - - if (s != null && s.trim().length() > 0) { - entitywolf.setOwnerUUID(s); - entitywolf.setTamed(true); - } - - return entitywolf; - } - - public void m(boolean flag) { - if (flag) { - this.datawatcher.watch(19, Byte.valueOf((byte) 1)); - } else { - this.datawatcher.watch(19, Byte.valueOf((byte) 0)); - } - } - - public boolean mate(EntityAnimal entityanimal) { - if (entityanimal == this) { - return false; - } else if (!this.isTamed()) { - return false; - } else if (!(entityanimal instanceof EntityWolf)) { - return false; - } else { - EntityWolf entitywolf = (EntityWolf) entityanimal; - - return !entitywolf.isTamed() ? false : (entitywolf.isSitting() ? false : this.ce() && entitywolf.ce()); - } - } - - public boolean ck() { - return this.datawatcher.getByte(19) == 1; - } - - protected boolean isTypeNotPersistent() { - return !this.isTamed() /*&& this.ticksLived > 2400*/; // CraftBukkit - } - - public boolean a(EntityLiving entityliving, EntityLiving entityliving1) { - if (!(entityliving instanceof EntityCreeper) && !(entityliving instanceof EntityGhast)) { - if (entityliving instanceof EntityWolf) { - EntityWolf entitywolf = (EntityWolf) entityliving; - - if (entitywolf.isTamed() && entitywolf.getOwner() == entityliving1) { - return false; - } - } - - return entityliving instanceof EntityHuman && entityliving1 instanceof EntityHuman && !((EntityHuman) entityliving1).a((EntityHuman) entityliving) ? false : !(entityliving instanceof EntityHorse) || !((EntityHorse) entityliving).isTame(); - } else { - return false; - } - } - - public EntityAgeable createChild(EntityAgeable entityageable) { - return this.b(entityageable); - } -} diff --git a/src/main/java/net/minecraft/server/EntityZombie.java b/src/main/java/net/minecraft/server/EntityZombie.java deleted file mode 100644 index 7d8cb937..00000000 --- a/src/main/java/net/minecraft/server/EntityZombie.java +++ /dev/null @@ -1,524 +0,0 @@ -package net.minecraft.server; - -import java.util.Calendar; -import java.util.List; -import java.util.UUID; - - -//CraftBukkit start -import org.bukkit.craftbukkit.entity.CraftLivingEntity; -import org.bukkit.event.entity.CreatureSpawnEvent; -import org.bukkit.event.entity.EntityCombustByEntityEvent; -import org.bukkit.event.entity.EntityCombustEvent; -import org.bukkit.event.entity.EntityTargetEvent; -//CraftBukkit end - -public class EntityZombie extends EntityMonster { - - protected static final IAttribute bp = (new AttributeRanged("zombie.spawnReinforcements", 0.0D, 0.0D, 1.0D)).a("Spawn Reinforcements Chance"); - private static final UUID bq = UUID.fromString("B9766B59-9566-4402-BC1F-2EE2A276D836"); - private static final AttributeModifier br = new AttributeModifier(bq, "Baby speed boost", 0.5D, 1); - private final PathfinderGoalBreakDoor bs = new PathfinderGoalBreakDoor(this); - private int bt; - private boolean bu = false; - private float bv = -1.0F; - private float bw; - private int lastTick = MinecraftServer.currentTick; // CraftBukkit - add field - - public EntityZombie(World world) { - super(world); - this.getNavigation().b(true); - this.goalSelector.a(0, new PathfinderGoalFloat(this)); - this.goalSelector.a(2, new PathfinderGoalMeleeAttack(this, EntityHuman.class, 1.0D, false)); - this.goalSelector.a(4, new PathfinderGoalMeleeAttack(this, EntityVillager.class, 1.0D, true)); - this.goalSelector.a(5, new PathfinderGoalMoveTowardsRestriction(this, 1.0D)); - this.goalSelector.a(6, new PathfinderGoalMoveThroughVillage(this, 1.0D, false)); - this.goalSelector.a(7, new PathfinderGoalRandomStroll(this, 1.0D)); - this.goalSelector.a(8, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 8.0F)); - this.goalSelector.a(8, new PathfinderGoalRandomLookaround(this)); - this.targetSelector.a(1, new PathfinderGoalHurtByTarget(this, true)); - this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityHuman.class, 0, true)); - this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityVillager.class, 0, false)); - this.a(0.6F, 1.8F); - } - - protected void aD() { - super.aD(); - this.getAttributeInstance(GenericAttributes.b).setValue(40.0D); - this.getAttributeInstance(GenericAttributes.d).setValue(0.23000000417232513D); - this.getAttributeInstance(GenericAttributes.e).setValue(3.0D); - this.getAttributeMap().b(bp).setValue(this.random.nextDouble() * 0.10000000149011612D); - } - - protected void c() { - super.c(); - 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 aV() { - int i = super.aV() + 2; - - if (i > 20) { - i = 20; - } - - return i; - } - - protected boolean bk() { - return true; - } - - public boolean bZ() { - return this.bu; - } - - public void a(boolean flag) { - if (this.bu != flag) { - this.bu = flag; - if (flag) { - this.goalSelector.a(1, this.bs); - } else { - this.goalSelector.a((PathfinderGoal) this.bs); - } - } - } - - public boolean isBaby() { - return this.getDataWatcher().getByte(12) == 1; - } - - protected int getExpValue(EntityHuman entityhuman) { - if (this.isBaby()) { - this.b = (int) ((float) this.b * 2.5F); - } - - return super.getExpValue(entityhuman); - } - - public void setBaby(boolean flag) { - this.getDataWatcher().watch(12, Byte.valueOf((byte) (flag ? 1 : 0))); - if (this.world != null && !this.world.isStatic) { - AttributeInstance attributeinstance = this.getAttributeInstance(GenericAttributes.d); - - attributeinstance.b(br); - if (flag) { - attributeinstance.a(br); - } - } - - this.k(flag); - } - - 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 e() { - if (this.world.w() && !this.world.isStatic && !this.isBaby()) { - float f = this.d(1.0F); - - if (f > 0.5F && this.random.nextFloat() * 30.0F < (f - 0.4F) * 2.0F && this.world.i(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.g()) { - itemstack.setData(itemstack.j() + this.random.nextInt(2)); - if (itemstack.j() >= itemstack.l()) { - 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()); - } - // CraftBukkit end - } - } - } - - if (this.am() && this.getGoalTarget() != null && this.vehicle instanceof EntityChicken) { - ((EntityInsentient) this.vehicle).getNavigation().a(this.getNavigation().e(), 1.5D); - } - - super.e(); - } - - public boolean damageEntity(DamageSource damagesource, float f) { - if (!super.damageEntity(damagesource, f)) { - return false; - } else { - EntityLiving entityliving = this.getGoalTarget(); - - if (entityliving == null && this.bT() instanceof EntityLiving) { - entityliving = (EntityLiving) this.bT(); - } - - if (entityliving == null && damagesource.getEntity() instanceof EntityLiving) { - entityliving = (EntityLiving) damagesource.getEntity(); - } - - if (entityliving != null && this.world.difficulty == EnumDifficulty.HARD && (double) this.random.nextFloat() < this.getAttributeInstance(bp).getValue()) { - int i = MathHelper.floor(this.locX); - int j = MathHelper.floor(this.locY); - int k = MathHelper.floor(this.locZ); - EntityZombie entityzombie = new EntityZombie(this.world); - - for (int l = 0; l < 50; ++l) { - int i1 = i + MathHelper.nextInt(this.random, 7, 40) * MathHelper.nextInt(this.random, -1, 1); - int j1 = j + MathHelper.nextInt(this.random, 7, 40) * MathHelper.nextInt(this.random, -1, 1); - int k1 = k + MathHelper.nextInt(this.random, 7, 40) * MathHelper.nextInt(this.random, -1, 1); - - if (World.a((IBlockAccess) this.world, i1, j1 - 1, k1) && this.world.getLightLevel(i1, j1, k1) < 10) { - entityzombie.setPosition((double) i1, (double) j1, (double) k1); - if (this.world.b(entityzombie.boundingBox) && this.world.getCubes(entityzombie, entityzombie.boundingBox).isEmpty() && !this.world.containsLiquid(entityzombie.boundingBox)) { - this.world.addEntity(entityzombie, CreatureSpawnEvent.SpawnReason.REINFORCEMENTS); // CraftBukkit - // CraftBukkit start - call EntityTargetEvent - org.bukkit.event.entity.EntityTargetLivingEntityEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTargetLivingEvent(entityzombie, entityliving, EntityTargetEvent.TargetReason.REINFORCEMENT_TARGET); - if (!event.isCancelled()) { - if (event.getTarget() == null) { - entityzombie.setGoalTarget(null); - } else { - entityzombie.setGoalTarget(((org.bukkit.craftbukkit.entity.CraftLivingEntity) event.getTarget()).getHandle()); - } - } - // CraftBukkit end - entityzombie.prepare((GroupDataEntity) null); - this.getAttributeInstance(bp).a(new AttributeModifier("Zombie reinforcement caller charge", -0.05000000074505806D, 0)); - entityzombie.getAttributeInstance(bp).a(new AttributeModifier("Zombie reinforcement callee charge", -0.05000000074505806D, 0)); - break; - } - } - } - } - - return true; - } - } - - public void h() { - if (!this.world.isStatic && this.cc()) { - int i = this.ce(); - - // CraftBukkit start - Use wall time instead of ticks for villager conversion - int elapsedTicks = MinecraftServer.currentTick - this.lastTick; - this.lastTick = MinecraftServer.currentTick; - i *= elapsedTicks; - // CraftBukkit end - - this.bt -= i; - if (this.bt <= 0) { - this.cd(); - } - } - - super.h(); - } - - public boolean n(Entity entity) { - boolean flag = super.n(entity); - - if (flag) { - int i = this.world.difficulty.a(); - - if (this.be() == null && this.isBurning() && this.random.nextFloat() < (float) i * 0.3F) { - // CraftBukkit start - EntityCombustByEntityEvent event = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), 2 * i); - this.world.getServer().getPluginManager().callEvent(event); - - if (!event.isCancelled()) { - entity.setOnFire(event.getDuration()); - } - // CraftBukkit end - } - } - - return flag; - } - - protected String t() { - return "mob.zombie.say"; - } - - protected String aT() { - return "mob.zombie.hurt"; - } - - protected String aU() { - return "mob.zombie.death"; - } - - protected void a(int i, int j, int k, Block block) { - this.makeSound("mob.zombie.step", 0.15F, 1.0F); - } - - protected Item getLoot() { - return Items.ROTTEN_FLESH; - } - - public EnumMonsterType getMonsterType() { - return EnumMonsterType.UNDEAD; - } - - protected void getRareDrop(int i) { - switch (this.random.nextInt(3)) { - case 0: - this.a(Items.IRON_INGOT, 1); - break; - - case 1: - this.a(Items.CARROT, 1); - break; - - case 2: - this.a(Items.POTATO, 1); - } - } - - protected void bC() { - super.bC(); - if (this.random.nextFloat() < (this.world.difficulty == EnumDifficulty.HARD ? 0.05F : 0.01F)) { - int i = this.random.nextInt(3); - - if (i == 0) { - this.setEquipment(0, new ItemStack(Items.IRON_SWORD)); - } else { - this.setEquipment(0, new ItemStack(Items.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.cc() ? this.bt : -1); - nbttagcompound.setBoolean("CanBreakDoors", this.bZ()); - } - - public void a(NBTTagCompound nbttagcompound) { - super.a(nbttagcompound); - if (nbttagcompound.getBoolean("IsBaby")) { - this.setBaby(true); - } - - if (nbttagcompound.getBoolean("IsVillager")) { - this.setVillager(true); - } - - if (nbttagcompound.hasKeyOfType("ConversionTime", 99) && nbttagcompound.getInt("ConversionTime") > -1) { - this.a(nbttagcompound.getInt("ConversionTime")); - } - - this.a(nbttagcompound.getBoolean("CanBreakDoors")); - } - - public void a(EntityLiving entityliving) { - super.a(entityliving); - if ((this.world.difficulty == EnumDifficulty.NORMAL || this.world.difficulty == EnumDifficulty.HARD) && entityliving instanceof EntityVillager) { - if (this.world.difficulty != EnumDifficulty.HARD && this.random.nextBoolean()) { - return; - } - - EntityZombie entityzombie = new EntityZombie(this.world); - - entityzombie.k(entityliving); - this.world.kill(entityliving); - entityzombie.prepare((GroupDataEntity) null); - entityzombie.setVillager(true); - if (entityliving.isBaby()) { - entityzombie.setBaby(true); - } - - this.world.addEntity(entityzombie, CreatureSpawnEvent.SpawnReason.INFECTION); // CraftBukkit - add SpawnReason - this.world.a((EntityHuman) null, 1016, (int) this.locX, (int) this.locY, (int) this.locZ, 0); - } - } - - public GroupDataEntity prepare(GroupDataEntity groupdataentity) { - Object object = super.prepare(groupdataentity); - float f = this.world.b(this.locX, this.locY, this.locZ); - - this.h(this.random.nextFloat() < 0.55F * f); - if (object == null) { - object = new GroupDataZombie(this, this.world.random.nextFloat() < 0.05F, this.world.random.nextFloat() < 0.05F, (EmptyClassZombie) null); - } - - if (object instanceof GroupDataZombie) { - GroupDataZombie groupdatazombie = (GroupDataZombie) object; - - if (groupdatazombie.b) { - this.setVillager(true); - } - - if (groupdatazombie.a) { - this.setBaby(true); - if ((double) this.world.random.nextFloat() < 0.05D) { - List list = this.world.a(EntityChicken.class, this.boundingBox.grow(5.0D, 3.0D, 5.0D), IEntitySelector.b); - - if (!list.isEmpty()) { - EntityChicken entitychicken = (EntityChicken) list.get(0); - - entitychicken.i(true); - this.mount(entitychicken); - } - } else if ((double) this.world.random.nextFloat() < 0.05D) { - EntityChicken entitychicken1 = new EntityChicken(this.world); - - entitychicken1.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, 0.0F); - entitychicken1.prepare((GroupDataEntity) null); - entitychicken1.i(true); - this.world.addEntity(entitychicken1, CreatureSpawnEvent.SpawnReason.MOUNT); - this.mount(entitychicken1); - } - } - } - - this.a(this.random.nextFloat() < f * 0.1F); - this.bC(); - this.bD(); - if (this.getEquipment(4) == null) { - Calendar calendar = this.world.V(); - - 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 ? Blocks.JACK_O_LANTERN : Blocks.PUMPKIN)); - this.dropChances[4] = 0.0F; - } - } - - this.getAttributeInstance(GenericAttributes.c).a(new AttributeModifier("Random spawn bonus", this.random.nextDouble() * 0.05000000074505806D, 0)); - double d0 = this.random.nextDouble() * 1.5D * (double) this.world.b(this.locX, this.locY, this.locZ); - - if (d0 > 1.0D) { - this.getAttributeInstance(GenericAttributes.b).a(new AttributeModifier("Random zombie-spawn bonus", d0, 2)); - } - - if (this.random.nextFloat() < f * 0.05F) { - this.getAttributeInstance(bp).a(new AttributeModifier("Leader zombie bonus", this.random.nextDouble() * 0.25D + 0.5D, 0)); - this.getAttributeInstance(GenericAttributes.maxHealth).a(new AttributeModifier("Leader zombie bonus", this.random.nextDouble() * 3.0D + 1.0D, 2)); - this.a(true); - } - - return (GroupDataEntity) object; - } - - public boolean a(EntityHuman entityhuman) { - ItemStack itemstack = entityhuman.bF(); - - if (itemstack != null && itemstack.getItem() == Items.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.bt = i; - this.getDataWatcher().watch(14, Byte.valueOf((byte) 1)); - this.removeEffect(MobEffectList.WEAKNESS.id); - this.addEffect(new MobEffect(MobEffectList.INCREASE_DAMAGE.id, i, Math.min(this.world.difficulty.a() - 1, 0))); - this.world.broadcastEntityEffect(this, (byte) 16); - } - - protected boolean isTypeNotPersistent() { - return !this.cc(); - } - - public boolean cc() { - return this.getDataWatcher().getByte(14) == 1; - } - - protected void cd() { - EntityVillager entityvillager = new EntityVillager(this.world); - - entityvillager.k(this); - entityvillager.prepare((GroupDataEntity) null); - entityvillager.cd(); - if (this.isBaby()) { - entityvillager.setAge(-24000); - } - - this.world.kill(this); - this.world.addEntity(entityvillager, CreatureSpawnEvent.SpawnReason.CURED); // CraftBukkit - add SpawnReason - 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 ce() { - 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) { - Block block = this.world.getType(k, l, i1); - - if (block == Blocks.IRON_FENCE || block == Blocks.BED) { - if (this.random.nextFloat() < 0.3F) { - ++i; - } - - ++j; - } - } - } - } - } - - return i; - } - - public void k(boolean flag) { - this.a(flag ? 0.5F : 1.0F); - } - - protected final void a(float f, float f1) { - boolean flag = this.bv > 0.0F && this.bw > 0.0F; - - this.bv = f; - this.bw = f1; - if (!flag) { - this.a(1.0F); - } - } - - protected final void a(float f) { - super.a(this.bv * f, this.bw * f); - } -} diff --git a/src/main/java/net/minecraft/server/ExpirableListEntry.java b/src/main/java/net/minecraft/server/ExpirableListEntry.java deleted file mode 100644 index 2cf6e232..00000000 --- a/src/main/java/net/minecraft/server/ExpirableListEntry.java +++ /dev/null @@ -1,95 +0,0 @@ -package net.minecraft.server; - -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Date; - -import net.minecraft.util.com.google.gson.JsonObject; - -public abstract class ExpirableListEntry extends JsonListEntry { - - public static final SimpleDateFormat a = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z"); - protected final Date b; - protected final String c; - protected final Date d; - protected final String e; - - public ExpirableListEntry(Object object, Date date, String s, Date date1, String s1) { - super(object); - this.b = date == null ? new Date() : date; - this.c = s == null ? "(Unknown)" : s; - this.d = date1; - this.e = s1 == null ? "Banned by an operator." : s1; - } - - protected ExpirableListEntry(Object object, JsonObject jsonobject) { - super(checkExpiry(object, jsonobject), jsonobject); // CraftBukkit - check expiry - - Date date; - - try { - date = jsonobject.has("created") ? a.parse(jsonobject.get("created").getAsString()) : new Date(); - } catch (ParseException parseexception) { - date = new Date(); - } - - this.b = date; - this.c = jsonobject.has("source") ? jsonobject.get("source").getAsString() : "(Unknown)"; - - Date date1; - - try { - date1 = jsonobject.has("expires") ? a.parse(jsonobject.get("expires").getAsString()) : null; - } catch (ParseException parseexception1) { - date1 = null; - } - - this.d = date1; - this.e = jsonobject.has("reason") ? jsonobject.get("reason").getAsString() : "Banned by an operator."; - } - - public Date getExpires() { - return this.d; - } - - public String getReason() { - return this.e; - } - - boolean hasExpired() { - return this.d == null ? false : this.d.before(new Date()); - } - - protected void a(JsonObject jsonobject) { - jsonobject.addProperty("created", a.format(this.b)); - jsonobject.addProperty("source", this.c); - jsonobject.addProperty("expires", this.d == null ? "forever" : a.format(this.d)); - jsonobject.addProperty("reason", this.e); - } - - // CraftBukkit start - public String getSource() { - return this.c; - } - - public Date getCreated() { - return this.b; - } - - private static Object checkExpiry(Object object, JsonObject jsonobject) { - Date expires = null; - - try { - expires = jsonobject.has("expires") ? a.parse(jsonobject.get("expires").getAsString()) : null; - } catch (ParseException ex) { - // Guess we don't have a date - } - - if (expires == null || expires.after(new Date())) { - return object; - } else { - return null; - } - } - // CraftBukkit end -} diff --git a/src/main/java/net/minecraft/server/Explosion.java b/src/main/java/net/minecraft/server/Explosion.java deleted file mode 100644 index 56fa9998..00000000 --- a/src/main/java/net/minecraft/server/Explosion.java +++ /dev/null @@ -1,269 +0,0 @@ -package net.minecraft.server; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Random; - -// CraftBukkit start -import org.bukkit.craftbukkit.event.CraftEventFactory; -import org.bukkit.event.entity.EntityExplodeEvent; -import org.bukkit.Location; -// CraftBukkit end - -public class Explosion { - - public boolean a; - public boolean b = true; - private int i = 16; - private Random j = new Random(); - private World world; - public double posX; - public double posY; - public double posZ; - public Entity source; - public float size; - public List blocks = new ArrayList(); - private Map l = new HashMap(); - public boolean wasCanceled = false; // CraftBukkit - add field - - public Explosion(World world, Entity entity, double d0, double d1, double d2, float f) { - this.world = world; - this.source = entity; - this.size = (float) Math.max(f, 0.0); // CraftBukkit - clamp bad values - this.posX = d0; - this.posY = d1; - this.posZ = d2; - } - - public void a() { - // CraftBukkit start - if (this.size < 0.1F) { - return; - } - // CraftBukkit end - - float f = this.size; - HashSet hashset = new HashSet(); - - int i; - int j; - int k; - double d0; - double d1; - double d2; - - 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; - d4 /= d6; - d5 /= d6; - float f1 = this.size * (0.7F + this.world.random.nextFloat() * 0.6F); - - d0 = this.posX; - d1 = this.posY; - d2 = this.posZ; - - for (float f2 = 0.3F; f1 > 0.0F; f1 -= f2 * 0.75F) { - int l = MathHelper.floor(d0); - int i1 = MathHelper.floor(d1); - int j1 = MathHelper.floor(d2); - Block block = this.world.getType(l, i1, j1); - - if (block.getMaterial() != Material.AIR) { - float f3 = this.source != null ? this.source.a(this, this.world, l, i1, j1, block) : block.a(this.source); - - f1 -= (f3 + 0.3F) * f2; - } - - if (f1 > 0.0F && (this.source == null || this.source.a(this, this.world, l, i1, j1, block, f1)) && i1 < 256 && i1 >= 0) { // CraftBukkit - don't wrap explosions - hashset.add(new ChunkPosition(l, i1, j1)); - } - - d0 += d3 * (double) f2; - d1 += d4 * (double) f2; - d2 += d5 * (double) f2; - } - } - } - } - } - - this.blocks.addAll(hashset); - this.size *= 2.0F; - i = MathHelper.floor(this.posX - (double) this.size - 1.0D); - j = MathHelper.floor(this.posX + (double) this.size + 1.0D); - k = MathHelper.floor(this.posY - (double) this.size - 1.0D); - int k1 = MathHelper.floor(this.posY + (double) this.size + 1.0D); - int l1 = MathHelper.floor(this.posZ - (double) this.size - 1.0D); - int i2 = MathHelper.floor(this.posZ + (double) this.size + 1.0D); - List list = this.world.getEntities(this.source, AxisAlignedBB.a((double) i, (double) k, (double) l1, (double) j, (double) k1, (double) i2)); - Vec3D vec3d = Vec3D.a(this.posX, this.posY, this.posZ); - - for (int j2 = 0; j2 < list.size(); ++j2) { - Entity entity = (Entity) list.get(j2); - double d7 = entity.f(this.posX, this.posY, this.posZ) / (double) this.size; - - if (d7 <= 1.0D) { - d0 = entity.locX - this.posX; - d1 = entity.locY + (double) entity.getHeadHeight() - this.posY; - d2 = entity.locZ - this.posZ; - double d8 = (double) MathHelper.sqrt(d0 * d0 + d1 * d1 + d2 * d2); - - if (d8 != 0.0D) { - d0 /= d8; - d1 /= d8; - d2 /= d8; - double d9 = (double) this.world.a(vec3d, entity.boundingBox); - double d10 = (1.0D - d7) * d9; - - // CraftBukkit start - CraftEventFactory.entityDamage = source; - if (!entity.damageEntity(DamageSource.explosion(this), (float) ((int) ((d10 * d10 + d10) / 2.0D * 8.0D * (double) this.size + 1.0D)))) { - CraftEventFactory.entityDamage = null; - continue; - } - // CraftBukkit end - double d11 = EnchantmentProtection.a(entity, d10); - - entity.motX += d0 * d11; - entity.motY += d1 * d11; - entity.motZ += d2 * d11; - if (entity instanceof EntityHuman) { - this.l.put((EntityHuman) entity, Vec3D.a(d0 * d10, d1 * d10, d2 * d10)); - } - } - } - } - - this.size = f; - } - - 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); - 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); - } - - Iterator iterator; - ChunkPosition chunkposition; - int i; - int j; - int k; - Block block; - - 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 bblock = bworld.getBlockAt(cpos.x, cpos.y, cpos.z); - if (bblock.getType() != org.bukkit.Material.AIR) { - blockList.add(bblock); - } - } - - EntityExplodeEvent event = new EntityExplodeEvent(explode, location, blockList, 0.3F); - this.world.getServer().getPluginManager().callEvent(event); - - this.blocks.clear(); - - for (org.bukkit.block.Block bblock : event.blockList()) { - ChunkPosition coords = new ChunkPosition(bblock.getX(), bblock.getY(), bblock.getZ()); - blocks.add(coords); - } - - if (event.isCancelled()) { - this.wasCanceled = true; - return; - } - // CraftBukkit end - - iterator = this.blocks.iterator(); - - while (iterator.hasNext()) { - chunkposition = (ChunkPosition) iterator.next(); - i = chunkposition.x; - j = chunkposition.y; - k = chunkposition.z; - block = this.world.getType(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); - } - - if (block.getMaterial() != Material.AIR) { - if (block.a(this)) { - // CraftBukkit - add yield - block.dropNaturally(this.world, i, j, k, this.world.getData(i, j, k), event.getYield(), 0); - } - - this.world.setTypeAndData(i, j, k, Blocks.AIR, 0, 3); - block.wasExploded(this.world, i, j, k, this); - } - } - } - - if (this.a) { - iterator = this.blocks.iterator(); - - while (iterator.hasNext()) { - chunkposition = (ChunkPosition) iterator.next(); - i = chunkposition.x; - j = chunkposition.y; - k = chunkposition.z; - block = this.world.getType(i, j, k); - Block block1 = this.world.getType(i, j - 1, k); - - if (block.getMaterial() == Material.AIR && block1.j() && this.j.nextInt(3) == 0) { - // CraftBukkit start - Ignition by explosion - if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(this.world, i, j, k, this).isCancelled()) { - this.world.setTypeUpdate(i, j, k, Blocks.FIRE); - } - // CraftBukkit end - } - } - } - } - - public Map b() { - return this.l; - } - - public EntityLiving c() { - return this.source == null ? null : (this.source instanceof EntityTNTPrimed ? ((EntityTNTPrimed) this.source).getSource() : (this.source instanceof EntityLiving ? (EntityLiving) this.source : null)); - } -} diff --git a/src/main/java/net/minecraft/server/FileConversionException.java b/src/main/java/net/minecraft/server/FileConversionException.java deleted file mode 100644 index 4b189bfb..00000000 --- a/src/main/java/net/minecraft/server/FileConversionException.java +++ /dev/null @@ -1,22 +0,0 @@ -package net.minecraft.server; - -// CraftBukkit - Imported because it's package private - -class FileConversionException extends RuntimeException { - - private FileConversionException(String s, Throwable throwable) { - super(s, throwable); - } - - private FileConversionException(String s) { - super(s); - } - - FileConversionException(String s, PredicateEmptyList predicateemptylist) { - this(s); - } - - FileConversionException(String s, Throwable throwable, PredicateEmptyList predicateemptylist) { - this(s, throwable); - } -} diff --git a/src/main/java/net/minecraft/server/FoodMetaData.java b/src/main/java/net/minecraft/server/FoodMetaData.java deleted file mode 100644 index 41692318..00000000 --- a/src/main/java/net/minecraft/server/FoodMetaData.java +++ /dev/null @@ -1,116 +0,0 @@ -package net.minecraft.server; - -public class FoodMetaData { - - // CraftBukkit start - All made public - public int foodLevel = 20; - public float saturationLevel = 5.0F; - public float exhaustionLevel; - public int foodTickTimer; - private EntityHuman entityhuman; - // CraftBukkit end - private int e = 20; - - public FoodMetaData() { throw new AssertionError("Whoopsie, we missed the bukkit."); } // CraftBukkit start - throw an error - - // CraftBukkit start - added EntityHuman constructor - public FoodMetaData(EntityHuman entityhuman) { - org.apache.commons.lang.Validate.notNull(entityhuman); - this.entityhuman = entityhuman; - } - // CraftBukkit end - - public void eat(int i, float f) { - this.foodLevel = Math.min(i + this.foodLevel, 20); - this.saturationLevel = Math.min(this.saturationLevel + (float) i * f * 2.0F, (float) this.foodLevel); - } - - public void a(ItemFood itemfood, ItemStack itemstack) { - // CraftBukkit start - int oldFoodLevel = foodLevel; - - org.bukkit.event.entity.FoodLevelChangeEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callFoodLevelChangeEvent(entityhuman, itemfood.getNutrition(itemstack) + oldFoodLevel); - - if (!event.isCancelled()) { - this.eat(event.getFoodLevel() - oldFoodLevel, itemfood.getSaturationModifier(itemstack)); - } - - ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutUpdateHealth(((EntityPlayer) entityhuman).getBukkitEntity().getScaledHealth(), entityhuman.getFoodData().foodLevel, entityhuman.getFoodData().saturationLevel)); - // CraftBukkit end - } - - public void a(EntityHuman entityhuman) { - EnumDifficulty enumdifficulty = entityhuman.world.difficulty; - - this.e = this.foodLevel; - if (this.exhaustionLevel > 4.0F) { - this.exhaustionLevel -= 4.0F; - if (this.saturationLevel > 0.0F) { - this.saturationLevel = Math.max(this.saturationLevel - 1.0F, 0.0F); - } else if (enumdifficulty != EnumDifficulty.PEACEFUL) { - // CraftBukkit start - org.bukkit.event.entity.FoodLevelChangeEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callFoodLevelChangeEvent(entityhuman, Math.max(this.foodLevel - 1, 0)); - - if (!event.isCancelled()) { - this.foodLevel = event.getFoodLevel(); - } - - ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutUpdateHealth(((EntityPlayer) entityhuman).getBukkitEntity().getScaledHealth(), this.foodLevel, this.saturationLevel)); - // CraftBukkit end - } - } - - if (entityhuman.world.getGameRules().getBoolean("naturalRegeneration") && this.foodLevel >= 18 && entityhuman.bR()) { - ++this.foodTickTimer; - if (this.foodTickTimer >= 80) { - // CraftBukkit - added RegainReason - entityhuman.heal(1.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.SATIATED); - this.a(3.0F); - this.foodTickTimer = 0; - } - } else if (this.foodLevel <= 0) { - ++this.foodTickTimer; - if (this.foodTickTimer >= 80) { - if (entityhuman.getHealth() > 10.0F || enumdifficulty == EnumDifficulty.HARD || entityhuman.getHealth() > 1.0F && enumdifficulty == EnumDifficulty.NORMAL) { - entityhuman.damageEntity(DamageSource.STARVE, 1.0F); - } - - this.foodTickTimer = 0; - } - } else { - this.foodTickTimer = 0; - } - } - - public void a(NBTTagCompound nbttagcompound) { - if (nbttagcompound.hasKeyOfType("foodLevel", 99)) { - this.foodLevel = nbttagcompound.getInt("foodLevel"); - this.foodTickTimer = nbttagcompound.getInt("foodTickTimer"); - this.saturationLevel = nbttagcompound.getFloat("foodSaturationLevel"); - this.exhaustionLevel = nbttagcompound.getFloat("foodExhaustionLevel"); - } - } - - public void b(NBTTagCompound nbttagcompound) { - nbttagcompound.setInt("foodLevel", this.foodLevel); - nbttagcompound.setInt("foodTickTimer", this.foodTickTimer); - nbttagcompound.setFloat("foodSaturationLevel", this.saturationLevel); - nbttagcompound.setFloat("foodExhaustionLevel", this.exhaustionLevel); - } - - public int getFoodLevel() { - return this.foodLevel; - } - - public boolean c() { - return this.foodLevel < 20; - } - - public void a(float f) { - this.exhaustionLevel = Math.min(this.exhaustionLevel + f, 40.0F); - } - - public float getSaturationLevel() { - return this.saturationLevel; - } -} diff --git a/src/main/java/net/minecraft/server/GroupDataZombie.java b/src/main/java/net/minecraft/server/GroupDataZombie.java deleted file mode 100644 index 340af90f..00000000 --- a/src/main/java/net/minecraft/server/GroupDataZombie.java +++ /dev/null @@ -1,21 +0,0 @@ -package net.minecraft.server; - -// CraftBukkit - package-private import -class GroupDataZombie implements GroupDataEntity { - - public boolean a; - public boolean b; - final EntityZombie c; - - private GroupDataZombie(EntityZombie entityzombie, boolean flag, boolean flag1) { - this.c = entityzombie; - this.a = false; - this.b = false; - this.a = flag; - this.b = flag1; - } - - GroupDataZombie(EntityZombie entityzombie, boolean flag, boolean flag1, EmptyClassZombie emptyclasszombie) { - this(entityzombie, flag, flag1); - } -} diff --git a/src/main/java/net/minecraft/server/HandshakeListener.java b/src/main/java/net/minecraft/server/HandshakeListener.java deleted file mode 100644 index 52bc69b6..00000000 --- a/src/main/java/net/minecraft/server/HandshakeListener.java +++ /dev/null @@ -1,99 +0,0 @@ -package net.minecraft.server; - -import net.minecraft.util.io.netty.util.concurrent.GenericFutureListener; - -// CraftBukkit start -import java.net.InetAddress; -import java.util.HashMap; -// CraftBukkit end - -public class HandshakeListener implements PacketHandshakingInListener { - - // CraftBukkit start - add fields - private static final HashMap<InetAddress, Long> throttleTracker = new HashMap<InetAddress, Long>(); - private static int throttleCounter = 0; - // CraftBukkit end - - private final MinecraftServer a; - private final NetworkManager b; - - public HandshakeListener(MinecraftServer minecraftserver, NetworkManager networkmanager) { - this.a = minecraftserver; - this.b = networkmanager; - } - - public void a(PacketHandshakingInSetProtocol packethandshakinginsetprotocol) { - switch (ProtocolOrdinalWrapper.a[packethandshakinginsetprotocol.c().ordinal()]) { - case 1: - this.b.a(EnumProtocol.LOGIN); - ChatComponentText chatcomponenttext; - - // CraftBukkit start - Connection throttle - try { - long currentTime = System.currentTimeMillis(); - long connectionThrottle = MinecraftServer.getServer().server.getConnectionThrottle(); - InetAddress address = ((java.net.InetSocketAddress) this.b.getSocketAddress()).getAddress(); - - synchronized (throttleTracker) { - if (throttleTracker.containsKey(address) && !"127.0.0.1".equals(address.getHostAddress()) && currentTime - throttleTracker.get(address) < connectionThrottle) { - throttleTracker.put(address, currentTime); - chatcomponenttext = new ChatComponentText("Connection throttled! Please wait before reconnecting."); - this.b.handle(new PacketLoginOutDisconnect(chatcomponenttext), new GenericFutureListener[0]); - this.b.close(chatcomponenttext); - return; - } - - throttleTracker.put(address, currentTime); - throttleCounter++; - if (throttleCounter > 200) { - throttleCounter = 0; - - // Cleanup stale entries - java.util.Iterator iter = throttleTracker.entrySet().iterator(); - while (iter.hasNext()) { - java.util.Map.Entry<InetAddress, Long> entry = (java.util.Map.Entry) iter.next(); - if (entry.getValue() > connectionThrottle) { - iter.remove(); - } - } - } - } - } catch (Throwable t) { - org.apache.logging.log4j.LogManager.getLogger().debug("Failed to check connection throttle", t); - } - // CraftBukkit end - - if (packethandshakinginsetprotocol.d() > 5) { - chatcomponenttext = new ChatComponentText("Outdated server! I\'m still on 1.7.10"); - this.b.handle(new PacketLoginOutDisconnect(chatcomponenttext), new GenericFutureListener[0]); - this.b.close(chatcomponenttext); - } else if (packethandshakinginsetprotocol.d() < 5) { - chatcomponenttext = new ChatComponentText("Outdated client! Please use 1.7.10"); - this.b.handle(new PacketLoginOutDisconnect(chatcomponenttext), new GenericFutureListener[0]); - this.b.close(chatcomponenttext); - } else { - this.b.a((PacketListener) (new LoginListener(this.a, this.b))); - ((LoginListener) this.b.getPacketListener()).hostname = packethandshakinginsetprotocol.b + ":" + packethandshakinginsetprotocol.c; // CraftBukkit - set hostname - } - break; - - case 2: - this.b.a(EnumProtocol.STATUS); - this.b.a((PacketListener) (new PacketStatusListener(this.a, this.b))); - break; - - default: - throw new UnsupportedOperationException("Invalid intention " + packethandshakinginsetprotocol.c()); - } - } - - public void a(IChatBaseComponent ichatbasecomponent) {} - - public void a(EnumProtocol enumprotocol, EnumProtocol enumprotocol1) { - if (enumprotocol1 != EnumProtocol.LOGIN && enumprotocol1 != EnumProtocol.STATUS) { - throw new UnsupportedOperationException("Invalid state " + enumprotocol1); - } - } - - public void a() {} -} diff --git a/src/main/java/net/minecraft/server/IDataManager.java b/src/main/java/net/minecraft/server/IDataManager.java deleted file mode 100644 index e5d578df..00000000 --- a/src/main/java/net/minecraft/server/IDataManager.java +++ /dev/null @@ -1,28 +0,0 @@ -package net.minecraft.server; - -import java.io.File; - -public interface IDataManager { - - WorldData getWorldData(); - - void checkSession() throws ExceptionWorldConflict; // CraftBukkit - throws ExceptionWorldConflict - - IChunkLoader createChunkLoader(WorldProvider worldprovider); - - void saveWorldData(WorldData worlddata, NBTTagCompound nbttagcompound); - - void saveWorldData(WorldData worlddata); - - IPlayerFileData getPlayerFileData(); - - void a(); - - File getDirectory(); - - File getDataFile(String s); - - String g(); - - java.util.UUID getUUID(); // CraftBukkit -} diff --git a/src/main/java/net/minecraft/server/IInventory.java b/src/main/java/net/minecraft/server/IInventory.java deleted file mode 100644 index bfc5c869..00000000 --- a/src/main/java/net/minecraft/server/IInventory.java +++ /dev/null @@ -1,48 +0,0 @@ -package net.minecraft.server; - -import org.bukkit.craftbukkit.entity.CraftHumanEntity; // CraftBukkit - -public interface IInventory { - - int getSize(); - - ItemStack getItem(int i); - - ItemStack splitStack(int i, int j); - - ItemStack splitWithoutUpdate(int i); - - void setItem(int i, ItemStack itemstack); - - String getInventoryName(); - - boolean k_(); - - int getMaxStackSize(); - - void update(); - - boolean a(EntityHuman entityhuman); - - void startOpen(); - - void closeContainer(); - - boolean b(int i, ItemStack itemstack); - - // CraftBukkit start - ItemStack[] getContents(); - - void onOpen(CraftHumanEntity who); - - void onClose(CraftHumanEntity who); - - java.util.List<org.bukkit.entity.HumanEntity> getViewers(); - - org.bukkit.inventory.InventoryHolder getOwner(); - - void setMaxStackSize(int size); - - int MAX_STACK = 64; - // CraftBukkit end -} diff --git a/src/main/java/net/minecraft/server/IRecipe.java b/src/main/java/net/minecraft/server/IRecipe.java deleted file mode 100644 index bb28c12f..00000000 --- a/src/main/java/net/minecraft/server/IRecipe.java +++ /dev/null @@ -1,14 +0,0 @@ -package net.minecraft.server; - -public interface IRecipe { - - boolean a(InventoryCrafting inventorycrafting, World world); - - ItemStack a(InventoryCrafting inventorycrafting); - - int a(); - - ItemStack b(); - - org.bukkit.inventory.Recipe toBukkitRecipe(); // CraftBukkit -} diff --git a/src/main/java/net/minecraft/server/IntHashMap.java b/src/main/java/net/minecraft/server/IntHashMap.java deleted file mode 100644 index fff9d7ac..00000000 --- a/src/main/java/net/minecraft/server/IntHashMap.java +++ /dev/null @@ -1,167 +0,0 @@ -package net.minecraft.server; - -import java.util.HashSet; -import java.util.Set; - -public class IntHashMap { - - private transient IntHashMapEntry[] a = new IntHashMapEntry[16]; - private transient int b; - private int c = 12; - private final float d = 0.75F; - private transient volatile int e; - // private Set f = new HashSet(); // CraftBukkit - expensive and unused - - public IntHashMap() {} - - private static int g(int i) { - i ^= i >>> 20 ^ i >>> 12; - return i ^ i >>> 7 ^ i >>> 4; - } - - private static int a(int i, int j) { - return i & j - 1; - } - - public Object get(int i) { - int j = g(i); - - for (IntHashMapEntry inthashmapentry = this.a[a(j, this.a.length)]; inthashmapentry != null; inthashmapentry = inthashmapentry.c) { - if (inthashmapentry.a == i) { - return inthashmapentry.b; - } - } - - return null; - } - - public boolean b(int i) { - return this.c(i) != null; - } - - final IntHashMapEntry c(int i) { - int j = g(i); - - for (IntHashMapEntry inthashmapentry = this.a[a(j, this.a.length)]; inthashmapentry != null; inthashmapentry = inthashmapentry.c) { - if (inthashmapentry.a == i) { - return inthashmapentry; - } - } - - return null; - } - - public void a(int i, Object object) { - // this.f.add(Integer.valueOf(i)); // CraftBukkit - int j = g(i); - int k = a(j, this.a.length); - - for (IntHashMapEntry inthashmapentry = this.a[k]; inthashmapentry != null; inthashmapentry = inthashmapentry.c) { - if (inthashmapentry.a == i) { - inthashmapentry.b = object; - return; - } - } - - ++this.e; - this.a(j, i, object, k); - } - - private void h(int i) { - IntHashMapEntry[] ainthashmapentry = this.a; - int j = ainthashmapentry.length; - - if (j == 1073741824) { - this.c = Integer.MAX_VALUE; - } else { - IntHashMapEntry[] ainthashmapentry1 = new IntHashMapEntry[i]; - - this.a(ainthashmapentry1); - this.a = ainthashmapentry1; - this.c = (int) ((float) i * this.d); - } - } - - private void a(IntHashMapEntry[] ainthashmapentry) { - IntHashMapEntry[] ainthashmapentry1 = this.a; - int i = ainthashmapentry.length; - - for (int j = 0; j < ainthashmapentry1.length; ++j) { - IntHashMapEntry inthashmapentry = ainthashmapentry1[j]; - - if (inthashmapentry != null) { - ainthashmapentry1[j] = null; - - IntHashMapEntry inthashmapentry1; - - do { - inthashmapentry1 = inthashmapentry.c; - int k = a(inthashmapentry.d, i); - - inthashmapentry.c = ainthashmapentry[k]; - ainthashmapentry[k] = inthashmapentry; - inthashmapentry = inthashmapentry1; - } while (inthashmapentry1 != null); - } - } - } - - public Object d(int i) { - // this.f.remove(Integer.valueOf(i)); // CraftBukkit - IntHashMapEntry inthashmapentry = this.e(i); - - return inthashmapentry == null ? null : inthashmapentry.b; - } - - final IntHashMapEntry e(int i) { - int j = g(i); - int k = a(j, this.a.length); - IntHashMapEntry inthashmapentry = this.a[k]; - - IntHashMapEntry inthashmapentry1; - IntHashMapEntry inthashmapentry2; - - for (inthashmapentry1 = inthashmapentry; inthashmapentry1 != null; inthashmapentry1 = inthashmapentry2) { - inthashmapentry2 = inthashmapentry1.c; - if (inthashmapentry1.a == i) { - ++this.e; - --this.b; - if (inthashmapentry == inthashmapentry1) { - this.a[k] = inthashmapentry2; - } else { - inthashmapentry.c = inthashmapentry2; - } - - return inthashmapentry1; - } - - inthashmapentry = inthashmapentry1; - } - - return inthashmapentry1; - } - - public void c() { - ++this.e; - IntHashMapEntry[] ainthashmapentry = this.a; - - for (int i = 0; i < ainthashmapentry.length; ++i) { - ainthashmapentry[i] = null; - } - - this.b = 0; - } - - private void a(int i, int j, Object object, int k) { - IntHashMapEntry inthashmapentry = this.a[k]; - - this.a[k] = new IntHashMapEntry(i, j, object, inthashmapentry); - if (this.b++ >= this.c) { - this.h(2 * this.a.length); - } - } - - static int f(int i) { - return g(i); - } -} diff --git a/src/main/java/net/minecraft/server/InventoryCraftResult.java b/src/main/java/net/minecraft/server/InventoryCraftResult.java deleted file mode 100644 index 7db82900..00000000 --- a/src/main/java/net/minecraft/server/InventoryCraftResult.java +++ /dev/null @@ -1,96 +0,0 @@ -package net.minecraft.server; - -// CraftBukkit start -import org.bukkit.craftbukkit.entity.CraftHumanEntity; -import org.bukkit.entity.HumanEntity; -// CraftBukkit end - -public class InventoryCraftResult implements IInventory { - - private ItemStack[] items = new ItemStack[1]; - - // CraftBukkit start - private int maxStack = MAX_STACK; - - public ItemStack[] getContents() { - return this.items; - } - - public org.bukkit.inventory.InventoryHolder getOwner() { - return null; // Result slots don't get an owner - } - - // Don't need a transaction; the InventoryCrafting keeps track of it for us - public void onOpen(CraftHumanEntity who) {} - public void onClose(CraftHumanEntity who) {} - public java.util.List<HumanEntity> getViewers() { - return new java.util.ArrayList<HumanEntity>(); - } - - public void setMaxStackSize(int size) { - maxStack = size; - } - // CraftBukkit end - - public InventoryCraftResult() {} - - public int getSize() { - return 1; - } - - public ItemStack getItem(int i) { - return this.items[0]; - } - - public String getInventoryName() { - return "Result"; - } - - public boolean k_() { - return false; - } - - public ItemStack splitStack(int i, int j) { - if (this.items[0] != null) { - ItemStack itemstack = this.items[0]; - - this.items[0] = null; - return itemstack; - } else { - return null; - } - } - - public ItemStack splitWithoutUpdate(int i) { - if (this.items[0] != null) { - ItemStack itemstack = this.items[0]; - - this.items[0] = null; - return itemstack; - } else { - return null; - } - } - - public void setItem(int i, ItemStack itemstack) { - this.items[0] = itemstack; - } - - public int getMaxStackSize() { - return maxStack; // CraftBukkit - } - - public void update() {} - - public boolean a(EntityHuman entityhuman) { - return true; - } - - public void startOpen() {} - - public void closeContainer() {} - - public boolean b(int i, ItemStack itemstack) { - return true; - } -} diff --git a/src/main/java/net/minecraft/server/InventoryCrafting.java b/src/main/java/net/minecraft/server/InventoryCrafting.java deleted file mode 100644 index 5b46597d..00000000 --- a/src/main/java/net/minecraft/server/InventoryCrafting.java +++ /dev/null @@ -1,149 +0,0 @@ -package net.minecraft.server; - -// CraftBukkit start -import java.util.List; - -import org.bukkit.craftbukkit.entity.CraftHumanEntity; -import org.bukkit.entity.HumanEntity; -import org.bukkit.event.inventory.InventoryType; -// CraftBukkit end - -public class InventoryCrafting implements IInventory { - - private ItemStack[] items; - private int b; - private Container c; - - // CraftBukkit start - add fields - public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>(); - public IRecipe currentRecipe; - public IInventory resultInventory; - private EntityHuman owner; - private int maxStack = MAX_STACK; - - public ItemStack[] getContents() { - return this.items; - } - - public void onOpen(CraftHumanEntity who) { - transaction.add(who); - } - - public InventoryType getInvType() { - return items.length == 4 ? InventoryType.CRAFTING : InventoryType.WORKBENCH; - } - - public void onClose(CraftHumanEntity who) { - transaction.remove(who); - } - - public List<HumanEntity> getViewers() { - return transaction; - } - - public org.bukkit.inventory.InventoryHolder getOwner() { - return owner.getBukkitEntity(); - } - - public void setMaxStackSize(int size) { - maxStack = size; - resultInventory.setMaxStackSize(size); - } - - public InventoryCrafting(Container container, int i, int j, EntityHuman player) { - this(container, i, j); - this.owner = player; - } - // CraftBukkit end - - public InventoryCrafting(Container container, int i, int j) { - int k = i * j; - - this.items = new ItemStack[k]; - this.c = container; - this.b = i; - } - - public int getSize() { - return this.items.length; - } - - public ItemStack getItem(int i) { - return i >= this.getSize() ? null : this.items[i]; - } - - public ItemStack b(int i, int j) { - if (i >= 0 && i < this.b) { - int k = i + j * this.b; - - return this.getItem(k); - } else { - return null; - } - } - - public String getInventoryName() { - return "container.crafting"; - } - - public boolean k_() { - return false; - } - - public ItemStack splitWithoutUpdate(int i) { - if (this.items[i] != null) { - ItemStack itemstack = this.items[i]; - - this.items[i] = null; - return itemstack; - } else { - return null; - } - } - - public ItemStack splitStack(int i, int j) { - if (this.items[i] != null) { - ItemStack itemstack; - - if (this.items[i].count <= j) { - itemstack = this.items[i]; - this.items[i] = null; - this.c.a((IInventory) this); - return itemstack; - } else { - itemstack = this.items[i].a(j); - if (this.items[i].count == 0) { - this.items[i] = null; - } - - this.c.a((IInventory) this); - return itemstack; - } - } else { - return null; - } - } - - public void setItem(int i, ItemStack itemstack) { - this.items[i] = itemstack; - this.c.a((IInventory) this); - } - - public int getMaxStackSize() { - return maxStack; // CraftBukkit - } - - public void update() {} - - public boolean a(EntityHuman entityhuman) { - return true; - } - - public void startOpen() {} - - public void closeContainer() {} - - public boolean b(int i, ItemStack itemstack) { - return true; - } -} diff --git a/src/main/java/net/minecraft/server/InventoryEnderChest.java b/src/main/java/net/minecraft/server/InventoryEnderChest.java deleted file mode 100644 index ed23f787..00000000 --- a/src/main/java/net/minecraft/server/InventoryEnderChest.java +++ /dev/null @@ -1,110 +0,0 @@ -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 InventoryEnderChest extends InventorySubcontainer { - - private TileEntityEnderChest a; - - // CraftBukkit start - add fields and methods - 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; - } - - public int getMaxStackSize() { - return maxStack; - } - // CraftBukkit end - - public InventoryEnderChest() { - super("container.enderchest", false, 27); - } - - public void a(TileEntityEnderChest tileentityenderchest) { - this.a = tileentityenderchest; - } - - public void a(NBTTagList nbttaglist) { - int i; - - for (i = 0; i < this.getSize(); ++i) { - this.setItem(i, (ItemStack) null); - } - - for (i = 0; i < nbttaglist.size(); ++i) { - NBTTagCompound nbttagcompound = nbttaglist.get(i); - int j = nbttagcompound.getByte("Slot") & 255; - - if (j >= 0 && j < this.getSize()) { - this.setItem(j, ItemStack.createStack(nbttagcompound)); - } - } - } - - public NBTTagList h() { - NBTTagList nbttaglist = new NBTTagList(); - - for (int i = 0; i < this.getSize(); ++i) { - ItemStack itemstack = this.getItem(i); - - if (itemstack != null) { - NBTTagCompound nbttagcompound = new NBTTagCompound(); - - nbttagcompound.setByte("Slot", (byte) i); - itemstack.save(nbttagcompound); - nbttaglist.add(nbttagcompound); - } - } - - return nbttaglist; - } - - public boolean a(EntityHuman entityhuman) { - return this.a != null && !this.a.a(entityhuman) ? false : super.a(entityhuman); - } - - public void startOpen() { - if (this.a != null) { - this.a.a(); - } - - super.startOpen(); - } - - public void closeContainer() { - if (this.a != null) { - this.a.b(); - } - - super.closeContainer(); - this.a = null; - } -} diff --git a/src/main/java/net/minecraft/server/InventoryHorseChest.java b/src/main/java/net/minecraft/server/InventoryHorseChest.java deleted file mode 100644 index 01289950..00000000 --- a/src/main/java/net/minecraft/server/InventoryHorseChest.java +++ /dev/null @@ -1,60 +0,0 @@ -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 InventoryHorseChest extends InventorySubcontainer { - - public InventoryHorseChest(String s, int i) { - super(s, false, i); - } - - // CraftBukkit start - add fields and methods - public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>(); - private EntityHorse horse; - private int maxStack = MAX_STACK; - - public InventoryHorseChest(String s, int i, EntityHorse horse) { - this(s, i); - this.horse = horse; - } - - @Override - public ItemStack[] getContents() { - return this.items; - } - - @Override - public void onOpen(CraftHumanEntity who) { - transaction.add(who); - } - - @Override - public void onClose(CraftHumanEntity who) { - transaction.remove(who); - } - - @Override - public List<HumanEntity> getViewers() { - return transaction; - } - - @Override - public org.bukkit.inventory.InventoryHolder getOwner() { - return (org.bukkit.entity.Horse) this.horse.getBukkitEntity(); - } - - @Override - public void setMaxStackSize(int size) { - maxStack = size; - } - - @Override - public int getMaxStackSize() { - return maxStack; - } - // CraftBukkit end -} diff --git a/src/main/java/net/minecraft/server/InventoryLargeChest.java b/src/main/java/net/minecraft/server/InventoryLargeChest.java deleted file mode 100644 index 263de7c5..00000000 --- a/src/main/java/net/minecraft/server/InventoryLargeChest.java +++ /dev/null @@ -1,129 +0,0 @@ -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 InventoryLargeChest implements IInventory { - - private String a; - public IInventory left; // CraftBukkit - private -> public - public IInventory right; // CraftBukkit - private -> public - - // CraftBukkit start - add fields and methods - public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>(); - - public ItemStack[] getContents() { - ItemStack[] result = new ItemStack[this.getSize()]; - for (int i = 0; i < result.length; i++) { - result[i] = this.getItem(i); - } - return result; - } - - public void onOpen(CraftHumanEntity who) { - this.left.onOpen(who); - this.right.onOpen(who); - transaction.add(who); - } - - public void onClose(CraftHumanEntity who) { - this.left.onClose(who); - this.right.onClose(who); - transaction.remove(who); - } - - public List<HumanEntity> getViewers() { - return transaction; - } - - public org.bukkit.inventory.InventoryHolder getOwner() { - return null; // This method won't be called since CraftInventoryDoubleChest doesn't defer to here - } - - public void setMaxStackSize(int size) { - this.left.setMaxStackSize(size); - this.right.setMaxStackSize(size); - } - // CraftBukkit end - - public InventoryLargeChest(String s, IInventory iinventory, IInventory iinventory1) { - this.a = s; - if (iinventory == null) { - iinventory = iinventory1; - } - - if (iinventory1 == null) { - iinventory1 = iinventory; - } - - this.left = iinventory; - this.right = iinventory1; - } - - public int getSize() { - return this.left.getSize() + this.right.getSize(); - } - - public boolean a(IInventory iinventory) { - return this.left == iinventory || this.right == iinventory; - } - - public String getInventoryName() { - return this.left.k_() ? this.left.getInventoryName() : (this.right.k_() ? this.right.getInventoryName() : this.a); - } - - public boolean k_() { - return this.left.k_() || this.right.k_(); - } - - public ItemStack getItem(int i) { - return i >= this.left.getSize() ? this.right.getItem(i - this.left.getSize()) : this.left.getItem(i); - } - - public ItemStack splitStack(int i, int j) { - return i >= this.left.getSize() ? this.right.splitStack(i - this.left.getSize(), j) : this.left.splitStack(i, j); - } - - public ItemStack splitWithoutUpdate(int i) { - return i >= this.left.getSize() ? this.right.splitWithoutUpdate(i - this.left.getSize()) : this.left.splitWithoutUpdate(i); - } - - public void setItem(int i, ItemStack itemstack) { - if (i >= this.left.getSize()) { - this.right.setItem(i - this.left.getSize(), itemstack); - } else { - this.left.setItem(i, itemstack); - } - } - - public int getMaxStackSize() { - return Math.min(this.left.getMaxStackSize(), this.right.getMaxStackSize()); // CraftBukkit - check both sides - } - - public void update() { - this.left.update(); - this.right.update(); - } - - public boolean a(EntityHuman entityhuman) { - return this.left.a(entityhuman) && this.right.a(entityhuman); - } - - public void startOpen() { - this.left.startOpen(); - this.right.startOpen(); - } - - public void closeContainer() { - this.left.closeContainer(); - this.right.closeContainer(); - } - - public boolean b(int i, ItemStack itemstack) { - return true; - } -} diff --git a/src/main/java/net/minecraft/server/InventoryMerchant.java b/src/main/java/net/minecraft/server/InventoryMerchant.java deleted file mode 100644 index b5617b32..00000000 --- a/src/main/java/net/minecraft/server/InventoryMerchant.java +++ /dev/null @@ -1,192 +0,0 @@ -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 InventoryMerchant implements IInventory { - - private final IMerchant merchant; - private ItemStack[] itemsInSlots = new ItemStack[3]; - private final EntityHuman player; - private MerchantRecipe recipe; - private int e; - - // CraftBukkit start - add fields and methods - public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>(); - private int maxStack = MAX_STACK; - - public ItemStack[] getContents() { - return this.itemsInSlots; - } - - 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 i) { - maxStack = i; - } - - public org.bukkit.inventory.InventoryHolder getOwner() { - return player.getBukkitEntity(); - } - // CraftBukkit end - - public InventoryMerchant(EntityHuman entityhuman, IMerchant imerchant) { - this.player = entityhuman; - this.merchant = imerchant; - } - - public int getSize() { - return this.itemsInSlots.length; - } - - public ItemStack getItem(int i) { - return this.itemsInSlots[i]; - } - - public ItemStack splitStack(int i, int j) { - if (this.itemsInSlots[i] != null) { - ItemStack itemstack; - - if (i == 2) { - itemstack = this.itemsInSlots[i]; - this.itemsInSlots[i] = null; - return itemstack; - } else if (this.itemsInSlots[i].count <= j) { - itemstack = this.itemsInSlots[i]; - this.itemsInSlots[i] = null; - if (this.d(i)) { - this.h(); - } - - return itemstack; - } else { - itemstack = this.itemsInSlots[i].a(j); - if (this.itemsInSlots[i].count == 0) { - this.itemsInSlots[i] = null; - } - - if (this.d(i)) { - this.h(); - } - - return itemstack; - } - } else { - return null; - } - } - - private boolean d(int i) { - return i == 0 || i == 1; - } - - public ItemStack splitWithoutUpdate(int i) { - if (this.itemsInSlots[i] != null) { - ItemStack itemstack = this.itemsInSlots[i]; - - this.itemsInSlots[i] = null; - return itemstack; - } else { - return null; - } - } - - public void setItem(int i, ItemStack itemstack) { - this.itemsInSlots[i] = itemstack; - if (itemstack != null && itemstack.count > this.getMaxStackSize()) { - itemstack.count = this.getMaxStackSize(); - } - - if (this.d(i)) { - this.h(); - } - } - - public String getInventoryName() { - return "mob.villager"; - } - - public boolean k_() { - return false; - } - - public int getMaxStackSize() { - return maxStack; // CraftBukkit - } - - public boolean a(EntityHuman entityhuman) { - return this.merchant.b() == entityhuman; - } - - public void startOpen() {} - - public void closeContainer() {} - - public boolean b(int i, ItemStack itemstack) { - return true; - } - - public void update() { - this.h(); - } - - public void h() { - this.recipe = null; - ItemStack itemstack = this.itemsInSlots[0]; - ItemStack itemstack1 = this.itemsInSlots[1]; - - if (itemstack == null) { - itemstack = itemstack1; - itemstack1 = null; - } - - if (itemstack == null) { - this.setItem(2, (ItemStack) null); - } else { - MerchantRecipeList merchantrecipelist = this.merchant.getOffers(this.player); - - if (merchantrecipelist != null) { - MerchantRecipe merchantrecipe = merchantrecipelist.a(itemstack, itemstack1, this.e); - - 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 && !merchantrecipe.g()) { - this.recipe = merchantrecipe; - this.setItem(2, merchantrecipe.getBuyItem3().cloneItemStack()); - } else { - this.setItem(2, (ItemStack) null); - } - } else { - this.setItem(2, (ItemStack) null); - } - } - } - - this.merchant.a_(this.getItem(2)); - } - - public MerchantRecipe getRecipe() { - return this.recipe; - } - - public void c(int i) { - this.e = i; - this.h(); - } -} diff --git a/src/main/java/net/minecraft/server/InventorySubcontainer.java b/src/main/java/net/minecraft/server/InventorySubcontainer.java deleted file mode 100644 index 9a775e4c..00000000 --- a/src/main/java/net/minecraft/server/InventorySubcontainer.java +++ /dev/null @@ -1,120 +0,0 @@ -package net.minecraft.server; - -import java.util.ArrayList; -import java.util.List; - -public abstract class InventorySubcontainer implements IInventory { // CraftBukkit - abstract - - private String a; - private int b; - protected ItemStack[] items; // CraftBukkit - protected - private List d; - private boolean e; - - public InventorySubcontainer(String s, boolean flag, int i) { - this.a = s; - this.e = flag; - this.b = i; - this.items = new ItemStack[i]; - } - - public void a(IInventoryListener iinventorylistener) { - if (this.d == null) { - this.d = new ArrayList(); - } - - this.d.add(iinventorylistener); - } - - public void b(IInventoryListener iinventorylistener) { - this.d.remove(iinventorylistener); - } - - public ItemStack getItem(int i) { - return i >= 0 && i < this.items.length ? this.items[i] : null; - } - - public ItemStack splitStack(int i, int j) { - if (this.items[i] != null) { - ItemStack itemstack; - - if (this.items[i].count <= j) { - itemstack = this.items[i]; - this.items[i] = null; - this.update(); - return itemstack; - } else { - itemstack = this.items[i].a(j); - if (this.items[i].count == 0) { - this.items[i] = null; - } - - this.update(); - return itemstack; - } - } else { - return null; - } - } - - public ItemStack splitWithoutUpdate(int i) { - if (this.items[i] != null) { - ItemStack itemstack = this.items[i]; - - this.items[i] = null; - return itemstack; - } else { - return null; - } - } - - public void setItem(int i, ItemStack itemstack) { - this.items[i] = itemstack; - if (itemstack != null && itemstack.count > this.getMaxStackSize()) { - itemstack.count = this.getMaxStackSize(); - } - - this.update(); - } - - public int getSize() { - return this.b; - } - - public String getInventoryName() { - return this.a; - } - - public boolean k_() { - return this.e; - } - - public void a(String s) { - this.e = true; - this.a = s; - } - - public int getMaxStackSize() { - return 64; - } - - public void update() { - if (this.d != null) { - for (int i = 0; i < this.d.size(); ++i) { - ((IInventoryListener) this.d.get(i)).a(this); - } - } - } - - public boolean a(EntityHuman entityhuman) { - return true; - } - - public void startOpen() {} - - public void closeContainer() {} - - public boolean b(int i, ItemStack itemstack) { - return true; - } -} diff --git a/src/main/java/net/minecraft/server/Item.java b/src/main/java/net/minecraft/server/Item.java deleted file mode 100644 index 4382f1ab..00000000 --- a/src/main/java/net/minecraft/server/Item.java +++ /dev/null @@ -1,503 +0,0 @@ -package net.minecraft.server; - -import java.util.HashSet; -import java.util.Iterator; -import java.util.Random; -import java.util.UUID; - -import net.minecraft.util.com.google.common.collect.HashMultimap; -import net.minecraft.util.com.google.common.collect.Multimap; -import net.minecraft.util.com.google.common.collect.Sets; - -public class Item { - - public static final RegistryMaterials REGISTRY = new RegistryMaterials(); - protected static final UUID f = UUID.fromString("CB3F55D3-645C-4F38-A497-9C13A33DB5CF"); - private CreativeModeTab a; - protected static Random g = new Random(); - protected int maxStackSize = 64; - private int durability; - protected boolean i; - protected boolean j; - private Item craftingResult; - private String d; - private String name; - protected String l; - - public Item() {} - - public static int getId(Item item) { - return item == null ? 0 : REGISTRY.b(item); - } - - public static Item getById(int i) { - return (Item) REGISTRY.a(i); - } - - public static Item getItemOf(Block block) { - return getById(Block.getId(block)); - } - - public static void l() { - REGISTRY.a(256, "iron_shovel", (new ItemSpade(EnumToolMaterial.IRON)).c("shovelIron").f("iron_shovel")); - REGISTRY.a(257, "iron_pickaxe", (new ItemPickaxe(EnumToolMaterial.IRON)).c("pickaxeIron").f("iron_pickaxe")); - REGISTRY.a(258, "iron_axe", (new ItemAxe(EnumToolMaterial.IRON)).c("hatchetIron").f("iron_axe")); - REGISTRY.a(259, "flint_and_steel", (new ItemFlintAndSteel()).c("flintAndSteel").f("flint_and_steel")); - REGISTRY.a(260, "apple", (new ItemFood(4, 0.3F, false)).c("apple").f("apple")); - REGISTRY.a(261, "bow", (new ItemBow()).c("bow").f("bow")); - REGISTRY.a(262, "arrow", (new Item()).c("arrow").a(CreativeModeTab.j).f("arrow")); - REGISTRY.a(263, "coal", (new ItemCoal()).c("coal").f("coal")); - REGISTRY.a(264, "diamond", (new Item()).c("diamond").a(CreativeModeTab.l).f("diamond")); - REGISTRY.a(265, "iron_ingot", (new Item()).c("ingotIron").a(CreativeModeTab.l).f("iron_ingot")); - REGISTRY.a(266, "gold_ingot", (new Item()).c("ingotGold").a(CreativeModeTab.l).f("gold_ingot")); - REGISTRY.a(267, "iron_sword", (new ItemSword(EnumToolMaterial.IRON)).c("swordIron").f("iron_sword")); - REGISTRY.a(268, "wooden_sword", (new ItemSword(EnumToolMaterial.WOOD)).c("swordWood").f("wood_sword")); - REGISTRY.a(269, "wooden_shovel", (new ItemSpade(EnumToolMaterial.WOOD)).c("shovelWood").f("wood_shovel")); - REGISTRY.a(270, "wooden_pickaxe", (new ItemPickaxe(EnumToolMaterial.WOOD)).c("pickaxeWood").f("wood_pickaxe")); - REGISTRY.a(271, "wooden_axe", (new ItemAxe(EnumToolMaterial.WOOD)).c("hatchetWood").f("wood_axe")); - REGISTRY.a(272, "stone_sword", (new ItemSword(EnumToolMaterial.STONE)).c("swordStone").f("stone_sword")); - REGISTRY.a(273, "stone_shovel", (new ItemSpade(EnumToolMaterial.STONE)).c("shovelStone").f("stone_shovel")); - REGISTRY.a(274, "stone_pickaxe", (new ItemPickaxe(EnumToolMaterial.STONE)).c("pickaxeStone").f("stone_pickaxe")); - REGISTRY.a(275, "stone_axe", (new ItemAxe(EnumToolMaterial.STONE)).c("hatchetStone").f("stone_axe")); - REGISTRY.a(276, "diamond_sword", (new ItemSword(EnumToolMaterial.DIAMOND)).c("swordDiamond").f("diamond_sword")); - REGISTRY.a(277, "diamond_shovel", (new ItemSpade(EnumToolMaterial.DIAMOND)).c("shovelDiamond").f("diamond_shovel")); - REGISTRY.a(278, "diamond_pickaxe", (new ItemPickaxe(EnumToolMaterial.DIAMOND)).c("pickaxeDiamond").f("diamond_pickaxe")); - REGISTRY.a(279, "diamond_axe", (new ItemAxe(EnumToolMaterial.DIAMOND)).c("hatchetDiamond").f("diamond_axe")); - REGISTRY.a(280, "stick", (new Item()).q().c("stick").a(CreativeModeTab.l).f("stick")); - REGISTRY.a(281, "bowl", (new Item()).c("bowl").a(CreativeModeTab.l).f("bowl")); - REGISTRY.a(282, "mushroom_stew", (new ItemSoup(6)).c("mushroomStew").f("mushroom_stew")); - REGISTRY.a(283, "golden_sword", (new ItemSword(EnumToolMaterial.GOLD)).c("swordGold").f("gold_sword")); - REGISTRY.a(284, "golden_shovel", (new ItemSpade(EnumToolMaterial.GOLD)).c("shovelGold").f("gold_shovel")); - REGISTRY.a(285, "golden_pickaxe", (new ItemPickaxe(EnumToolMaterial.GOLD)).c("pickaxeGold").f("gold_pickaxe")); - REGISTRY.a(286, "golden_axe", (new ItemAxe(EnumToolMaterial.GOLD)).c("hatchetGold").f("gold_axe")); - REGISTRY.a(287, "string", (new ItemReed(Blocks.TRIPWIRE)).c("string").a(CreativeModeTab.l).f("string")); - REGISTRY.a(288, "feather", (new Item()).c("feather").a(CreativeModeTab.l).f("feather")); - REGISTRY.a(289, "gunpowder", (new Item()).c("sulphur").e(PotionBrewer.k).a(CreativeModeTab.l).f("gunpowder")); - REGISTRY.a(290, "wooden_hoe", (new ItemHoe(EnumToolMaterial.WOOD)).c("hoeWood").f("wood_hoe")); - REGISTRY.a(291, "stone_hoe", (new ItemHoe(EnumToolMaterial.STONE)).c("hoeStone").f("stone_hoe")); - REGISTRY.a(292, "iron_hoe", (new ItemHoe(EnumToolMaterial.IRON)).c("hoeIron").f("iron_hoe")); - REGISTRY.a(293, "diamond_hoe", (new ItemHoe(EnumToolMaterial.DIAMOND)).c("hoeDiamond").f("diamond_hoe")); - REGISTRY.a(294, "golden_hoe", (new ItemHoe(EnumToolMaterial.GOLD)).c("hoeGold").f("gold_hoe")); - REGISTRY.a(295, "wheat_seeds", (new ItemSeeds(Blocks.CROPS, Blocks.SOIL)).c("seeds").f("seeds_wheat")); - REGISTRY.a(296, "wheat", (new Item()).c("wheat").a(CreativeModeTab.l).f("wheat")); - REGISTRY.a(297, "bread", (new ItemFood(5, 0.6F, false)).c("bread").f("bread")); - REGISTRY.a(298, "leather_helmet", (new ItemArmor(EnumArmorMaterial.CLOTH, 0, 0)).c("helmetCloth").f("leather_helmet")); - REGISTRY.a(299, "leather_chestplate", (new ItemArmor(EnumArmorMaterial.CLOTH, 0, 1)).c("chestplateCloth").f("leather_chestplate")); - REGISTRY.a(300, "leather_leggings", (new ItemArmor(EnumArmorMaterial.CLOTH, 0, 2)).c("leggingsCloth").f("leather_leggings")); - REGISTRY.a(301, "leather_boots", (new ItemArmor(EnumArmorMaterial.CLOTH, 0, 3)).c("bootsCloth").f("leather_boots")); - REGISTRY.a(302, "chainmail_helmet", (new ItemArmor(EnumArmorMaterial.CHAIN, 1, 0)).c("helmetChain").f("chainmail_helmet")); - REGISTRY.a(303, "chainmail_chestplate", (new ItemArmor(EnumArmorMaterial.CHAIN, 1, 1)).c("chestplateChain").f("chainmail_chestplate")); - REGISTRY.a(304, "chainmail_leggings", (new ItemArmor(EnumArmorMaterial.CHAIN, 1, 2)).c("leggingsChain").f("chainmail_leggings")); - REGISTRY.a(305, "chainmail_boots", (new ItemArmor(EnumArmorMaterial.CHAIN, 1, 3)).c("bootsChain").f("chainmail_boots")); - REGISTRY.a(306, "iron_helmet", (new ItemArmor(EnumArmorMaterial.IRON, 2, 0)).c("helmetIron").f("iron_helmet")); - REGISTRY.a(307, "iron_chestplate", (new ItemArmor(EnumArmorMaterial.IRON, 2, 1)).c("chestplateIron").f("iron_chestplate")); - REGISTRY.a(308, "iron_leggings", (new ItemArmor(EnumArmorMaterial.IRON, 2, 2)).c("leggingsIron").f("iron_leggings")); - REGISTRY.a(309, "iron_boots", (new ItemArmor(EnumArmorMaterial.IRON, 2, 3)).c("bootsIron").f("iron_boots")); - REGISTRY.a(310, "diamond_helmet", (new ItemArmor(EnumArmorMaterial.DIAMOND, 3, 0)).c("helmetDiamond").f("diamond_helmet")); - REGISTRY.a(311, "diamond_chestplate", (new ItemArmor(EnumArmorMaterial.DIAMOND, 3, 1)).c("chestplateDiamond").f("diamond_chestplate")); - REGISTRY.a(312, "diamond_leggings", (new ItemArmor(EnumArmorMaterial.DIAMOND, 3, 2)).c("leggingsDiamond").f("diamond_leggings")); - REGISTRY.a(313, "diamond_boots", (new ItemArmor(EnumArmorMaterial.DIAMOND, 3, 3)).c("bootsDiamond").f("diamond_boots")); - REGISTRY.a(314, "golden_helmet", (new ItemArmor(EnumArmorMaterial.GOLD, 4, 0)).c("helmetGold").f("gold_helmet")); - REGISTRY.a(315, "golden_chestplate", (new ItemArmor(EnumArmorMaterial.GOLD, 4, 1)).c("chestplateGold").f("gold_chestplate")); - REGISTRY.a(316, "golden_leggings", (new ItemArmor(EnumArmorMaterial.GOLD, 4, 2)).c("leggingsGold").f("gold_leggings")); - REGISTRY.a(317, "golden_boots", (new ItemArmor(EnumArmorMaterial.GOLD, 4, 3)).c("bootsGold").f("gold_boots")); - REGISTRY.a(318, "flint", (new Item()).c("flint").a(CreativeModeTab.l).f("flint")); - REGISTRY.a(319, "porkchop", (new ItemFood(3, 0.3F, true)).c("porkchopRaw").f("porkchop_raw")); - REGISTRY.a(320, "cooked_porkchop", (new ItemFood(8, 0.8F, true)).c("porkchopCooked").f("porkchop_cooked")); - REGISTRY.a(321, "painting", (new ItemHanging(EntityPainting.class)).c("painting").f("painting")); - REGISTRY.a(322, "golden_apple", (new ItemGoldenApple(4, 1.2F, false)).j().a(MobEffectList.REGENERATION.id, 5, 1, 1.0F).c("appleGold").f("apple_golden")); - REGISTRY.a(323, "sign", (new ItemSign()).c("sign").f("sign")); - REGISTRY.a(324, "wooden_door", (new ItemDoor(Material.WOOD)).c("doorWood").f("door_wood")); - Item item = (new ItemBucket(Blocks.AIR)).c("bucket").e(16).f("bucket_empty"); - - REGISTRY.a(325, "bucket", item); - REGISTRY.a(326, "water_bucket", (new ItemBucket(Blocks.WATER)).c("bucketWater").c(item).f("bucket_water")); - REGISTRY.a(327, "lava_bucket", (new ItemBucket(Blocks.LAVA)).c("bucketLava").c(item).f("bucket_lava")); - REGISTRY.a(328, "minecart", (new ItemMinecart(0)).c("minecart").f("minecart_normal")); - REGISTRY.a(329, "saddle", (new ItemSaddle()).c("saddle").f("saddle")); - REGISTRY.a(330, "iron_door", (new ItemDoor(Material.ORE)).c("doorIron").f("door_iron")); - REGISTRY.a(331, "redstone", (new ItemRedstone()).c("redstone").e(PotionBrewer.i).f("redstone_dust")); - REGISTRY.a(332, "snowball", (new ItemSnowball()).c("snowball").f("snowball")); - REGISTRY.a(333, "boat", (new ItemBoat()).c("boat").f("boat")); - REGISTRY.a(334, "leather", (new Item()).c("leather").a(CreativeModeTab.l).f("leather")); - REGISTRY.a(335, "milk_bucket", (new ItemMilkBucket()).c("milk").c(item).f("bucket_milk")); - REGISTRY.a(336, "brick", (new Item()).c("brick").a(CreativeModeTab.l).f("brick")); - REGISTRY.a(337, "clay_ball", (new Item()).c("clay").a(CreativeModeTab.l).f("clay_ball")); - REGISTRY.a(338, "reeds", (new ItemReed(Blocks.SUGAR_CANE_BLOCK)).c("reeds").a(CreativeModeTab.l).f("reeds")); - REGISTRY.a(339, "paper", (new Item()).c("paper").a(CreativeModeTab.f).f("paper")); - REGISTRY.a(340, "book", (new ItemBook()).c("book").a(CreativeModeTab.f).f("book_normal")); - REGISTRY.a(341, "slime_ball", (new Item()).c("slimeball").a(CreativeModeTab.f).f("slimeball")); - REGISTRY.a(342, "chest_minecart", (new ItemMinecart(1)).c("minecartChest").f("minecart_chest")); - REGISTRY.a(343, "furnace_minecart", (new ItemMinecart(2)).c("minecartFurnace").f("minecart_furnace")); - REGISTRY.a(344, "egg", (new ItemEgg()).c("egg").f("egg")); - REGISTRY.a(345, "compass", (new Item()).c("compass").a(CreativeModeTab.i).f("compass")); - REGISTRY.a(346, "fishing_rod", (new ItemFishingRod()).c("fishingRod").f("fishing_rod")); - REGISTRY.a(347, "clock", (new Item()).c("clock").a(CreativeModeTab.i).f("clock")); - REGISTRY.a(348, "glowstone_dust", (new Item()).c("yellowDust").e(PotionBrewer.j).a(CreativeModeTab.l).f("glowstone_dust")); - REGISTRY.a(349, "fish", (new ItemFish(false)).c("fish").f("fish_raw").a(true)); - REGISTRY.a(350, "cooked_fished", (new ItemFish(true)).c("fish").f("fish_cooked").a(true)); - REGISTRY.a(351, "dye", (new ItemDye()).c("dyePowder").f("dye_powder")); - REGISTRY.a(352, "bone", (new Item()).c("bone").q().a(CreativeModeTab.f).f("bone")); - REGISTRY.a(353, "sugar", (new Item()).c("sugar").e(PotionBrewer.b).a(CreativeModeTab.l).f("sugar")); - REGISTRY.a(354, "cake", (new ItemReed(Blocks.CAKE_BLOCK)).e(1).c("cake").a(CreativeModeTab.h).f("cake")); - REGISTRY.a(355, "bed", (new ItemBed()).e(1).c("bed").f("bed")); - REGISTRY.a(356, "repeater", (new ItemReed(Blocks.DIODE_OFF)).c("diode").a(CreativeModeTab.d).f("repeater")); - REGISTRY.a(357, "cookie", (new ItemFood(2, 0.1F, false)).c("cookie").f("cookie")); - REGISTRY.a(358, "filled_map", (new ItemWorldMap()).c("map").f("map_filled")); - REGISTRY.a(359, "shears", (new ItemShears()).c("shears").f("shears")); - REGISTRY.a(360, "melon", (new ItemFood(2, 0.3F, false)).c("melon").f("melon")); - REGISTRY.a(361, "pumpkin_seeds", (new ItemSeeds(Blocks.PUMPKIN_STEM, Blocks.SOIL)).c("seeds_pumpkin").f("seeds_pumpkin")); - REGISTRY.a(362, "melon_seeds", (new ItemSeeds(Blocks.MELON_STEM, Blocks.SOIL)).c("seeds_melon").f("seeds_melon")); - REGISTRY.a(363, "beef", (new ItemFood(3, 0.3F, true)).c("beefRaw").f("beef_raw")); - REGISTRY.a(364, "cooked_beef", (new ItemFood(8, 0.8F, true)).c("beefCooked").f("beef_cooked")); - REGISTRY.a(365, "chicken", (new ItemFood(2, 0.3F, true)).a(MobEffectList.HUNGER.id, 30, 0, 0.3F).c("chickenRaw").f("chicken_raw")); - REGISTRY.a(366, "cooked_chicken", (new ItemFood(6, 0.6F, true)).c("chickenCooked").f("chicken_cooked")); - REGISTRY.a(367, "rotten_flesh", (new ItemFood(4, 0.1F, true)).a(MobEffectList.HUNGER.id, 30, 0, 0.8F).c("rottenFlesh").f("rotten_flesh")); - REGISTRY.a(368, "ender_pearl", (new ItemEnderPearl()).c("enderPearl").f("ender_pearl")); - REGISTRY.a(369, "blaze_rod", (new Item()).c("blazeRod").a(CreativeModeTab.l).f("blaze_rod")); - REGISTRY.a(370, "ghast_tear", (new Item()).c("ghastTear").e(PotionBrewer.c).a(CreativeModeTab.k).f("ghast_tear")); - REGISTRY.a(371, "gold_nugget", (new Item()).c("goldNugget").a(CreativeModeTab.l).f("gold_nugget")); - REGISTRY.a(372, "nether_wart", (new ItemSeeds(Blocks.NETHER_WART, Blocks.SOUL_SAND)).c("netherStalkSeeds").e("+4").f("nether_wart")); - REGISTRY.a(373, "potion", (new ItemPotion()).c("potion").f("potion")); - REGISTRY.a(374, "glass_bottle", (new ItemGlassBottle()).c("glassBottle").f("potion_bottle_empty")); - REGISTRY.a(375, "spider_eye", (new ItemFood(2, 0.8F, false)).a(MobEffectList.POISON.id, 5, 0, 1.0F).c("spiderEye").e(PotionBrewer.d).f("spider_eye")); - REGISTRY.a(376, "fermented_spider_eye", (new Item()).c("fermentedSpiderEye").e(PotionBrewer.e).a(CreativeModeTab.k).f("spider_eye_fermented")); - REGISTRY.a(377, "blaze_powder", (new Item()).c("blazePowder").e(PotionBrewer.g).a(CreativeModeTab.k).f("blaze_powder")); - REGISTRY.a(378, "magma_cream", (new Item()).c("magmaCream").e(PotionBrewer.h).a(CreativeModeTab.k).f("magma_cream")); - REGISTRY.a(379, "brewing_stand", (new ItemReed(Blocks.BREWING_STAND)).c("brewingStand").a(CreativeModeTab.k).f("brewing_stand")); - REGISTRY.a(380, "cauldron", (new ItemReed(Blocks.CAULDRON)).c("cauldron").a(CreativeModeTab.k).f("cauldron")); - REGISTRY.a(381, "ender_eye", (new ItemEnderEye()).c("eyeOfEnder").f("ender_eye")); - REGISTRY.a(382, "speckled_melon", (new Item()).c("speckledMelon").e(PotionBrewer.f).a(CreativeModeTab.k).f("melon_speckled")); - REGISTRY.a(383, "spawn_egg", (new ItemMonsterEgg()).c("monsterPlacer").f("spawn_egg")); - REGISTRY.a(384, "experience_bottle", (new ItemExpBottle()).c("expBottle").f("experience_bottle")); - REGISTRY.a(385, "fire_charge", (new ItemFireball()).c("fireball").f("fireball")); - REGISTRY.a(386, "writable_book", (new ItemBookAndQuill()).c("writingBook").a(CreativeModeTab.f).f("book_writable")); - REGISTRY.a(387, "written_book", (new ItemWrittenBook()).c("writtenBook").f("book_written").e(16)); - REGISTRY.a(388, "emerald", (new Item()).c("emerald").a(CreativeModeTab.l).f("emerald")); - REGISTRY.a(389, "item_frame", (new ItemHanging(EntityItemFrame.class)).c("frame").f("item_frame")); - REGISTRY.a(390, "flower_pot", (new ItemReed(Blocks.FLOWER_POT)).c("flowerPot").a(CreativeModeTab.c).f("flower_pot")); - REGISTRY.a(391, "carrot", (new ItemSeedFood(4, 0.6F, Blocks.CARROTS, Blocks.SOIL)).c("carrots").f("carrot")); - REGISTRY.a(392, "potato", (new ItemSeedFood(1, 0.3F, Blocks.POTATOES, Blocks.SOIL)).c("potato").f("potato")); - REGISTRY.a(393, "baked_potato", (new ItemFood(6, 0.6F, false)).c("potatoBaked").f("potato_baked")); - REGISTRY.a(394, "poisonous_potato", (new ItemFood(2, 0.3F, false)).a(MobEffectList.POISON.id, 5, 0, 0.6F).c("potatoPoisonous").f("potato_poisonous")); - REGISTRY.a(395, "map", (new ItemMapEmpty()).c("emptyMap").f("map_empty")); - REGISTRY.a(396, "golden_carrot", (new ItemFood(6, 1.2F, false)).c("carrotGolden").e(PotionBrewer.l).f("carrot_golden")); - REGISTRY.a(397, "skull", (new ItemSkull()).c("skull").f("skull")); - REGISTRY.a(398, "carrot_on_a_stick", (new ItemCarrotStick()).c("carrotOnAStick").f("carrot_on_a_stick")); - REGISTRY.a(399, "nether_star", (new ItemNetherStar()).c("netherStar").a(CreativeModeTab.l).f("nether_star")); - REGISTRY.a(400, "pumpkin_pie", (new ItemFood(8, 0.3F, false)).c("pumpkinPie").a(CreativeModeTab.h).f("pumpkin_pie")); - REGISTRY.a(401, "fireworks", (new ItemFireworks()).c("fireworks").f("fireworks")); - REGISTRY.a(402, "firework_charge", (new ItemFireworksCharge()).c("fireworksCharge").a(CreativeModeTab.f).f("fireworks_charge")); - REGISTRY.a(403, "enchanted_book", (new ItemEnchantedBook()).e(1).c("enchantedBook").f("book_enchanted")); - REGISTRY.a(404, "comparator", (new ItemReed(Blocks.REDSTONE_COMPARATOR_OFF)).c("comparator").a(CreativeModeTab.d).f("comparator")); - REGISTRY.a(405, "netherbrick", (new Item()).c("netherbrick").a(CreativeModeTab.l).f("netherbrick")); - REGISTRY.a(406, "quartz", (new Item()).c("netherquartz").a(CreativeModeTab.l).f("quartz")); - REGISTRY.a(407, "tnt_minecart", (new ItemMinecart(3)).c("minecartTnt").f("minecart_tnt")); - REGISTRY.a(408, "hopper_minecart", (new ItemMinecart(5)).c("minecartHopper").f("minecart_hopper")); - REGISTRY.a(417, "iron_horse_armor", (new Item()).c("horsearmormetal").e(1).a(CreativeModeTab.f).f("iron_horse_armor")); - REGISTRY.a(418, "golden_horse_armor", (new Item()).c("horsearmorgold").e(1).a(CreativeModeTab.f).f("gold_horse_armor")); - REGISTRY.a(419, "diamond_horse_armor", (new Item()).c("horsearmordiamond").e(1).a(CreativeModeTab.f).f("diamond_horse_armor")); - REGISTRY.a(420, "lead", (new ItemLeash()).c("leash").f("lead")); - REGISTRY.a(421, "name_tag", (new ItemNameTag()).c("nameTag").f("name_tag")); - REGISTRY.a(422, "command_block_minecart", (new ItemMinecart(6)).c("minecartCommandBlock").f("minecart_command_block").a((CreativeModeTab) null)); - REGISTRY.a(2256, "record_13", (new ItemRecord("13")).c("record").f("record_13")); - REGISTRY.a(2257, "record_cat", (new ItemRecord("cat")).c("record").f("record_cat")); - REGISTRY.a(2258, "record_blocks", (new ItemRecord("blocks")).c("record").f("record_blocks")); - REGISTRY.a(2259, "record_chirp", (new ItemRecord("chirp")).c("record").f("record_chirp")); - REGISTRY.a(2260, "record_far", (new ItemRecord("far")).c("record").f("record_far")); - REGISTRY.a(2261, "record_mall", (new ItemRecord("mall")).c("record").f("record_mall")); - REGISTRY.a(2262, "record_mellohi", (new ItemRecord("mellohi")).c("record").f("record_mellohi")); - REGISTRY.a(2263, "record_stal", (new ItemRecord("stal")).c("record").f("record_stal")); - REGISTRY.a(2264, "record_strad", (new ItemRecord("strad")).c("record").f("record_strad")); - REGISTRY.a(2265, "record_ward", (new ItemRecord("ward")).c("record").f("record_ward")); - REGISTRY.a(2266, "record_11", (new ItemRecord("11")).c("record").f("record_11")); - REGISTRY.a(2267, "record_wait", (new ItemRecord("wait")).c("record").f("record_wait")); - HashSet hashset = Sets.newHashSet(new Block[] { Blocks.AIR, Blocks.BREWING_STAND, Blocks.BED, Blocks.NETHER_WART, Blocks.CAULDRON, Blocks.FLOWER_POT, Blocks.CROPS, Blocks.SUGAR_CANE_BLOCK, Blocks.CAKE_BLOCK, Blocks.SKULL, Blocks.PISTON_EXTENSION, Blocks.PISTON_MOVING, Blocks.GLOWING_REDSTONE_ORE, Blocks.DIODE_ON, Blocks.PUMPKIN_STEM, Blocks.SIGN_POST, Blocks.REDSTONE_COMPARATOR_ON, Blocks.TRIPWIRE, Blocks.REDSTONE_LAMP_ON, Blocks.MELON_STEM, Blocks.REDSTONE_TORCH_OFF, Blocks.REDSTONE_COMPARATOR_OFF, Blocks.REDSTONE_WIRE, Blocks.WALL_SIGN, Blocks.DIODE_OFF, Blocks.IRON_DOOR_BLOCK, Blocks.WOODEN_DOOR}); - Iterator iterator = Block.REGISTRY.keySet().iterator(); - - while (iterator.hasNext()) { - String s = (String) iterator.next(); - Block block = (Block) Block.REGISTRY.get(s); - Object object; - - if (block == Blocks.WOOL) { - object = (new ItemCloth(Blocks.WOOL)).b("cloth"); - } else if (block == Blocks.STAINED_HARDENED_CLAY) { - object = (new ItemCloth(Blocks.STAINED_HARDENED_CLAY)).b("clayHardenedStained"); - } else if (block == Blocks.STAINED_GLASS) { - object = (new ItemCloth(Blocks.STAINED_GLASS)).b("stainedGlass"); - } else if (block == Blocks.STAINED_GLASS_PANE) { - object = (new ItemCloth(Blocks.STAINED_GLASS_PANE)).b("stainedGlassPane"); - } else if (block == Blocks.WOOL_CARPET) { - object = (new ItemCloth(Blocks.WOOL_CARPET)).b("woolCarpet"); - } else if (block == Blocks.DIRT) { - object = (new ItemMultiTexture(Blocks.DIRT, Blocks.DIRT, BlockDirt.a)).b("dirt"); - } else if (block == Blocks.SAND) { - object = (new ItemMultiTexture(Blocks.SAND, Blocks.SAND, BlockSand.a)).b("sand"); - } else if (block == Blocks.LOG) { - object = (new ItemMultiTexture(Blocks.LOG, Blocks.LOG, BlockLog1.M)).b("log"); - } else if (block == Blocks.LOG2) { - object = (new ItemMultiTexture(Blocks.LOG2, Blocks.LOG2, BlockLog2.M)).b("log"); - } else if (block == Blocks.WOOD) { - object = (new ItemMultiTexture(Blocks.WOOD, Blocks.WOOD, BlockWood.a)).b("wood"); - } else if (block == Blocks.MONSTER_EGGS) { - object = (new ItemMultiTexture(Blocks.MONSTER_EGGS, Blocks.MONSTER_EGGS, BlockMonsterEggs.a)).b("monsterStoneEgg"); - } else if (block == Blocks.SMOOTH_BRICK) { - object = (new ItemMultiTexture(Blocks.SMOOTH_BRICK, Blocks.SMOOTH_BRICK, BlockSmoothBrick.a)).b("stonebricksmooth"); - } else if (block == Blocks.SANDSTONE) { - object = (new ItemMultiTexture(Blocks.SANDSTONE, Blocks.SANDSTONE, BlockSandStone.a)).b("sandStone"); - } else if (block == Blocks.QUARTZ_BLOCK) { - object = (new ItemMultiTexture(Blocks.QUARTZ_BLOCK, Blocks.QUARTZ_BLOCK, BlockQuartz.a)).b("quartzBlock"); - } else if (block == Blocks.STEP) { - object = (new ItemStep(Blocks.STEP, Blocks.STEP, Blocks.DOUBLE_STEP, false)).b("stoneSlab"); - } else if (block == Blocks.DOUBLE_STEP) { - object = (new ItemStep(Blocks.DOUBLE_STEP, Blocks.STEP, Blocks.DOUBLE_STEP, true)).b("stoneSlab"); - } else if (block == Blocks.WOOD_STEP) { - object = (new ItemStep(Blocks.WOOD_STEP, Blocks.WOOD_STEP, Blocks.WOOD_DOUBLE_STEP, false)).b("woodSlab"); - } else if (block == Blocks.WOOD_DOUBLE_STEP) { - object = (new ItemStep(Blocks.WOOD_DOUBLE_STEP, Blocks.WOOD_STEP, Blocks.WOOD_DOUBLE_STEP, true)).b("woodSlab"); - } else if (block == Blocks.SAPLING) { - object = (new ItemMultiTexture(Blocks.SAPLING, Blocks.SAPLING, BlockSapling.a)).b("sapling"); - } else if (block == Blocks.LEAVES) { - object = (new ItemLeaves(Blocks.LEAVES)).b("leaves"); - } else if (block == Blocks.LEAVES2) { - object = (new ItemLeaves(Blocks.LEAVES2)).b("leaves"); - } else if (block == Blocks.VINE) { - object = new ItemWithAuxData(Blocks.VINE, false); - } else if (block == Blocks.LONG_GRASS) { - object = (new ItemWithAuxData(Blocks.LONG_GRASS, true)).a(new String[] { "shrub", "grass", "fern"}); - } else if (block == Blocks.YELLOW_FLOWER) { - object = (new ItemMultiTexture(Blocks.YELLOW_FLOWER, Blocks.YELLOW_FLOWER, BlockFlowers.b)).b("flower"); - } else if (block == Blocks.RED_ROSE) { - object = (new ItemMultiTexture(Blocks.RED_ROSE, Blocks.RED_ROSE, BlockFlowers.a)).b("rose"); - } else if (block == Blocks.SNOW) { - object = new ItemSnow(Blocks.SNOW, Blocks.SNOW); - } else if (block == Blocks.WATER_LILY) { - object = new ItemWaterLily(Blocks.WATER_LILY); - } else if (block == Blocks.PISTON) { - object = new ItemPiston(Blocks.PISTON); - } else if (block == Blocks.PISTON_STICKY) { - object = new ItemPiston(Blocks.PISTON_STICKY); - } else if (block == Blocks.COBBLE_WALL) { - object = (new ItemMultiTexture(Blocks.COBBLE_WALL, Blocks.COBBLE_WALL, BlockCobbleWall.a)).b("cobbleWall"); - } else if (block == Blocks.ANVIL) { - object = (new ItemAnvil(Blocks.ANVIL)).b("anvil"); - } else if (block == Blocks.DOUBLE_PLANT) { - object = (new ItemTallPlant(Blocks.DOUBLE_PLANT, Blocks.DOUBLE_PLANT, BlockTallPlant.a)).b("doublePlant"); - // CraftBukkit start - allow certain blocks to retain data - } else if (block == Blocks.MOB_SPAWNER || block == Blocks.BIG_MUSHROOM_1 || block == Blocks.BIG_MUSHROOM_2) { - object = new ItemWithAuxData(block, true); - // CraftBukkit end - } else { - if (hashset.contains(block)) { - continue; - } - - object = new ItemBlock(block); - } - - REGISTRY.a(Block.getId(block), s, object); - } - } - - public Item e(int i) { - this.maxStackSize = i; - return this; - } - - public boolean interactWith(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l, float f, float f1, float f2) { - return false; - } - - public float getDestroySpeed(ItemStack itemstack, Block block) { - return 1.0F; - } - - public ItemStack a(ItemStack itemstack, World world, EntityHuman entityhuman) { - return itemstack; - } - - public ItemStack b(ItemStack itemstack, World world, EntityHuman entityhuman) { - return itemstack; - } - - public int getMaxStackSize() { - return this.maxStackSize; - } - - public int filterData(int i) { - return 0; - } - - public boolean n() { - return this.j; - } - - protected Item a(boolean flag) { - this.j = flag; - return this; - } - - public int getMaxDurability() { - return this.durability; - } - - protected Item setMaxDurability(int i) { - this.durability = i; - return this; - } - - public boolean usesDurability() { - return this.durability > 0 && !this.j; - } - - public boolean a(ItemStack itemstack, EntityLiving entityliving, EntityLiving entityliving1) { - return false; - } - - public boolean a(ItemStack itemstack, World world, Block block, int i, int j, int k, EntityLiving entityliving) { - return false; - } - - public boolean canDestroySpecialBlock(Block block) { - return false; - } - - public boolean a(ItemStack itemstack, EntityHuman entityhuman, EntityLiving entityliving) { - return false; - } - - public Item q() { - this.i = true; - return this; - } - - public Item c(String s) { - this.name = s; - return this; - } - - public String k(ItemStack itemstack) { - String s = this.a(itemstack); - - return s == null ? "" : LocaleI18n.get(s); - } - - public String getName() { - return "item." + this.name; - } - - public String a(ItemStack itemstack) { - return "item." + this.name; - } - - public Item c(Item item) { - this.craftingResult = item; - return this; - } - - public boolean l(ItemStack itemstack) { - return true; - } - - public boolean s() { - return true; - } - - public Item t() { - return this.craftingResult; - } - - public boolean u() { - return this.craftingResult != null; - } - - public void a(ItemStack itemstack, World world, Entity entity, int i, boolean flag) {} - - public void d(ItemStack itemstack, World world, EntityHuman entityhuman) {} - - public boolean h() { - return false; - } - - public EnumAnimation d(ItemStack itemstack) { - return EnumAnimation.NONE; - } - - public int d_(ItemStack itemstack) { - return 0; - } - - public void a(ItemStack itemstack, World world, EntityHuman entityhuman, int i) {} - - protected Item e(String s) { - this.d = s; - return this; - } - - public String i(ItemStack itemstack) { - return this.d; - } - - public boolean m(ItemStack itemstack) { - return this.i(itemstack) != null; - } - - public String n(ItemStack itemstack) { - return ("" + LocaleI18n.get(this.k(itemstack) + ".name")).trim(); - } - - public EnumItemRarity f(ItemStack itemstack) { - return itemstack.hasEnchantments() ? EnumItemRarity.RARE : EnumItemRarity.COMMON; - } - - public boolean e_(ItemStack itemstack) { - return this.getMaxStackSize() == 1 && this.usesDurability(); - } - - protected MovingObjectPosition a(World world, EntityHuman entityhuman, boolean flag) { - float f = 1.0F; - float f1 = entityhuman.lastPitch + (entityhuman.pitch - entityhuman.lastPitch) * f; - float f2 = entityhuman.lastYaw + (entityhuman.yaw - entityhuman.lastYaw) * f; - double d0 = entityhuman.lastX + (entityhuman.locX - entityhuman.lastX) * (double) f; - double d1 = entityhuman.lastY + (entityhuman.locY - entityhuman.lastY) * (double) f + 1.62D - (double) entityhuman.height; - double d2 = entityhuman.lastZ + (entityhuman.locZ - entityhuman.lastZ) * (double) f; - Vec3D vec3d = Vec3D.a(d0, d1, d2); - float f3 = MathHelper.cos(-f2 * 0.017453292F - 3.1415927F); - float f4 = MathHelper.sin(-f2 * 0.017453292F - 3.1415927F); - float f5 = -MathHelper.cos(-f1 * 0.017453292F); - float f6 = MathHelper.sin(-f1 * 0.017453292F); - float f7 = f4 * f5; - float f8 = f3 * f5; - double d3 = 5.0D; - Vec3D vec3d1 = vec3d.add((double) f7 * d3, (double) f6 * d3, (double) f8 * d3); - - return world.rayTrace(vec3d, vec3d1, flag, !flag, false); - } - - public int c() { - return 0; - } - - public Item a(CreativeModeTab creativemodetab) { - this.a = creativemodetab; - return this; - } - - public boolean v() { - return true; - } - - public boolean a(ItemStack itemstack, ItemStack itemstack1) { - return false; - } - - public Multimap k() { - return HashMultimap.create(); - } - - protected Item f(String s) { - this.l = s; - return this; - } -} diff --git a/src/main/java/net/minecraft/server/ItemBoat.java b/src/main/java/net/minecraft/server/ItemBoat.java deleted file mode 100644 index e044b03d..00000000 --- a/src/main/java/net/minecraft/server/ItemBoat.java +++ /dev/null @@ -1,93 +0,0 @@ -package net.minecraft.server; - -import java.util.List; - -public class ItemBoat extends Item { - - public ItemBoat() { - this.maxStackSize = 1; - this.a(CreativeModeTab.e); - } - - public ItemStack a(ItemStack itemstack, World world, EntityHuman entityhuman) { - float f = 1.0F; - float f1 = entityhuman.lastPitch + (entityhuman.pitch - entityhuman.lastPitch) * f; - float f2 = entityhuman.lastYaw + (entityhuman.yaw - entityhuman.lastYaw) * f; - double d0 = entityhuman.lastX + (entityhuman.locX - entityhuman.lastX) * (double) f; - double d1 = entityhuman.lastY + (entityhuman.locY - entityhuman.lastY) * (double) f + 1.62D - (double) entityhuman.height; - double d2 = entityhuman.lastZ + (entityhuman.locZ - entityhuman.lastZ) * (double) f; - Vec3D vec3d = Vec3D.a(d0, d1, d2); - float f3 = MathHelper.cos(-f2 * 0.017453292F - 3.1415927F); - float f4 = MathHelper.sin(-f2 * 0.017453292F - 3.1415927F); - float f5 = -MathHelper.cos(-f1 * 0.017453292F); - float f6 = MathHelper.sin(-f1 * 0.017453292F); - float f7 = f4 * f5; - float f8 = f3 * f5; - double d3 = 5.0D; - Vec3D vec3d1 = vec3d.add((double) f7 * d3, (double) f6 * d3, (double) f8 * d3); - MovingObjectPosition movingobjectposition = world.rayTrace(vec3d, vec3d1, true); - - if (movingobjectposition == null) { - return itemstack; - } else { - Vec3D vec3d2 = entityhuman.j(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)); - - int i; - - for (i = 0; i < list.size(); ++i) { - Entity entity = (Entity) list.get(i); - - if (entity.R()) { - float f10 = entity.af(); - AxisAlignedBB axisalignedbb = entity.boundingBox.grow((double) f10, (double) f10, (double) f10); - - if (axisalignedbb.a(vec3d)) { - flag = true; - } - } - } - - if (flag) { - return itemstack; - } else { - if (movingobjectposition.type == EnumMovingObjectType.BLOCK) { - i = movingobjectposition.b; - int j = movingobjectposition.c; - int k = movingobjectposition.d; - - // CraftBukkit start - Boat placement - org.bukkit.event.player.PlayerInteractEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent(entityhuman, org.bukkit.event.block.Action.RIGHT_CLICK_BLOCK, i, j, k, movingobjectposition.face, itemstack); - - if (event.isCancelled()) { - return itemstack; - } - // CraftBukkit end - - if (world.getType(i, j, k) == Blocks.SNOW) { - --j; - } - - EntityBoat entityboat = new EntityBoat(world, (double) ((float) i + 0.5F), (double) ((float) j + 1.0F), (double) ((float) k + 0.5F)); - - entityboat.yaw = (float) (((MathHelper.floor((double) (entityhuman.yaw * 4.0F / 360.0F) + 0.5D) & 3) - 1) * 90); - if (!world.getCubes(entityboat, entityboat.boundingBox.grow(-0.1D, -0.1D, -0.1D)).isEmpty()) { - return itemstack; - } - - if (!world.isStatic) { - world.addEntity(entityboat); - } - - if (!entityhuman.abilities.canInstantlyBuild) { - --itemstack.count; - } - } - - return itemstack; - } - } - } -} diff --git a/src/main/java/net/minecraft/server/ItemBow.java b/src/main/java/net/minecraft/server/ItemBow.java deleted file mode 100644 index a1bf31af..00000000 --- a/src/main/java/net/minecraft/server/ItemBow.java +++ /dev/null @@ -1,109 +0,0 @@ -package net.minecraft.server; - -import org.bukkit.event.entity.EntityCombustEvent; // CraftBukkit - -public class ItemBow extends Item { - - public static final String[] a = new String[] { "pulling_0", "pulling_1", "pulling_2"}; - - public ItemBow() { - this.maxStackSize = 1; - this.setMaxDurability(384); - this.a(CreativeModeTab.j); - } - - public void a(ItemStack itemstack, World world, EntityHuman entityhuman, int i) { - boolean flag = entityhuman.abilities.canInstantlyBuild || EnchantmentManager.getEnchantmentLevel(Enchantment.ARROW_INFINITE.id, itemstack) > 0; - - if (flag || entityhuman.inventory.b(Items.ARROW)) { - int j = this.d_(itemstack) - i; - float f = (float) j / 20.0F; - - f = (f * f + f * 2.0F) / 3.0F; - if ((double) f < 0.1D) { - return; - } - - if (f > 1.0F) { - f = 1.0F; - } - - EntityArrow entityarrow = new EntityArrow(world, entityhuman, f * 2.0F); - - if (f == 1.0F) { - entityarrow.setCritical(true); - } - - int k = EnchantmentManager.getEnchantmentLevel(Enchantment.ARROW_DAMAGE.id, itemstack); - - if (k > 0) { - entityarrow.b(entityarrow.e() + (double) k * 0.5D + 0.5D); - } - - int l = EnchantmentManager.getEnchantmentLevel(Enchantment.ARROW_KNOCKBACK.id, itemstack); - - if (l > 0) { - entityarrow.setKnockbackStrength(l); - } - - if (EnchantmentManager.getEnchantmentLevel(Enchantment.ARROW_FIRE.id, itemstack) > 0) { - // CraftBukkit start - call EntityCombustEvent - EntityCombustEvent event = new EntityCombustEvent(entityarrow.getBukkitEntity(), 100); - entityarrow.world.getServer().getPluginManager().callEvent(event); - - if (!event.isCancelled()) { - entityarrow.setOnFire(event.getDuration()); - } - // CraftBukkit end - } - - // CraftBukkit start - org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(entityhuman, itemstack, entityarrow, f); - if (event.isCancelled()) { - event.getProjectile().remove(); - return; - } - - if (event.getProjectile() == entityarrow.getBukkitEntity()) { - world.addEntity(entityarrow); - } - // CraftBukkit end - - itemstack.damage(1, entityhuman); - world.makeSound(entityhuman, "random.bow", 1.0F, 1.0F / (g.nextFloat() * 0.4F + 1.2F) + f * 0.5F); - if (flag) { - entityarrow.fromPlayer = 2; - } else { - entityhuman.inventory.a(Items.ARROW); - } - - if (!world.isStatic) { - // world.addEntity(entityarrow); // CraftBukkit - moved up - } - } - } - - public ItemStack b(ItemStack itemstack, World world, EntityHuman entityhuman) { - return itemstack; - } - - public int d_(ItemStack itemstack) { - return 72000; - } - - public EnumAnimation d(ItemStack itemstack) { - return EnumAnimation.BOW; - } - - public ItemStack a(ItemStack itemstack, World world, EntityHuman entityhuman) { - if (entityhuman.abilities.canInstantlyBuild || entityhuman.inventory.b(Items.ARROW)) { - entityhuman.a(itemstack, this.d_(itemstack)); - } - - return itemstack; - } - - public int c() { - return 1; - } -} diff --git a/src/main/java/net/minecraft/server/ItemBucket.java b/src/main/java/net/minecraft/server/ItemBucket.java deleted file mode 100644 index a58d4e73..00000000 --- a/src/main/java/net/minecraft/server/ItemBucket.java +++ /dev/null @@ -1,171 +0,0 @@ -package net.minecraft.server; - -// CraftBukkit start -import org.bukkit.craftbukkit.event.CraftEventFactory; -import org.bukkit.craftbukkit.inventory.CraftItemStack; -import org.bukkit.event.player.PlayerBucketEmptyEvent; -import org.bukkit.event.player.PlayerBucketFillEvent; -// CraftBukkit end - -public class ItemBucket extends Item { - - private Block a; - - public ItemBucket(Block block) { - this.maxStackSize = 1; - this.a = block; - this.a(CreativeModeTab.f); - } - - public ItemStack a(ItemStack itemstack, World world, EntityHuman entityhuman) { - boolean flag = this.a == Blocks.AIR; - MovingObjectPosition movingobjectposition = this.a(world, entityhuman, flag); - - if (movingobjectposition == null) { - return itemstack; - } else { - if (movingobjectposition.type == EnumMovingObjectType.BLOCK) { - int i = movingobjectposition.b; - int j = movingobjectposition.c; - int k = movingobjectposition.d; - - if (!world.a(entityhuman, i, j, k)) { - return itemstack; - } - - if (flag) { - if (!entityhuman.a(i, j, k, movingobjectposition.face, itemstack)) { - return itemstack; - } - - Material material = world.getType(i, j, k).getMaterial(); - int l = world.getData(i, j, k); - - if (material == Material.WATER && l == 0) { - // CraftBukkit start - PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent(entityhuman, i, j, k, -1, itemstack, Items.WATER_BUCKET); - - if (event.isCancelled()) { - return itemstack; - } - // CraftBukkit end - world.setAir(i, j, k); - return this.a(itemstack, entityhuman, Items.WATER_BUCKET, event.getItemStack()); // CraftBukkit - added Event stack - } - - if (material == Material.LAVA && l == 0) { - // CraftBukkit start - PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent(entityhuman, i, j, k, -1, itemstack, Items.LAVA_BUCKET); - - if (event.isCancelled()) { - return itemstack; - } - // CraftBukkit end - world.setAir(i, j, k); - return this.a(itemstack, entityhuman, Items.LAVA_BUCKET, event.getItemStack()); // CraftBukkit - added Event stack - } - } else { - if (this.a == Blocks.AIR) { - // CraftBukkit start - PlayerBucketEmptyEvent event = CraftEventFactory.callPlayerBucketEmptyEvent(entityhuman, i, j, k, movingobjectposition.face, itemstack); - - if (event.isCancelled()) { - return itemstack; - } - - return CraftItemStack.asNMSCopy(event.getItemStack()); - } - - int clickedX = i, clickedY = j, clickedZ = k; - // CraftBukkit end - - if (movingobjectposition.face == 0) { - --j; - } - - if (movingobjectposition.face == 1) { - ++j; - } - - if (movingobjectposition.face == 2) { - --k; - } - - if (movingobjectposition.face == 3) { - ++k; - } - - if (movingobjectposition.face == 4) { - --i; - } - - if (movingobjectposition.face == 5) { - ++i; - } - - if (!entityhuman.a(i, j, k, movingobjectposition.face, itemstack)) { - return itemstack; - } - - // CraftBukkit start - PlayerBucketEmptyEvent event = CraftEventFactory.callPlayerBucketEmptyEvent(entityhuman, clickedX, clickedY, clickedZ, movingobjectposition.face, itemstack); - - if (event.isCancelled()) { - return itemstack; - } - // CraftBukkit end - - if (this.a(world, i, j, k) && !entityhuman.abilities.canInstantlyBuild) { - return CraftItemStack.asNMSCopy(event.getItemStack()); // CraftBukkit - } - } - } - - return itemstack; - } - } - - // CraftBukkit - added ob.ItemStack result - TODO: Is this... the right way to handle this? - private ItemStack a(ItemStack itemstack, EntityHuman entityhuman, Item item, org.bukkit.inventory.ItemStack result) { - if (entityhuman.abilities.canInstantlyBuild) { - return itemstack; - } else if (--itemstack.count <= 0) { - return CraftItemStack.asNMSCopy(result); // CraftBukkit - } else { - if (!entityhuman.inventory.pickup(CraftItemStack.asNMSCopy(result))) { // CraftBukkit - entityhuman.drop(CraftItemStack.asNMSCopy(result), false); // CraftBukkit - } - - return itemstack; - } - } - - public boolean a(World world, int i, int j, int k) { - if (this.a == Blocks.AIR) { - return false; - } else { - Material material = world.getType(i, j, k).getMaterial(); - boolean flag = !material.isBuildable(); - - if (!world.isEmpty(i, j, k) && !flag) { - return false; - } else { - if (world.worldProvider.f && this.a == Blocks.WATER) { - world.makeSound((double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), "random.fizz", 0.5F, 2.6F + (world.random.nextFloat() - world.random.nextFloat()) * 0.8F); - - for (int l = 0; l < 8; ++l) { - world.addParticle("largesmoke", (double) i + Math.random(), (double) j + Math.random(), (double) k + Math.random(), 0.0D, 0.0D, 0.0D); - } - } else { - if (!world.isStatic && flag && !material.isLiquid()) { - world.setAir(i, j, k, true); - } - - world.setTypeAndData(i, j, k, this.a, 0, 3); - } - - return true; - } - } - } -} diff --git a/src/main/java/net/minecraft/server/ItemDye.java b/src/main/java/net/minecraft/server/ItemDye.java deleted file mode 100644 index 156af8e3..00000000 --- a/src/main/java/net/minecraft/server/ItemDye.java +++ /dev/null @@ -1,129 +0,0 @@ -package net.minecraft.server; - -import org.bukkit.event.entity.SheepDyeWoolEvent; // CraftBukkit - -public class ItemDye extends Item { - - public static final String[] a = new String[] { "black", "red", "green", "brown", "blue", "purple", "cyan", "silver", "gray", "pink", "lime", "yellow", "lightBlue", "magenta", "orange", "white"}; - public static final String[] b = new String[] { "black", "red", "green", "brown", "blue", "purple", "cyan", "silver", "gray", "pink", "lime", "yellow", "light_blue", "magenta", "orange", "white"}; - public static final int[] c = new int[] { 1973019, 11743532, 3887386, 5320730, 2437522, 8073150, 2651799, 11250603, 4408131, 14188952, 4312372, 14602026, 6719955, 12801229, 15435844, 15790320}; - - public ItemDye() { - this.a(true); - this.setMaxDurability(0); - this.a(CreativeModeTab.l); - } - - public String a(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.a(i, j, k, l, itemstack)) { - return false; - } else { - if (itemstack.getData() == 15) { - if (a(itemstack, world, i, j, k)) { - if (!world.isStatic) { - world.triggerEffect(2005, i, j, k, 0); - } - - return true; - } - } else if (itemstack.getData() == 3) { - Block block = world.getType(i, j, k); - int i1 = world.getData(i, j, k); - - if (block == Blocks.LOG && BlockLogAbstract.c(i1) == 3) { - if (l == 0) { - return false; - } - - if (l == 1) { - return false; - } - - if (l == 2) { - --k; - } - - if (l == 3) { - ++k; - } - - if (l == 4) { - --i; - } - - if (l == 5) { - ++i; - } - - if (world.isEmpty(i, j, k)) { - int j1 = Blocks.COCOA.getPlacedData(world, i, j, k, l, f, f1, f2, 0); - - world.setTypeAndData(i, j, k, Blocks.COCOA, j1, 2); - if (!entityhuman.abilities.canInstantlyBuild) { - --itemstack.count; - } - } - - return true; - } - } - - return false; - } - } - - public static boolean a(ItemStack itemstack, World world, int i, int j, int k) { - Block block = world.getType(i, j, k); - - if (block instanceof IBlockFragilePlantElement) { - IBlockFragilePlantElement iblockfragileplantelement = (IBlockFragilePlantElement) block; - - if (iblockfragileplantelement.a(world, i, j, k, world.isStatic)) { - if (!world.isStatic) { - if (iblockfragileplantelement.a(world, world.random, i, j, k)) { - iblockfragileplantelement.b(world, world.random, i, j, k); - } - - --itemstack.count; - } - - return true; - } - } - - return false; - } - - public boolean a(ItemStack itemstack, EntityHuman entityhuman, EntityLiving entityliving) { - if (entityliving instanceof EntitySheep) { - EntitySheep entitysheep = (EntitySheep) entityliving; - int i = BlockCloth.b(itemstack.getData()); - - if (!entitysheep.isSheared() && entitysheep.getColor() != i) { - // CraftBukkit start - byte bColor = (byte) i; - SheepDyeWoolEvent event = new SheepDyeWoolEvent((org.bukkit.entity.Sheep) entitysheep.getBukkitEntity(), org.bukkit.DyeColor.getByData(bColor)); - entitysheep.world.getServer().getPluginManager().callEvent(event); - - if (event.isCancelled()) { - return false; - } - - i = (byte) event.getColor().getWoolData(); - // CraftBukkit end - entitysheep.setColor(i); - --itemstack.count; - } - - return true; - } else { - return false; - } - } -} diff --git a/src/main/java/net/minecraft/server/ItemFireball.java b/src/main/java/net/minecraft/server/ItemFireball.java deleted file mode 100644 index 0a3bf131..00000000 --- a/src/main/java/net/minecraft/server/ItemFireball.java +++ /dev/null @@ -1,67 +0,0 @@ -package net.minecraft.server; - -// CraftBukkit start -import org.bukkit.craftbukkit.block.CraftBlockState; -import org.bukkit.craftbukkit.event.CraftEventFactory; -// CraftBukkit end - -public class ItemFireball extends Item { - - public ItemFireball() { - this.a(CreativeModeTab.f); - } - - 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) { - return true; - } else { - if (l == 0) { - --j; - } - - 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 (world.getType(i, j, k).getMaterial() == Material.AIR) { - // CraftBukkit start - fire BlockIgniteEvent - if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, i, j, k, org.bukkit.event.block.BlockIgniteEvent.IgniteCause.FIREBALL, entityhuman).isCancelled()) { - if (!entityhuman.abilities.canInstantlyBuild) { - --itemstack.count; - } - return false; - } - // CraftBukkit end - - world.makeSound((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "fire.ignite", 1.0F, g.nextFloat() * 0.4F + 0.8F); - world.setTypeUpdate(i, j, k, Blocks.FIRE); - } - - if (!entityhuman.abilities.canInstantlyBuild) { - --itemstack.count; - } - - return true; - } - } - } -} diff --git a/src/main/java/net/minecraft/server/ItemFishingRod.java b/src/main/java/net/minecraft/server/ItemFishingRod.java deleted file mode 100644 index 2f34151b..00000000 --- a/src/main/java/net/minecraft/server/ItemFishingRod.java +++ /dev/null @@ -1,47 +0,0 @@ -package net.minecraft.server; - -import org.bukkit.event.player.PlayerFishEvent; // CraftBukkit - -public class ItemFishingRod extends Item { - - public ItemFishingRod() { - this.setMaxDurability(64); - this.e(1); - this.a(CreativeModeTab.i); - } - - public ItemStack a(ItemStack itemstack, World world, EntityHuman entityhuman) { - if (entityhuman.hookedFish != null) { - int i = entityhuman.hookedFish.e(); - - itemstack.damage(i, entityhuman); - entityhuman.ba(); - } else { - // CraftBukkit start - EntityFishingHook hook = new EntityFishingHook(world, entityhuman); - PlayerFishEvent playerFishEvent = new PlayerFishEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), null, (org.bukkit.entity.Fish) hook.getBukkitEntity(), PlayerFishEvent.State.FISHING); - world.getServer().getPluginManager().callEvent(playerFishEvent); - - if (playerFishEvent.isCancelled()) { - return itemstack; - } - // CraftBukkit end - world.makeSound(entityhuman, "random.bow", 0.5F, 0.4F / (g.nextFloat() * 0.4F + 0.8F)); - if (!world.isStatic) { - world.addEntity(hook); // CraftBukkit - moved creation up - } - - entityhuman.ba(); - } - - return itemstack; - } - - public boolean e_(ItemStack itemstack) { - return super.e_(itemstack); - } - - public int c() { - return 1; - } -} diff --git a/src/main/java/net/minecraft/server/ItemFlintAndSteel.java b/src/main/java/net/minecraft/server/ItemFlintAndSteel.java deleted file mode 100644 index ec2edea5..00000000 --- a/src/main/java/net/minecraft/server/ItemFlintAndSteel.java +++ /dev/null @@ -1,72 +0,0 @@ -package net.minecraft.server; - -// CraftBukkit start -import org.bukkit.craftbukkit.block.CraftBlockState; -import org.bukkit.craftbukkit.event.CraftEventFactory; -// CraftBukkit end - -public class ItemFlintAndSteel extends Item { - - public ItemFlintAndSteel() { - this.maxStackSize = 1; - this.setMaxDurability(64); - this.a(CreativeModeTab.i); - } - - public boolean interactWith(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l, float f, float f1, float f2) { - int clickedX = i, clickedY = j, clickedZ = k; // CraftBukkit - if (l == 0) { - --j; - } - - 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 (world.getType(i, j, k).getMaterial() == Material.AIR) { - // CraftBukkit start - Store the clicked block - if (CraftEventFactory.callBlockIgniteEvent(world, i, j, k, org.bukkit.event.block.BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL, entityhuman).isCancelled()) { - itemstack.damage(1, entityhuman); - return false; - } - - CraftBlockState blockState = CraftBlockState.getBlockState(world, i, j, k); - // CraftBukkit end - - world.makeSound((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "fire.ignite", 1.0F, g.nextFloat() * 0.4F + 0.8F); - world.setTypeUpdate(i, j, k, Blocks.FIRE); - - // CraftBukkit start - org.bukkit.event.block.BlockPlaceEvent placeEvent = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, clickedX, clickedY, clickedZ); - - if (placeEvent.isCancelled() || !placeEvent.canBuild()) { - placeEvent.getBlockPlaced().setTypeIdAndData(0, (byte) 0, false); - return false; - } - // CraftBukkit end - } - - itemstack.damage(1, entityhuman); - return true; - } - } -} diff --git a/src/main/java/net/minecraft/server/ItemHanging.java b/src/main/java/net/minecraft/server/ItemHanging.java deleted file mode 100644 index d88d36ac..00000000 --- a/src/main/java/net/minecraft/server/ItemHanging.java +++ /dev/null @@ -1,67 +0,0 @@ -package net.minecraft.server; - -// CraftBukkit start -import org.bukkit.entity.Player; -import org.bukkit.event.hanging.HangingPlaceEvent; -import org.bukkit.event.painting.PaintingPlaceEvent; -// CraftBukkit end - -public class ItemHanging extends Item { - - private final Class a; - - public ItemHanging(Class oclass) { - 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 - fire HangingPlaceEvent - 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); - - HangingPlaceEvent event = new HangingPlaceEvent((org.bukkit.entity.Hanging) entityhanging.getBukkitEntity(), who, blockClicked, blockFace); - world.getServer().getPluginManager().callEvent(event); - - PaintingPlaceEvent paintingEvent = null; - if (entityhanging instanceof EntityPainting) { - // Fire old painting event until it can be removed - paintingEvent = new PaintingPlaceEvent((org.bukkit.entity.Painting) entityhanging.getBukkitEntity(), who, blockClicked, blockFace); - paintingEvent.setCancelled(event.isCancelled()); - world.getServer().getPluginManager().callEvent(paintingEvent); - } - - if (event.isCancelled() || (paintingEvent != null && paintingEvent.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/ItemLeash.java b/src/main/java/net/minecraft/server/ItemLeash.java deleted file mode 100644 index 8655b9f1..00000000 --- a/src/main/java/net/minecraft/server/ItemLeash.java +++ /dev/null @@ -1,70 +0,0 @@ -package net.minecraft.server; - -import java.util.Iterator; -import java.util.List; - -import org.bukkit.event.hanging.HangingPlaceEvent; // CraftBukkit - -public class ItemLeash extends Item { - - public ItemLeash() { - this.a(CreativeModeTab.i); - } - - public boolean interactWith(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l, float f, float f1, float f2) { - Block block = world.getType(i, j, k); - - if (block.b() == 11) { - if (world.isStatic) { - return true; - } else { - a(entityhuman, world, i, j, k); - return true; - } - } else { - return false; - } - } - - public static boolean a(EntityHuman entityhuman, World world, int i, int j, int k) { - EntityLeash entityleash = EntityLeash.b(world, i, j, k); - boolean flag = false; - double d0 = 7.0D; - List list = world.a(EntityInsentient.class, AxisAlignedBB.a((double) i - d0, (double) j - d0, (double) k - d0, (double) i + d0, (double) j + d0, (double) k + d0)); - - if (list != null) { - Iterator iterator = list.iterator(); - - while (iterator.hasNext()) { - EntityInsentient entityinsentient = (EntityInsentient) iterator.next(); - - if (entityinsentient.bN() && entityinsentient.getLeashHolder() == entityhuman) { - if (entityleash == null) { - entityleash = EntityLeash.a(world, i, j, k); - - // CraftBukkit start - fire HangingPlaceEvent - HangingPlaceEvent event = new HangingPlaceEvent((org.bukkit.entity.Hanging) entityleash.getBukkitEntity(), entityhuman != null ? (org.bukkit.entity.Player) entityhuman.getBukkitEntity() : null, world.getWorld().getBlockAt(i, j, k), org.bukkit.block.BlockFace.SELF); - world.getServer().getPluginManager().callEvent(event); - - if (event.isCancelled()) { - entityleash.die(); - return false; - } - // CraftBukkit end - } - - // CraftBukkit start - if (org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerLeashEntityEvent(entityinsentient, entityleash, entityhuman).isCancelled()) { - continue; - } - // CraftBukkit end - - entityinsentient.setLeashHolder(entityleash, true); - flag = true; - } - } - } - - return flag; - } -} diff --git a/src/main/java/net/minecraft/server/ItemMapEmpty.java b/src/main/java/net/minecraft/server/ItemMapEmpty.java deleted file mode 100644 index 8998a3fe..00000000 --- a/src/main/java/net/minecraft/server/ItemMapEmpty.java +++ /dev/null @@ -1,37 +0,0 @@ -package net.minecraft.server; - -public class ItemMapEmpty extends ItemWorldMapBase { - - protected ItemMapEmpty() { - this.a(CreativeModeTab.f); - } - - public ItemStack a(ItemStack itemstack, World world, EntityHuman entityhuman) { - World worldMain = world.getServer().getServer().worlds.get(0); // CraftBukkit - store reference to primary world - ItemStack itemstack1 = new ItemStack(Items.MAP, 1, worldMain.b("map")); // CraftBukkit - use primary world for maps - String s = "map_" + itemstack1.getData(); - WorldMap worldmap = new WorldMap(s); - - worldMain.a(s, (PersistentBase) worldmap); // CraftBukkit - use primary world for maps - worldmap.scale = 0; - int i = 128 * (1 << worldmap.scale); - - worldmap.centerX = (int) (Math.round(entityhuman.locX / (double) i) * (long) i); - worldmap.centerZ = (int) (Math.round(entityhuman.locZ / (double) i) * (long) i); - worldmap.map = (byte) ((WorldServer) world).dimension; // CraftBukkit - use bukkit dimension - worldmap.c(); - - org.bukkit.craftbukkit.event.CraftEventFactory.callEvent(new org.bukkit.event.server.MapInitializeEvent(worldmap.mapView)); // CraftBukkit - - --itemstack.count; - if (itemstack.count <= 0) { - return itemstack1; - } else { - if (!entityhuman.inventory.pickup(itemstack1.cloneItemStack())) { - entityhuman.drop(itemstack1, false); - } - - return itemstack; - } - } -} diff --git a/src/main/java/net/minecraft/server/ItemMinecart.java b/src/main/java/net/minecraft/server/ItemMinecart.java deleted file mode 100644 index 02a1fd8e..00000000 --- a/src/main/java/net/minecraft/server/ItemMinecart.java +++ /dev/null @@ -1,40 +0,0 @@ -package net.minecraft.server; - -public class ItemMinecart extends Item { - - private static final IDispenseBehavior b = new DispenseBehaviorMinecart(); - public int a; - - public ItemMinecart(int i) { - this.maxStackSize = 1; - this.a = i; - this.a(CreativeModeTab.e); - BlockDispenser.a.a(this, b); - } - - public boolean interactWith(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l, float f, float f1, float f2) { - if (BlockMinecartTrackAbstract.a(world.getType(i, j, k))) { - if (!world.isStatic) { - // CraftBukkit start - Minecarts - org.bukkit.event.player.PlayerInteractEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent(entityhuman, org.bukkit.event.block.Action.RIGHT_CLICK_BLOCK, i, j, k, l, itemstack); - - if (event.isCancelled()) { - return false; - } - // CraftBukkit end - EntityMinecartAbstract entityminecartabstract = EntityMinecartAbstract.a(world, (double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), this.a); - - if (itemstack.hasName()) { - entityminecartabstract.a(itemstack.getName()); - } - - world.addEntity(entityminecartabstract); - } - - --itemstack.count; - return true; - } else { - return false; - } - } -} diff --git a/src/main/java/net/minecraft/server/ItemMonsterEgg.java b/src/main/java/net/minecraft/server/ItemMonsterEgg.java deleted file mode 100644 index 639ddf56..00000000 --- a/src/main/java/net/minecraft/server/ItemMonsterEgg.java +++ /dev/null @@ -1,124 +0,0 @@ -package net.minecraft.server; - -public class ItemMonsterEgg extends Item { - - public ItemMonsterEgg() { - this.a(true); - this.a(CreativeModeTab.f); - } - - public String n(ItemStack itemstack) { - String s = ("" + LocaleI18n.get(this.getName() + ".name")).trim(); - String s1 = EntityTypes.b(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) { - // CraftBukkit - check ItemStack data - if (world.isStatic || itemstack.getData() == 48 || itemstack.getData() == 49 || itemstack.getData() == 63 || itemstack.getData() == 64) { - return true; - } else { - Block block = world.getType(i, j, k); - - i += Facing.b[l]; - j += Facing.c[l]; - k += Facing.d[l]; - double d0 = 0.0D; - - if (l == 1 && block.b() == 11) { - d0 = 0.5D; - } - - Entity entity = a(world, itemstack.getData(), (double) i + 0.5D, (double) j + d0, (double) k + 0.5D); - - if (entity != null) { - if (entity instanceof EntityLiving && itemstack.hasName()) { - ((EntityInsentient) entity).setCustomName(itemstack.getName()); - } - - if (!entityhuman.abilities.canInstantlyBuild) { - --itemstack.count; - } - } - - return true; - } - } - - public ItemStack a(ItemStack itemstack, World world, EntityHuman entityhuman) { - if (world.isStatic) { - return itemstack; - } else { - MovingObjectPosition movingobjectposition = this.a(world, entityhuman, true); - - if (movingobjectposition == null) { - return itemstack; - } else { - if (movingobjectposition.type == EnumMovingObjectType.BLOCK) { - int i = movingobjectposition.b; - int j = movingobjectposition.c; - int k = movingobjectposition.d; - - if (!world.a(entityhuman, i, j, k)) { - return itemstack; - } - - if (!entityhuman.a(i, j, k, movingobjectposition.face, itemstack)) { - return itemstack; - } - - if (world.getType(i, j, k) instanceof BlockFluids) { - Entity entity = a(world, itemstack.getData(), (double) i, (double) j, (double) k); - - if (entity != null) { - if (entity instanceof EntityLiving && itemstack.hasName()) { - ((EntityInsentient) entity).setCustomName(itemstack.getName()); - } - - if (!entityhuman.abilities.canInstantlyBuild) { - --itemstack.count; - } - } - } - } - - return itemstack; - } - } - } - - public static Entity a(World world, int i, double d0, double d1, double d2) { - // CraftBukkit start - delegate to spawnCreature - return spawnCreature(world, i, d0, d1, d2, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG); - } - - public static Entity spawnCreature(World world, int i, double d0, double d1, double d2, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) { - // CraftBukkit end - if (!EntityTypes.eggInfo.containsKey(Integer.valueOf(i))) { - return null; - } else { - Entity entity = null; - - for (int j = 0; j < 1; ++j) { - entity = EntityTypes.a(i, world); - if (entity != null && entity instanceof EntityLiving) { - EntityInsentient entityinsentient = (EntityInsentient) entity; - - entity.setPositionRotation(d0, d1, d2, MathHelper.g(world.random.nextFloat() * 360.0F), 0.0F); - entityinsentient.aO = entityinsentient.yaw; - entityinsentient.aM = entityinsentient.yaw; - entityinsentient.prepare((GroupDataEntity) null); - world.addEntity(entity, spawnReason); // CraftBukkit - entityinsentient.r(); - } - } - - return entity; - } - } -} diff --git a/src/main/java/net/minecraft/server/ItemStack.java b/src/main/java/net/minecraft/server/ItemStack.java deleted file mode 100644 index c9d74d37..00000000 --- a/src/main/java/net/minecraft/server/ItemStack.java +++ /dev/null @@ -1,593 +0,0 @@ -package net.minecraft.server; - -import java.text.DecimalFormat; -import java.util.Random; - -import net.minecraft.util.com.google.common.collect.HashMultimap; -import net.minecraft.util.com.google.common.collect.Multimap; - -// CraftBukkit start -import java.util.List; - -import org.bukkit.Location; -import org.bukkit.TreeType; -import org.bukkit.block.BlockState; -import org.bukkit.craftbukkit.block.CraftBlockState; -import org.bukkit.craftbukkit.util.CraftMagicNumbers; -import org.bukkit.entity.Player; -import org.bukkit.event.world.StructureGrowEvent; -// CraftBukkit end - -public final class ItemStack { - - public static final DecimalFormat a = new DecimalFormat("#.###"); - public int count; - public int c; - private Item item; - public NBTTagCompound tag; - private int damage; - private EntityItemFrame g; - - public ItemStack(Block block) { - this(block, 1); - } - - public ItemStack(Block block, int i) { - this(block, i, 0); - } - - public ItemStack(Block block, int i, int j) { - this(Item.getItemOf(block), i, j); - } - - public ItemStack(Item item) { - this(item, 1); - } - - public ItemStack(Item item, int i) { - this(item, i, 0); - } - - public ItemStack(Item item, int i, int j) { - this.item = item; - this.count = i; - // CraftBukkit start - Pass to setData to do filtering - this.setData(j); - //this.damage = j; - //if (this.damage < 0) { - // this.damage = 0; - //} - // CraftBukkit end - } - - public static ItemStack createStack(NBTTagCompound nbttagcompound) { - ItemStack itemstack = new ItemStack(); - - itemstack.c(nbttagcompound); - return itemstack.getItem() != null ? itemstack : null; - } - - private ItemStack() {} - - public ItemStack a(int i) { - ItemStack itemstack = new ItemStack(this.item, i, this.damage); - - if (this.tag != null) { - itemstack.tag = (NBTTagCompound) this.tag.clone(); - } - - this.count -= i; - return itemstack; - } - - public Item getItem() { - return this.item; - } - - public boolean placeItem(EntityHuman entityhuman, World world, int i, int j, int k, int l, float f, float f1, float f2) { - // CraftBukkit start - handle all block place event logic here - int data = this.getData(); - int count = this.count; - - if (!(this.getItem() instanceof ItemBucket)) { // if not bucket - world.captureBlockStates = true; - // special case bonemeal - if (this.getItem() instanceof ItemDye && this.getData() == 15) { - Block block = world.getType(i, j, k); - if (block == Blocks.SAPLING || block instanceof BlockMushroom) { - world.captureTreeGeneration = true; - } - } - } - boolean flag = this.getItem().interactWith(this, entityhuman, world, i, j, k, l, f, f1, f2); - int newData = this.getData(); - int newCount = this.count; - this.count = count; - this.setData(data); - world.captureBlockStates = false; - if (flag && world.captureTreeGeneration && world.capturedBlockStates.size() > 0) { - world.captureTreeGeneration = false; - Location location = new Location(world.getWorld(), i, j, k); - TreeType treeType = BlockSapling.treeType; - BlockSapling.treeType = null; - List<BlockState> blocks = (List<BlockState>) world.capturedBlockStates.clone(); - world.capturedBlockStates.clear(); - StructureGrowEvent event = null; - if (treeType != null) { - event = new StructureGrowEvent(location, treeType, false, (Player) entityhuman.getBukkitEntity(), blocks); - org.bukkit.Bukkit.getPluginManager().callEvent(event); - } - if (event == null || !event.isCancelled()) { - // Change the stack to its new contents if it hasn't been tampered with. - if (this.count == count && this.getData() == data) { - this.setData(newData); - this.count = newCount; - } - for (BlockState blockstate : blocks) { - blockstate.update(true); - } - } - - return flag; - } - world.captureTreeGeneration = false; - - if (flag) { - org.bukkit.event.block.BlockPlaceEvent placeEvent = null; - List<BlockState> blocks = (List<BlockState>) world.capturedBlockStates.clone(); - world.capturedBlockStates.clear(); - if (blocks.size() > 1) { - placeEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockMultiPlaceEvent(world, entityhuman, blocks, i, j, k); - } else if (blocks.size() == 1) { - placeEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blocks.get(0), i, j, k); - } - - if (placeEvent != null && (placeEvent.isCancelled() || !placeEvent.canBuild())) { - flag = false; // cancel placement - // revert back all captured blocks - for (BlockState blockstate : blocks) { - blockstate.update(true, false); - } - } else { - // Change the stack to its new contents if it hasn't been tampered with. - if (this.count == count && this.getData() == data) { - this.setData(newData); - this.count = newCount; - } - for (BlockState blockstate : blocks) { - int x = blockstate.getX(); - int y = blockstate.getY(); - int z = blockstate.getZ(); - int updateFlag = ((CraftBlockState) blockstate).getFlag(); - org.bukkit.Material mat = blockstate.getType(); - Block oldBlock = CraftMagicNumbers.getBlock(mat); - Block block = world.getType(x, y, z); - - if (block != null && !(block instanceof BlockContainer)) { // Containers get placed automatically - block.onPlace(world, x, y, z); - } - - world.notifyAndUpdatePhysics(x, y, z, null, oldBlock, block, updateFlag); // send null chunk as chunk.k() returns false by this point - } - entityhuman.a(StatisticList.USE_ITEM_COUNT[Item.getId(this.item)], 1); - } - } - world.capturedBlockStates.clear(); - // CraftBukkit end - - return flag; - } - - public float a(Block block) { - return this.getItem().getDestroySpeed(this, block); - } - - public ItemStack a(World world, EntityHuman entityhuman) { - return this.getItem().a(this, world, entityhuman); - } - - public ItemStack b(World world, EntityHuman entityhuman) { - return this.getItem().b(this, world, entityhuman); - } - - public NBTTagCompound save(NBTTagCompound nbttagcompound) { - nbttagcompound.setShort("id", (short) Item.getId(this.item)); - nbttagcompound.setByte("Count", (byte) this.count); - nbttagcompound.setShort("Damage", (short) this.damage); - if (this.tag != null) { - nbttagcompound.set("tag", this.tag.clone()); // CraftBukkit - make defensive copy, data is going to another thread - } - - return nbttagcompound; - } - - public void c(NBTTagCompound nbttagcompound) { - this.item = Item.getById(nbttagcompound.getShort("id")); - this.count = nbttagcompound.getByte("Count"); - /* CraftBukkit start - Route through setData for filtering - this.damage = nbttagcompound.getShort("Damage"); - if (this.damage < 0) { - this.damage = 0; - } - */ - this.setData(nbttagcompound.getShort("Damage")); - // CraftBukkit end - - if (nbttagcompound.hasKeyOfType("tag", 10)) { - // CraftBukkit - make defensive copy as this data may be coming from the save thread - this.tag = (NBTTagCompound) nbttagcompound.getCompound("tag").clone(); - } - } - - public int getMaxStackSize() { - return this.getItem().getMaxStackSize(); - } - - public boolean isStackable() { - return this.getMaxStackSize() > 1 && (!this.g() || !this.i()); - } - - public boolean g() { - return this.item.getMaxDurability() <= 0 ? false : !this.hasTag() || !this.getTag().getBoolean("Unbreakable"); - } - - public boolean usesData() { - return this.item.n(); - } - - public boolean i() { - return this.g() && this.damage > 0; - } - - public int j() { - return this.damage; - } - - public int getData() { - return this.damage; - } - - public void setData(int i) { - // CraftBukkit start - Filter out data for items that shouldn't have it - // The crafting system uses this value for a special purpose so we have to allow it - if (i == 32767) { - this.damage = i; - return; - } - - // Is this a block? - if (CraftMagicNumbers.getBlock(CraftMagicNumbers.getId(this.getItem())) != Blocks.AIR) { - // If vanilla doesn't use data on it don't allow any - if (!(this.usesData() || this.getItem().usesDurability())) { - i = 0; - } - } - - // Filter invalid plant data - if (CraftMagicNumbers.getBlock(CraftMagicNumbers.getId(this.getItem())) == Blocks.DOUBLE_PLANT && (i > 5 || i < 0)) { - i = 0; - } - // CraftBukkit end - - this.damage = i; - if (this.damage < -1) { // CraftBukkit - don't filter -1, we use it - this.damage = 0; - } - } - - public int l() { - return this.item.getMaxDurability(); - } - - public boolean isDamaged(int i, Random random) { - if (!this.g()) { - return false; - } else { - if (i > 0) { - int j = EnchantmentManager.getEnchantmentLevel(Enchantment.DURABILITY.id, this); - int k = 0; - - for (int l = 0; j > 0 && l < i; ++l) { - if (EnchantmentDurability.a(this, j, random)) { - ++k; - } - } - - i -= k; - if (i <= 0) { - return false; - } - } - - this.damage += i; - return this.damage > this.l(); - } - } - - public void damage(int i, EntityLiving entityliving) { - if (!(entityliving instanceof EntityHuman) || !((EntityHuman) entityliving).abilities.canInstantlyBuild) { - if (this.g()) { - if (this.isDamaged(i, entityliving.aI())) { - entityliving.a(this); - --this.count; - if (entityliving instanceof EntityHuman) { - EntityHuman entityhuman = (EntityHuman) entityliving; - - entityhuman.a(StatisticList.BREAK_ITEM_COUNT[Item.getId(this.item)], 1); - if (this.count == 0 && this.getItem() instanceof ItemBow) { - entityhuman.bG(); - } - } - - if (this.count < 0) { - this.count = 0; - } - - // CraftBukkit start - Check for item breaking - if (this.count == 0 && entityliving instanceof EntityHuman) { - org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerItemBreakEvent((EntityHuman) entityliving, this); - } - // CraftBukkit end - - this.damage = 0; - } - } - } - } - - public void a(EntityLiving entityliving, EntityHuman entityhuman) { - boolean flag = this.item.a(this, entityliving, (EntityLiving) entityhuman); - - if (flag) { - entityhuman.a(StatisticList.USE_ITEM_COUNT[Item.getId(this.item)], 1); - } - } - - public void a(World world, Block block, int i, int j, int k, EntityHuman entityhuman) { - boolean flag = this.item.a(this, world, block, i, j, k, entityhuman); - - if (flag) { - entityhuman.a(StatisticList.USE_ITEM_COUNT[Item.getId(this.item)], 1); - } - } - - public boolean b(Block block) { - return this.item.canDestroySpecialBlock(block); - } - - public boolean a(EntityHuman entityhuman, EntityLiving entityliving) { - return this.item.a(this, entityhuman, entityliving); - } - - public ItemStack cloneItemStack() { - ItemStack itemstack = new ItemStack(this.item, this.count, this.damage); - - if (this.tag != null) { - itemstack.tag = (NBTTagCompound) this.tag.clone(); - } - - return itemstack; - } - - public static boolean equals(ItemStack itemstack, ItemStack itemstack1) { - return itemstack == null && itemstack1 == null ? true : (itemstack != null && itemstack1 != null ? (itemstack.tag == null && itemstack1.tag != null ? false : itemstack.tag == null || itemstack.tag.equals(itemstack1.tag)) : false); - } - - public static boolean matches(ItemStack itemstack, ItemStack itemstack1) { - return itemstack == null && itemstack1 == null ? true : (itemstack != null && itemstack1 != null ? itemstack.d(itemstack1) : false); - } - - private boolean d(ItemStack itemstack) { - return this.count != itemstack.count ? false : (this.item != itemstack.item ? false : (this.damage != itemstack.damage ? false : (this.tag == null && itemstack.tag != null ? false : this.tag == null || this.tag.equals(itemstack.tag)))); - } - - public boolean doMaterialsMatch(ItemStack itemstack) { - return this.item == itemstack.item && this.damage == itemstack.damage; - } - - public String a() { - return this.item.a(this); - } - - public static ItemStack b(ItemStack itemstack) { - return itemstack == null ? null : itemstack.cloneItemStack(); - } - - public String toString() { - return this.count + "x" + this.item.getName() + "@" + this.damage; - } - - public void a(World world, Entity entity, int i, boolean flag) { - if (this.c > 0) { - --this.c; - } - - this.item.a(this, world, entity, i, flag); - } - - public void a(World world, EntityHuman entityhuman, int i) { - entityhuman.a(StatisticList.CRAFT_BLOCK_COUNT[Item.getId(this.item)], i); - this.item.d(this, world, entityhuman); - } - - public int n() { - return this.getItem().d_(this); - } - - public EnumAnimation o() { - return this.getItem().d(this); - } - - public void b(World world, EntityHuman entityhuman, int i) { - this.getItem().a(this, world, entityhuman, i); - } - - public boolean hasTag() { - return this.tag != null; - } - - public NBTTagCompound getTag() { - return this.tag; - } - - public NBTTagList getEnchantments() { - return this.tag == null ? null : this.tag.getList("ench", 10); - } - - public void setTag(NBTTagCompound nbttagcompound) { - this.tag = nbttagcompound; - } - - public String getName() { - String s = this.getItem().n(this); - - if (this.tag != null && this.tag.hasKeyOfType("display", 10)) { - NBTTagCompound nbttagcompound = this.tag.getCompound("display"); - - if (nbttagcompound.hasKeyOfType("Name", 8)) { - s = nbttagcompound.getString("Name"); - } - } - - return s; - } - - public ItemStack c(String s) { - if (this.tag == null) { - this.tag = new NBTTagCompound(); - } - - if (!this.tag.hasKeyOfType("display", 10)) { - this.tag.set("display", new NBTTagCompound()); - } - - this.tag.getCompound("display").setString("Name", s); - return this; - } - - public void t() { - if (this.tag != null) { - if (this.tag.hasKeyOfType("display", 10)) { - NBTTagCompound nbttagcompound = this.tag.getCompound("display"); - - nbttagcompound.remove("Name"); - if (nbttagcompound.isEmpty()) { - this.tag.remove("display"); - if (this.tag.isEmpty()) { - this.setTag((NBTTagCompound) null); - } - } - } - } - } - - public boolean hasName() { - return this.tag == null ? false : (!this.tag.hasKeyOfType("display", 10) ? false : this.tag.getCompound("display").hasKeyOfType("Name", 8)); - } - - public EnumItemRarity w() { - return this.getItem().f(this); - } - - public boolean x() { - return !this.getItem().e_(this) ? false : !this.hasEnchantments(); - } - - public void addEnchantment(Enchantment enchantment, int i) { - if (this.tag == null) { - this.setTag(new NBTTagCompound()); - } - - if (!this.tag.hasKeyOfType("ench", 9)) { - this.tag.set("ench", new NBTTagList()); - } - - NBTTagList nbttaglist = this.tag.getList("ench", 10); - NBTTagCompound nbttagcompound = new NBTTagCompound(); - - nbttagcompound.setShort("id", (short) enchantment.id); - nbttagcompound.setShort("lvl", (short) ((byte) i)); - nbttaglist.add(nbttagcompound); - } - - public boolean hasEnchantments() { - return this.tag != null && this.tag.hasKeyOfType("ench", 9); - } - - public void a(String s, NBTBase nbtbase) { - if (this.tag == null) { - this.setTag(new NBTTagCompound()); - } - - this.tag.set(s, nbtbase); - } - - public boolean z() { - return this.getItem().v(); - } - - public boolean A() { - return this.g != null; - } - - public void a(EntityItemFrame entityitemframe) { - this.g = entityitemframe; - } - - public EntityItemFrame B() { - return this.g; - } - - public int getRepairCost() { - return this.hasTag() && this.tag.hasKeyOfType("RepairCost", 3) ? this.tag.getInt("RepairCost") : 0; - } - - public void setRepairCost(int i) { - if (!this.hasTag()) { - this.tag = new NBTTagCompound(); - } - - this.tag.setInt("RepairCost", i); - } - - public Multimap D() { - Object object; - - if (this.hasTag() && this.tag.hasKeyOfType("AttributeModifiers", 9)) { - object = HashMultimap.create(); - NBTTagList nbttaglist = this.tag.getList("AttributeModifiers", 10); - - for (int i = 0; i < nbttaglist.size(); ++i) { - NBTTagCompound nbttagcompound = nbttaglist.get(i); - AttributeModifier attributemodifier = GenericAttributes.a(nbttagcompound); - - if (attributemodifier.a().getLeastSignificantBits() != 0L && attributemodifier.a().getMostSignificantBits() != 0L) { - ((Multimap) object).put(nbttagcompound.getString("AttributeName"), attributemodifier); - } - } - } else { - object = this.getItem().k(); - } - - return (Multimap) object; - } - - public void setItem(Item item) { - this.item = item; - this.setData(this.getData()); // CraftBukkit - Set data again to ensure it is filtered properly - } - - public IChatBaseComponent E() { - IChatBaseComponent ichatbasecomponent = (new ChatComponentText("[")).a(this.getName()).a("]"); - - if (this.item != null) { - NBTTagCompound nbttagcompound = new NBTTagCompound(); - - this.save(nbttagcompound); - ichatbasecomponent.getChatModifier().a(new ChatHoverable(EnumHoverAction.SHOW_ITEM, new ChatComponentText(nbttagcompound.toString()))); - ichatbasecomponent.getChatModifier().setColor(this.w().e); - } - - return ichatbasecomponent; - } -} diff --git a/src/main/java/net/minecraft/server/ItemWaterLily.java b/src/main/java/net/minecraft/server/ItemWaterLily.java deleted file mode 100644 index 246090d6..00000000 --- a/src/main/java/net/minecraft/server/ItemWaterLily.java +++ /dev/null @@ -1,48 +0,0 @@ -package net.minecraft.server; - -public class ItemWaterLily extends ItemWithAuxData { - - public ItemWaterLily(Block block) { - super(block, false); - } - - public ItemStack a(ItemStack itemstack, World world, EntityHuman entityhuman) { - MovingObjectPosition movingobjectposition = this.a(world, entityhuman, true); - - if (movingobjectposition == null) { - return itemstack; - } else { - if (movingobjectposition.type == EnumMovingObjectType.BLOCK) { - int i = movingobjectposition.b; - int j = movingobjectposition.c; - int k = movingobjectposition.d; - - if (!world.a(entityhuman, i, j, k)) { - return itemstack; - } - - if (!entityhuman.a(i, j, k, movingobjectposition.face, itemstack)) { - return itemstack; - } - - if (world.getType(i, j, k).getMaterial() == Material.WATER && world.getData(i, j, k) == 0 && world.isEmpty(i, j + 1, k)) { - // CraftBukkit start - special case for handling block placement with water lilies - org.bukkit.block.BlockState blockstate = org.bukkit.craftbukkit.block.CraftBlockState.getBlockState(world, i, j + 1, k); - world.setTypeUpdate(i, j + 1, k, Blocks.WATER_LILY); - org.bukkit.event.block.BlockPlaceEvent placeEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockstate, i, j, k); - if (placeEvent != null && (placeEvent.isCancelled() || !placeEvent.canBuild())) { - blockstate.update(true, false); - return itemstack; - } - // CraftBukkit end - - if (!entityhuman.abilities.canInstantlyBuild) { - --itemstack.count; - } - } - } - - return itemstack; - } - } -} diff --git a/src/main/java/net/minecraft/server/ItemWorldMap.java b/src/main/java/net/minecraft/server/ItemWorldMap.java deleted file mode 100644 index c08cccaf..00000000 --- a/src/main/java/net/minecraft/server/ItemWorldMap.java +++ /dev/null @@ -1,231 +0,0 @@ -package net.minecraft.server; - -import net.minecraft.util.com.google.common.collect.HashMultiset; -import net.minecraft.util.com.google.common.collect.Iterables; -import net.minecraft.util.com.google.common.collect.Multisets; - -// CraftBukkit start -import org.bukkit.Bukkit; -import org.bukkit.event.server.MapInitializeEvent; -// CraftBukkit end - -public class ItemWorldMap extends ItemWorldMapBase { - - protected ItemWorldMap() { - this.a(true); - } - - public WorldMap getSavedMap(ItemStack itemstack, World world) { - World worldMain = world.getServer().getServer().worlds.get(0); // CraftBukkit - store reference to primary world - String s = "map_" + itemstack.getData(); - WorldMap worldmap = (WorldMap) worldMain.a(WorldMap.class, s); // CraftBukkit - use primary world for maps - - if (worldmap == null && !world.isStatic) { - itemstack.setData(worldMain.b("map")); // CraftBukkit - use primary world for maps - s = "map_" + itemstack.getData(); - worldmap = new WorldMap(s); - worldmap.scale = 3; - 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(); - worldMain.a(s, (PersistentBase) worldmap); // CraftBukkit - use primary world for maps - - // CraftBukkit start - MapInitializeEvent event = new MapInitializeEvent(worldmap.mapView); - Bukkit.getServer().getPluginManager().callEvent(event); - // CraftBukkit end - } - - return worldmap; - } - - public void a(World world, Entity entity, WorldMap worldmap) { - // CraftBukkit - world.worldProvider -> ((WorldServer) world) - if (((WorldServer) world).dimension == worldmap.map && entity instanceof EntityHuman) { - int i = 1 << worldmap.scale; - int j = worldmap.centerX; - int k = worldmap.centerZ; - int l = MathHelper.floor(entity.locX - (double) j) / i + 64; - int i1 = MathHelper.floor(entity.locZ - (double) k) / i + 64; - int j1 = 128 / i; - - if (world.worldProvider.g) { - j1 /= 2; - } - - WorldMapHumanTracker worldmaphumantracker = worldmap.a((EntityHuman) entity); - - ++worldmaphumantracker.d; - - for (int k1 = l - j1 + 1; k1 < l + j1; ++k1) { - if ((k1 & 15) == (worldmaphumantracker.d & 15)) { - int l1 = 255; - int i2 = 0; - double d0 = 0.0D; - - for (int j2 = i1 - j1 - 1; j2 < i1 + j1; ++j2) { - if (k1 >= 0 && j2 >= -1 && k1 < 128 && j2 < 128) { - int k2 = k1 - l; - int l2 = j2 - i1; - boolean flag = k2 * k2 + l2 * l2 > (j1 - 2) * (j1 - 2); - int i3 = (j / i + k1 - 64) * i; - int j3 = (k / i + j2 - 64) * i; - HashMultiset hashmultiset = HashMultiset.create(); - Chunk chunk = world.getChunkAtWorldCoords(i3, j3); - - if (!chunk.isEmpty()) { - int k3 = i3 & 15; - int l3 = j3 & 15; - int i4 = 0; - double d1 = 0.0D; - int j4; - - if (world.worldProvider.g) { - j4 = i3 + j3 * 231871; - j4 = j4 * j4 * 31287121 + j4 * 11; - if ((j4 >> 20 & 1) == 0) { - hashmultiset.add(Blocks.DIRT.f(0), 10); - } else { - hashmultiset.add(Blocks.STONE.f(0), 100); - } - - d1 = 100.0D; - } else { - for (j4 = 0; j4 < i; ++j4) { - for (int k4 = 0; k4 < i; ++k4) { - int l4 = chunk.b(j4 + k3, k4 + l3) + 1; - Block block = Blocks.AIR; - int i5 = 0; - - if (l4 > 1) { - do { - --l4; - block = chunk.getType(j4 + k3, l4, k4 + l3); - i5 = chunk.getData(j4 + k3, l4, k4 + l3); - } while (block.f(i5) == MaterialMapColor.b && l4 > 0); - - if (l4 > 0 && block.getMaterial().isLiquid()) { - int j5 = l4 - 1; - - Block block1; - - do { - block1 = chunk.getType(j4 + k3, j5--, k4 + l3); - ++i4; - } while (j5 > 0 && block1.getMaterial().isLiquid()); - } - } - - d1 += (double) l4 / (double) (i * i); - hashmultiset.add(block.f(i5)); - } - } - } - - i4 /= i * i; - double d2 = (d1 - d0) * 4.0D / (double) (i + 4) + ((double) (k1 + j2 & 1) - 0.5D) * 0.4D; - byte b0 = 1; - - if (d2 > 0.6D) { - b0 = 2; - } - - if (d2 < -0.6D) { - b0 = 0; - } - - MaterialMapColor materialmapcolor = (MaterialMapColor) Iterables.getFirst(Multisets.copyHighestCountFirst(hashmultiset), MaterialMapColor.b); - - if (materialmapcolor == MaterialMapColor.n) { - d2 = (double) i4 * 0.1D + (double) (k1 + j2 & 1) * 0.2D; - b0 = 1; - if (d2 < 0.5D) { - b0 = 2; - } - - if (d2 > 0.9D) { - b0 = 0; - } - } - - d0 = d1; - if (j2 >= 0 && k2 * k2 + l2 * l2 < j1 * j1 && (!flag || (k1 + j2 & 1) != 0)) { - byte b1 = worldmap.colors[k1 + j2 * 128]; - byte b2 = (byte) (materialmapcolor.M * 4 + b0); - - if (b1 != b2) { - if (l1 > j2) { - l1 = j2; - } - - if (i2 < j2) { - i2 = j2; - } - - worldmap.colors[k1 + j2 * 128] = b2; - } - } - } - } - } - - if (l1 <= i2) { - worldmap.flagDirty(k1, l1, i2); - } - } - } - } - } - - public void a(ItemStack itemstack, World world, Entity entity, int i, boolean flag) { - if (!world.isStatic) { - WorldMap worldmap = this.getSavedMap(itemstack, world); - - if (entity instanceof EntityHuman) { - EntityHuman entityhuman = (EntityHuman) entity; - - worldmap.a(entityhuman, itemstack); - } - - if (flag) { - this.a(world, entity, worldmap); - } - } - } - - public Packet c(ItemStack itemstack, World world, EntityHuman entityhuman) { - byte[] abyte = this.getSavedMap(itemstack, world).getUpdatePacket(itemstack, world, entityhuman); - - return abyte == null ? null : new PacketPlayOutMap(itemstack.getData(), abyte); - } - - public void d(ItemStack itemstack, World world, EntityHuman entityhuman) { - if (itemstack.hasTag() && itemstack.getTag().getBoolean("map_is_scaling")) { - WorldMap worldmap = Items.MAP.getSavedMap(itemstack, world); - - world = world.getServer().getServer().worlds.get(0); // CraftBukkit - use primary world for maps - - 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(), (PersistentBase) 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/JsonList.java b/src/main/java/net/minecraft/server/JsonList.java deleted file mode 100644 index 9d1cb336..00000000 --- a/src/main/java/net/minecraft/server/JsonList.java +++ /dev/null @@ -1,166 +0,0 @@ -package net.minecraft.server; - -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.File; -import java.io.IOException; -import java.lang.reflect.ParameterizedType; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.Map; - -import net.minecraft.util.com.google.common.base.Charsets; -import net.minecraft.util.com.google.common.collect.Lists; -import net.minecraft.util.com.google.common.collect.Maps; -import net.minecraft.util.com.google.common.io.Files; -import net.minecraft.util.com.google.gson.Gson; -import net.minecraft.util.com.google.gson.GsonBuilder; -import net.minecraft.util.com.google.gson.JsonObject; -import net.minecraft.util.org.apache.commons.io.IOUtils; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -public class JsonList { - - protected static final Logger a = LogManager.getLogger(); - protected final Gson b; - private final File c; - private final Map d = Maps.newHashMap(); - private boolean e = true; - private static final ParameterizedType f = new JsonListType(); - - public JsonList(File file1) { - this.c = file1; - GsonBuilder gsonbuilder = (new GsonBuilder()).setPrettyPrinting(); - - gsonbuilder.registerTypeHierarchyAdapter(JsonListEntry.class, new JsonListEntrySerializer(this, (JsonListType) null)); - this.b = gsonbuilder.create(); - } - - public boolean isEnabled() { - return this.e; - } - - public void a(boolean flag) { - this.e = flag; - } - - public File c() { - return this.c; - } - - public void add(JsonListEntry jsonlistentry) { - this.d.put(this.a(jsonlistentry.getKey()), jsonlistentry); - - try { - this.save(); - } catch (IOException ioexception) { - a.warn("Could not save the list after adding a user.", ioexception); - } - } - - public JsonListEntry get(Object object) { - this.h(); - return (JsonListEntry) this.d.get(this.a(object)); - } - - public void remove(Object object) { - this.d.remove(this.a(object)); - - try { - this.save(); - } catch (IOException ioexception) { - a.warn("Could not save the list after removing a user.", ioexception); - } - } - - public String[] getEntries() { - return (String[]) this.d.keySet().toArray(new String[this.d.size()]); - } - - // CraftBukkit start - public Collection<JsonListEntry> getValues() { - return this.d.values(); - } - // CraftBukkit end - - public boolean isEmpty() { - return this.d.size() < 1; - } - - protected String a(Object object) { - return object.toString(); - } - - protected boolean d(Object object) { - return this.d.containsKey(this.a(object)); - } - - private void h() { - ArrayList arraylist = Lists.newArrayList(); - Iterator iterator = this.d.values().iterator(); - - while (iterator.hasNext()) { - JsonListEntry jsonlistentry = (JsonListEntry) iterator.next(); - - if (jsonlistentry.hasExpired()) { - arraylist.add(jsonlistentry.getKey()); - } - } - - iterator = arraylist.iterator(); - - while (iterator.hasNext()) { - Object object = iterator.next(); - - this.d.remove(object); - } - } - - protected JsonListEntry a(JsonObject jsonobject) { - return new JsonListEntry(null, jsonobject); - } - - protected Map e() { - return this.d; - } - - public void save() throws IOException { // CraftBukkit - Added throws - Collection collection = this.d.values(); - String s = this.b.toJson(collection); - BufferedWriter bufferedwriter = null; - - try { - bufferedwriter = Files.newWriter(this.c, Charsets.UTF_8); - bufferedwriter.write(s); - } finally { - IOUtils.closeQuietly(bufferedwriter); - } - } - - public void load() throws IOException { // CraftBukkit - Added throws - Collection collection = null; - BufferedReader bufferedreader = null; - - try { - bufferedreader = Files.newReader(this.c, Charsets.UTF_8); - collection = (Collection) this.b.fromJson(bufferedreader, f); - } finally { - IOUtils.closeQuietly(bufferedreader); - } - - if (collection != null) { - this.d.clear(); - Iterator iterator = collection.iterator(); - - while (iterator.hasNext()) { - JsonListEntry jsonlistentry = (JsonListEntry) iterator.next(); - - if (jsonlistentry.getKey() != null) { - this.d.put(this.a(jsonlistentry.getKey()), jsonlistentry); - } - } - } - } -} diff --git a/src/main/java/net/minecraft/server/JsonListEntry.java b/src/main/java/net/minecraft/server/JsonListEntry.java deleted file mode 100644 index 1cd5104b..00000000 --- a/src/main/java/net/minecraft/server/JsonListEntry.java +++ /dev/null @@ -1,26 +0,0 @@ -package net.minecraft.server; - -import net.minecraft.util.com.google.gson.JsonObject; - -public class JsonListEntry { - - private final Object a; - - public JsonListEntry(Object object) { - this.a = object; - } - - protected JsonListEntry(Object object, JsonObject jsonobject) { - this.a = object; - } - - public Object getKey() { // CraftBukkit -> package private -> public - return this.a; - } - - boolean hasExpired() { - return false; - } - - protected void a(JsonObject jsonobject) {} -} diff --git a/src/main/java/net/minecraft/server/JsonListEntrySerializer.java b/src/main/java/net/minecraft/server/JsonListEntrySerializer.java deleted file mode 100644 index f4eee668..00000000 --- a/src/main/java/net/minecraft/server/JsonListEntrySerializer.java +++ /dev/null @@ -1,51 +0,0 @@ -package net.minecraft.server; - -// CraftBukkit - Imported for package private use in JsonList - -import java.lang.reflect.Type; - -import net.minecraft.util.com.google.gson.JsonDeserializationContext; -import net.minecraft.util.com.google.gson.JsonDeserializer; -import net.minecraft.util.com.google.gson.JsonElement; -import net.minecraft.util.com.google.gson.JsonObject; -import net.minecraft.util.com.google.gson.JsonSerializationContext; -import net.minecraft.util.com.google.gson.JsonSerializer; - -class JsonListEntrySerializer implements JsonDeserializer, JsonSerializer { - - final JsonList a; - - private JsonListEntrySerializer(JsonList jsonlist) { - this.a = jsonlist; - } - - public JsonElement a(JsonListEntry jsonlistentry, Type type, JsonSerializationContext jsonserializationcontext) { - JsonObject jsonobject = new JsonObject(); - - jsonlistentry.a(jsonobject); - return jsonobject; - } - - public JsonListEntry a(JsonElement jsonelement, Type type, JsonDeserializationContext jsondeserializationcontext) { - if (jsonelement.isJsonObject()) { - JsonObject jsonobject = jsonelement.getAsJsonObject(); - JsonListEntry jsonlistentry = this.a.a(jsonobject); - - return jsonlistentry; - } else { - return null; - } - } - - public JsonElement serialize(Object object, Type type, JsonSerializationContext jsonserializationcontext) { - return this.a((JsonListEntry) object, type, jsonserializationcontext); - } - - public Object deserialize(JsonElement jsonelement, Type type, JsonDeserializationContext jsondeserializationcontext) { - return this.a(jsonelement, type, jsondeserializationcontext); - } - - JsonListEntrySerializer(JsonList jsonlist, JsonListType jsonlisttype) { - this(jsonlist); - } -} diff --git a/src/main/java/net/minecraft/server/LoginListener.java b/src/main/java/net/minecraft/server/LoginListener.java deleted file mode 100644 index 8f982f17..00000000 --- a/src/main/java/net/minecraft/server/LoginListener.java +++ /dev/null @@ -1,151 +0,0 @@ -package net.minecraft.server; - -import java.security.PrivateKey; -import java.util.Arrays; -import java.util.Random; -import java.util.UUID; -import java.util.concurrent.atomic.AtomicInteger; -import javax.crypto.SecretKey; - -import net.minecraft.util.com.google.common.base.Charsets; -import net.minecraft.util.com.mojang.authlib.GameProfile; -import net.minecraft.util.io.netty.util.concurrent.GenericFutureListener; -import net.minecraft.util.org.apache.commons.lang3.Validate; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -public class LoginListener implements PacketLoginInListener { - - private static final AtomicInteger b = new AtomicInteger(0); - private static final Logger c = LogManager.getLogger(); - private static final Random random = new Random(); - private final byte[] e = new byte[4]; - private final MinecraftServer server; - public final NetworkManager networkManager; - private EnumProtocolState g; - private int h; - private GameProfile i; - private String j; - private SecretKey loginKey; - public String hostname = ""; // CraftBukkit - add field - - public LoginListener(MinecraftServer minecraftserver, NetworkManager networkmanager) { - this.g = EnumProtocolState.HELLO; - this.j = ""; - this.server = minecraftserver; - this.networkManager = networkmanager; - random.nextBytes(this.e); - } - - public void a() { - if (this.g == EnumProtocolState.READY_TO_ACCEPT) { - this.c(); - } - - if (this.h++ == 600) { - this.disconnect("Took too long to log in"); - } - } - - public void disconnect(String s) { - try { - c.info("Disconnecting " + this.getName() + ": " + s); - ChatComponentText chatcomponenttext = new ChatComponentText(s); - - this.networkManager.handle(new PacketLoginOutDisconnect(chatcomponenttext), new GenericFutureListener[0]); - this.networkManager.close(chatcomponenttext); - } catch (Exception exception) { - c.error("Error whilst disconnecting player", exception); - } - } - - public void c() { - if (!this.i.isComplete()) { - this.i = this.a(this.i); - } - - // CraftBukkit start - fire PlayerLoginEvent - EntityPlayer s = this.server.getPlayerList().attemptLogin(this, this.i, this.hostname); - - if (s == null) { - // this.disconnect(s); - // CraftBukkit end - } else { - this.g = EnumProtocolState.e; - this.networkManager.handle(new PacketLoginOutSuccess(this.i), new GenericFutureListener[0]); - this.server.getPlayerList().a(this.networkManager, this.server.getPlayerList().processLogin(this.i, s)); // CraftBukkit - add player reference - } - } - - public void a(IChatBaseComponent ichatbasecomponent) { - c.info(this.getName() + " lost connection: " + ichatbasecomponent.c()); - } - - public String getName() { - return this.i != null ? this.i.toString() + " (" + this.networkManager.getSocketAddress().toString() + ")" : String.valueOf(this.networkManager.getSocketAddress()); - } - - public void a(EnumProtocol enumprotocol, EnumProtocol enumprotocol1) { - Validate.validState(this.g == EnumProtocolState.e || this.g == EnumProtocolState.HELLO, "Unexpected change in protocol", new Object[0]); - Validate.validState(enumprotocol1 == EnumProtocol.PLAY || enumprotocol1 == EnumProtocol.LOGIN, "Unexpected protocol " + enumprotocol1, new Object[0]); - } - - public void a(PacketLoginInStart packetlogininstart) { - Validate.validState(this.g == EnumProtocolState.HELLO, "Unexpected hello packet", new Object[0]); - this.i = packetlogininstart.c(); - if (this.server.getOnlineMode() && !this.networkManager.c()) { - this.g = EnumProtocolState.KEY; - this.networkManager.handle(new PacketLoginOutEncryptionBegin(this.j, this.server.K().getPublic(), this.e), new GenericFutureListener[0]); - } else { - this.g = EnumProtocolState.READY_TO_ACCEPT; - } - } - - public void a(PacketLoginInEncryptionBegin packetlogininencryptionbegin) { - Validate.validState(this.g == EnumProtocolState.KEY, "Unexpected key packet", new Object[0]); - PrivateKey privatekey = this.server.K().getPrivate(); - - if (!Arrays.equals(this.e, packetlogininencryptionbegin.b(privatekey))) { - throw new IllegalStateException("Invalid nonce!"); - } else { - this.loginKey = packetlogininencryptionbegin.a(privatekey); - this.g = EnumProtocolState.AUTHENTICATING; - this.networkManager.a(this.loginKey); - (new ThreadPlayerLookupUUID(this, "User Authenticator #" + b.incrementAndGet())).start(); - } - } - - protected GameProfile a(GameProfile gameprofile) { - UUID uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + gameprofile.getName()).getBytes(Charsets.UTF_8)); - - return new GameProfile(uuid, gameprofile.getName()); - } - - static GameProfile a(LoginListener loginlistener) { - return loginlistener.i; - } - - static String b(LoginListener loginlistener) { - return loginlistener.j; - } - - static MinecraftServer c(LoginListener loginlistener) { - return loginlistener.server; - } - - static SecretKey d(LoginListener loginlistener) { - return loginlistener.loginKey; - } - - static GameProfile a(LoginListener loginlistener, GameProfile gameprofile) { - return loginlistener.i = gameprofile; - } - - static Logger e() { - return c; - } - - static EnumProtocolState a(LoginListener loginlistener, EnumProtocolState enumprotocolstate) { - return loginlistener.g = enumprotocolstate; - } -} diff --git a/src/main/java/net/minecraft/server/MethodProfiler.java b/src/main/java/net/minecraft/server/MethodProfiler.java deleted file mode 100644 index 7285e09e..00000000 --- a/src/main/java/net/minecraft/server/MethodProfiler.java +++ /dev/null @@ -1,24 +0,0 @@ -package net.minecraft.server; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -// CraftBukkit start - Strip down to empty methods, performance cost -public class MethodProfiler { - public boolean a = false; - - public final void a() { } - public final void a(String s) { } - public final void b() { } - public final List b(String s) { return null; } - public final void c(String s) { } - public final String c() { return null; } -} -// CraftBukkit end diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java deleted file mode 100644 index e65cbfae..00000000 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ /dev/null @@ -1,1321 +0,0 @@ -package net.minecraft.server; - -import java.awt.GraphicsEnvironment; -import java.awt.image.BufferedImage; -import java.io.File; -import java.net.Proxy; -import java.security.KeyPair; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Date; -import java.util.Iterator; -import java.util.List; -import java.util.Random; -import java.util.UUID; -import java.util.concurrent.Callable; -import javax.imageio.ImageIO; - -import net.minecraft.util.com.google.common.base.Charsets; -import net.minecraft.util.com.mojang.authlib.GameProfile; -import net.minecraft.util.com.mojang.authlib.GameProfileRepository; -import net.minecraft.util.com.mojang.authlib.minecraft.MinecraftSessionService; -import net.minecraft.util.com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService; -import net.minecraft.util.io.netty.buffer.ByteBuf; -import net.minecraft.util.io.netty.buffer.ByteBufOutputStream; -import net.minecraft.util.io.netty.buffer.Unpooled; -import net.minecraft.util.io.netty.handler.codec.base64.Base64; -import net.minecraft.util.org.apache.commons.lang3.Validate; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -// CraftBukkit start -import java.io.IOException; - -import jline.console.ConsoleReader; -import joptsimple.OptionSet; - -import org.bukkit.World.Environment; -import org.bukkit.craftbukkit.util.Waitable; -import org.bukkit.event.server.RemoteServerCommandEvent; -import org.bukkit.event.world.WorldSaveEvent; -// CraftBukkit end - -public abstract class MinecraftServer implements ICommandListener, Runnable, IMojangStatistics { - - private static final Logger i = LogManager.getLogger(); - private static final File a = new File("usercache.json"); - private static MinecraftServer j; - public Convertable convertable; // CraftBukkit - private final -> public - private final MojangStatisticsGenerator l = new MojangStatisticsGenerator("server", this, ar()); - public File universe; // CraftBukkit - private final -> public - private final List n = new ArrayList(); - private final ICommandHandler o; - public final MethodProfiler methodProfiler = new MethodProfiler(); - private final ServerConnection p; - private final ServerPing q = new ServerPing(); - private final Random r = new Random(); - private String serverIp; - private int t = -1; - public WorldServer[] worldServer; - private PlayerList u; - private boolean isRunning = true; - private boolean isStopped; - private int ticks; - protected final Proxy d; - public String e; - public int f; - private boolean onlineMode; - private boolean spawnAnimals; - private boolean spawnNPCs; - private boolean pvpMode; - private boolean allowFlight; - private String motd; - private int E; - private int F = 0; - public final long[] g = new long[100]; - public long[][] h; - private KeyPair G; - private String H; - private String I; - private boolean demoMode; - private boolean L; - private boolean M; - private String N = ""; - private boolean O; - private long P; - private String Q; - private boolean R; - private boolean S; - private final YggdrasilAuthenticationService T; - private final MinecraftSessionService U; - private long V = 0L; - private final GameProfileRepository W; - private final UserCache X; - - // CraftBukkit start - add fields - public List<WorldServer> worlds = new ArrayList<WorldServer>(); - public org.bukkit.craftbukkit.CraftServer server; - public OptionSet options; - public org.bukkit.command.ConsoleCommandSender console; - public org.bukkit.command.RemoteConsoleCommandSender remoteConsole; - public ConsoleReader reader; - public static int currentTick = (int) (System.currentTimeMillis() / 50); - public final Thread primaryThread; - public java.util.Queue<Runnable> processQueue = new java.util.concurrent.ConcurrentLinkedQueue<Runnable>(); - public int autosavePeriod; - // CraftBukkit end - - public MinecraftServer(OptionSet options, Proxy proxy) { // CraftBukkit - signature file -> OptionSet - this.X = new UserCache(this, a); - j = this; - this.d = proxy; - // this.universe = file1; // CraftBukkit - this.p = new ServerConnection(this); - this.o = new CommandDispatcher(); - // this.convertable = new WorldLoaderServer(file1); // CraftBukkit - moved to DedicatedServer.init - this.T = new YggdrasilAuthenticationService(proxy, UUID.randomUUID().toString()); - this.U = this.T.createMinecraftSessionService(); - this.W = this.T.createProfileRepository(); - // CraftBukkit start - this.options = options; - // Try to see if we're actually running in a terminal, disable jline if not - if (System.console() == null) { - System.setProperty("jline.terminal", "jline.UnsupportedTerminal"); - org.bukkit.craftbukkit.Main.useJline = false; - } - - try { - this.reader = new ConsoleReader(System.in, System.out); - this.reader.setExpandEvents(false); // Avoid parsing exceptions for uncommonly used event designators - } catch (Throwable e) { - try { - // Try again with jline disabled for Windows users without C++ 2008 Redistributable - System.setProperty("jline.terminal", "jline.UnsupportedTerminal"); - System.setProperty("user.language", "en"); - org.bukkit.craftbukkit.Main.useJline = false; - this.reader = new ConsoleReader(System.in, System.out); - this.reader.setExpandEvents(false); - } catch (IOException ex) { - i.warn((String) null, ex); - } - } - Runtime.getRuntime().addShutdownHook(new org.bukkit.craftbukkit.util.ServerShutdownThread(this)); - - primaryThread = new ThreadServerApplication(this, "Server thread"); // Moved from main - } - - public abstract PropertyManager getPropertyManager(); - // CraftBukkit end - - protected abstract boolean init() throws java.net.UnknownHostException; // CraftBukkit - throws UnknownHostException - - protected void a(String s) { - if (this.getConvertable().isConvertable(s)) { - i.info("Converting map!"); - this.b("menu.convertingLevel"); - this.getConvertable().convert(s, new ConvertProgressUpdater(this)); - } - } - - protected synchronized void b(String s) { - this.Q = s; - } - - protected void a(String s, String s1, long i, WorldType worldtype, String s2) { - this.a(s); - this.b("menu.loadingLevel"); - this.worldServer = new WorldServer[3]; - // this.h = new long[this.worldServer.length][100]; // CraftBukkit - Removed ticktime arrays - // IDataManager idatamanager = this.convertable.a(s, true); - // WorldData worlddata = idatamanager.getWorldData(); - /* CraftBukkit start - Removed worldsettings - WorldSettings worldsettings; - - if (worlddata == null) { - worldsettings = new WorldSettings(i, this.getGamemode(), this.getGenerateStructures(), this.isHardcore(), worldtype); - worldsettings.a(s2); - } else { - worldsettings = new WorldSettings(worlddata); - } - - if (this.L) { - worldsettings.a(); - } - // */ - int worldCount = 3; - - for (int j = 0; j < worldCount; ++j) { - WorldServer world; - int dimension = 0; - - if (j == 1) { - if (this.getAllowNether()) { - dimension = -1; - } else { - continue; - } - } - - if (j == 2) { - if (this.server.getAllowEnd()) { - dimension = 1; - } else { - continue; - } - } - - String worldType = Environment.getEnvironment(dimension).toString().toLowerCase(); - String name = (dimension == 0) ? s : s + "_" + worldType; - - org.bukkit.generator.ChunkGenerator gen = this.server.getGenerator(name); - WorldSettings worldsettings = new WorldSettings(i, this.getGamemode(), this.getGenerateStructures(), this.isHardcore(), worldtype); - worldsettings.a(s2); - - if (j == 0) { - IDataManager idatamanager = new ServerNBTManager(server.getWorldContainer(), s1, true); - if (this.R()) { - world = new DemoWorldServer(this, idatamanager, s1, dimension, this.methodProfiler); - } else { - // world =, b0 to dimension, added Environment and gen - world = new WorldServer(this, idatamanager, s1, dimension, worldsettings, this.methodProfiler, Environment.getEnvironment(dimension), gen); - } - this.server.scoreboardManager = new org.bukkit.craftbukkit.scoreboard.CraftScoreboardManager(this, world.getScoreboard()); - } else { - String dim = "DIM" + dimension; - - File newWorld = new File(new File(name), dim); - File oldWorld = new File(new File(s), dim); - - if ((!newWorld.isDirectory()) && (oldWorld.isDirectory())) { - MinecraftServer.i.info("---- Migration of old " + worldType + " folder required ----"); - MinecraftServer.i.info("Unfortunately due to the way that Minecraft implemented multiworld support in 1.6, Bukkit requires that you move your " + worldType + " folder to a new location in order to operate correctly."); - MinecraftServer.i.info("We will move this folder for you, but it will mean that you need to move it back should you wish to stop using Bukkit in the future."); - MinecraftServer.i.info("Attempting to move " + oldWorld + " to " + newWorld + "..."); - - if (newWorld.exists()) { - MinecraftServer.i.warn("A file or folder already exists at " + newWorld + "!"); - MinecraftServer.i.info("---- Migration of old " + worldType + " folder failed ----"); - } else if (newWorld.getParentFile().mkdirs()) { - if (oldWorld.renameTo(newWorld)) { - MinecraftServer.i.info("Success! To restore " + worldType + " in the future, simply move " + newWorld + " to " + oldWorld); - // Migrate world data too. - try { - com.google.common.io.Files.copy(new File(new File(s), "level.dat"), new File(new File(name), "level.dat")); - } catch (IOException exception) { - MinecraftServer.i.warn("Unable to migrate world data."); - } - MinecraftServer.i.info("---- Migration of old " + worldType + " folder complete ----"); - } else { - MinecraftServer.i.warn("Could not move folder " + oldWorld + " to " + newWorld + "!"); - MinecraftServer.i.info("---- Migration of old " + worldType + " folder failed ----"); - } - } else { - MinecraftServer.i.warn("Could not create path for " + newWorld + "!"); - MinecraftServer.i.info("---- Migration of old " + worldType + " folder failed ----"); - } - } - - IDataManager idatamanager = new ServerNBTManager(server.getWorldContainer(), name, true); - // world =, b0 to dimension, s1 to name, added Environment and gen - world = new SecondaryWorldServer(this, idatamanager, name, dimension, worldsettings, this.worlds.get(0), this.methodProfiler, Environment.getEnvironment(dimension), gen); - } - - if (gen != null) { - world.getWorld().getPopulators().addAll(gen.getDefaultPopulators(world.getWorld())); - } - - this.server.getPluginManager().callEvent(new org.bukkit.event.world.WorldInitEvent(world.getWorld())); - - world.addIWorldAccess(new WorldManager(this, world)); - if (!this.N()) { - world.getWorldData().setGameType(this.getGamemode()); - } - - this.worlds.add(world); - this.u.setPlayerFileData(this.worlds.toArray(new WorldServer[this.worlds.size()])); - // CraftBukkit end - } - - this.a(this.getDifficulty()); - this.g(); - } - - protected void g() { - boolean flag = true; - boolean flag1 = true; - boolean flag2 = true; - boolean flag3 = true; - int i = 0; - - this.b("menu.generatingTerrain"); - byte b0 = 0; - - // CraftBukkit start - fire WorldLoadEvent and handle whether or not to keep the spawn in memory - for (int m = 0; m < this.worlds.size(); ++m) { - WorldServer worldserver = this.worlds.get(m); - MinecraftServer.i.info("Preparing start region for level " + m + " (Seed: " + worldserver.getSeed() + ")"); - if (!worldserver.getWorld().getKeepSpawnInMemory()) { - continue; - } - - ChunkCoordinates chunkcoordinates = worldserver.getSpawn(); - long j = ar(); - i = 0; - - for (int k = -192; k <= 192 && this.isRunning(); k += 16) { - for (int l = -192; l <= 192 && this.isRunning(); l += 16) { - long i1 = ar(); - - if (i1 - j > 1000L) { - this.a_("Preparing spawn area", i * 100 / 625); - j = i1; - } - - ++i; - worldserver.chunkProviderServer.getChunkAt(chunkcoordinates.x + k >> 4, chunkcoordinates.z + l >> 4); - } - } - } - - for (WorldServer world : this.worlds) { - this.server.getPluginManager().callEvent(new org.bukkit.event.world.WorldLoadEvent(world.getWorld())); - } - // CraftBukkit end - this.n(); - } - - public abstract boolean getGenerateStructures(); - - public abstract EnumGamemode getGamemode(); - - public abstract EnumDifficulty getDifficulty(); - - public abstract boolean isHardcore(); - - public abstract int l(); - - public abstract boolean m(); - - protected void a_(String s, int i) { - this.e = s; - this.f = i; - // CraftBukkit - Use FQN to work around decompiler issue - MinecraftServer.i.info(s + ": " + i + "%"); - } - - protected void n() { - this.e = null; - this.f = 0; - - this.server.enablePlugins(org.bukkit.plugin.PluginLoadOrder.POSTWORLD); // CraftBukkit - } - - protected void saveChunks(boolean flag) throws ExceptionWorldConflict { // CraftBukkit - added throws - if (!this.M) { - // CraftBukkit start - fire WorldSaveEvent - // WorldServer[] aworldserver = this.worldServer; - int i = this.worlds.size(); - - for (int j = 0; j < i; ++j) { - WorldServer worldserver = this.worlds.get(j); - - if (worldserver != null) { - if (!flag) { - MinecraftServer.i.info("Saving chunks for level \'" + worldserver.getWorldData().getName() + "\'/" + worldserver.worldProvider.getName()); - } - - worldserver.save(true, (IProgressUpdate) null); - worldserver.saveLevel(); - - WorldSaveEvent event = new WorldSaveEvent(worldserver.getWorld()); - this.server.getPluginManager().callEvent(event); - // CraftBukkit end - } - } - } - } - - public void stop() throws ExceptionWorldConflict { // CraftBukkit - added throws - if (!this.M) { - i.info("Stopping server"); - // CraftBukkit start - if (this.server != null) { - this.server.disablePlugins(); - } - // CraftBukkit end - - if (this.ai() != null) { - this.ai().b(); - } - - if (this.u != null) { - i.info("Saving players"); - this.u.savePlayers(); - this.u.u(); - } - - if (this.worldServer != null) { - i.info("Saving worlds"); - this.saveChunks(false); - - /* CraftBukkit start - Handled in saveChunks - for (int i = 0; i < this.worldServer.length; ++i) { - WorldServer worldserver = this.worldServer[i]; - - worldserver.saveLevel(); - } - // CraftBukkit end */ - } - - if (this.l.d()) { - this.l.e(); - } - } - } - - public String getServerIp() { - return this.serverIp; - } - - public void c(String s) { - this.serverIp = s; - } - - public boolean isRunning() { - return this.isRunning; - } - - public void safeShutdown() { - this.isRunning = false; - } - - public void run() { - try { - if (this.init()) { - long i = ar(); - long j = 0L; - - this.q.setMOTD(new ChatComponentText(this.motd)); - this.q.setServerInfo(new ServerPingServerData("1.7.10", 5)); - this.a(this.q); - - while (this.isRunning) { - long k = ar(); - long l = k - i; - - if (l > 2000L && i - this.P >= 15000L) { - if (this.server.getWarnOnOverload()) // CraftBukkit - Added option to suppress warning messages - MinecraftServer.i.warn("Can\'t keep up! Did the system time change, or is the server overloaded? Running {}ms behind, skipping {} tick(s)", new Object[] { Long.valueOf(l), Long.valueOf(l / 50L)}); - l = 2000L; - this.P = i; - } - - if (l < 0L) { - MinecraftServer.i.warn("Time ran backwards! Did the system time change?"); - l = 0L; - } - - j += l; - i = k; - if (this.worlds.get(0).everyoneDeeplySleeping()) { // CraftBukkit - this.u(); - j = 0L; - } else { - while (j > 50L) { - MinecraftServer.currentTick = (int) (System.currentTimeMillis() / 50); // CraftBukkit - j -= 50L; - this.u(); - } - } - - Thread.sleep(Math.max(1L, 50L - j)); - this.O = true; - } - } else { - this.a((CrashReport) null); - } - } catch (Throwable throwable) { - i.error("Encountered an unexpected exception", throwable); - CrashReport crashreport = null; - - if (throwable instanceof ReportedException) { - crashreport = this.b(((ReportedException) throwable).a()); - } else { - crashreport = this.b(new CrashReport("Exception in server tick loop", throwable)); - } - - File file1 = new File(new File(this.s(), "crash-reports"), "crash-" + (new SimpleDateFormat("yyyy-MM-dd_HH.mm.ss")).format(new Date()) + "-server.txt"); - - if (crashreport.a(file1)) { - i.error("This crash report has been saved to: " + file1.getAbsolutePath()); - } else { - i.error("We were unable to save this crash report to disk."); - } - - this.a(crashreport); - } finally { - try { - this.stop(); - this.isStopped = true; - } catch (Throwable throwable1) { - i.error("Exception stopping the server", throwable1); - } finally { - // CraftBukkit start - Restore terminal to original settings - try { - this.reader.getTerminal().restore(); - } catch (Exception e) { - } - // CraftBukkit end - this.t(); - } - } - } - - private void a(ServerPing serverping) { - File file1 = this.d("server-icon.png"); - - if (file1.isFile()) { - ByteBuf bytebuf = Unpooled.buffer(); - - try { - BufferedImage bufferedimage = ImageIO.read(file1); - - Validate.validState(bufferedimage.getWidth() == 64, "Must be 64 pixels wide", new Object[0]); - Validate.validState(bufferedimage.getHeight() == 64, "Must be 64 pixels high", new Object[0]); - ImageIO.write(bufferedimage, "PNG", new ByteBufOutputStream(bytebuf)); - ByteBuf bytebuf1 = Base64.encode(bytebuf); - - serverping.setFavicon("data:image/png;base64," + bytebuf1.toString(Charsets.UTF_8)); - } catch (Exception exception) { - i.error("Couldn\'t load server icon", exception); - } finally { - bytebuf.release(); - } - } - } - - protected File s() { - return new File("."); - } - - protected void a(CrashReport crashreport) {} - - protected void t() {} - - protected void u() throws ExceptionWorldConflict { // CraftBukkit - added throws - long i = System.nanoTime(); - - ++this.ticks; - if (this.R) { - this.R = false; - this.methodProfiler.a = true; - this.methodProfiler.a(); - } - - this.methodProfiler.a("root"); - this.v(); - if (i - this.V >= 5000000000L) { - this.V = i; - this.q.setPlayerSample(new ServerPingPlayerSample(this.D(), this.C())); - GameProfile[] agameprofile = new GameProfile[Math.min(this.C(), 12)]; - int j = MathHelper.nextInt(this.r, 0, this.C() - agameprofile.length); - - for (int k = 0; k < agameprofile.length; ++k) { - agameprofile[k] = ((EntityPlayer) this.u.players.get(j + k)).getProfile(); - } - - Collections.shuffle(Arrays.asList(agameprofile)); - this.q.b().a(agameprofile); - } - - if ((this.autosavePeriod > 0) && ((this.ticks % this.autosavePeriod) == 0)) { // CraftBukkit - this.methodProfiler.a("save"); - this.u.savePlayers(); - this.saveChunks(true); - this.methodProfiler.b(); - } - - this.methodProfiler.a("tallying"); - this.g[this.ticks % 100] = System.nanoTime() - i; - this.methodProfiler.b(); - this.methodProfiler.a("snooper"); - if (!this.l.d() && this.ticks > 100) { - this.l.a(); - } - - if (this.ticks % 6000 == 0) { - this.l.b(); - } - - this.methodProfiler.b(); - this.methodProfiler.b(); - } - - public void v() { - this.methodProfiler.a("levels"); - - // CraftBukkit start - this.server.getScheduler().mainThreadHeartbeat(this.ticks); - - // Run tasks that are waiting on processing - while (!processQueue.isEmpty()) { - processQueue.remove().run(); - } - - org.bukkit.craftbukkit.chunkio.ChunkIOExecutor.tick(); - - // Send time updates to everyone, it will get the right time from the world the player is in. - if (this.ticks % 20 == 0) { - for (int i = 0; i < this.getPlayerList().players.size(); ++i) { - EntityPlayer entityplayer = (EntityPlayer) this.getPlayerList().players.get(i); - entityplayer.playerConnection.sendPacket(new PacketPlayOutUpdateTime(entityplayer.world.getTime(), entityplayer.getPlayerTime(), entityplayer.world.getGameRules().getBoolean("doDaylightCycle"))); // Add support for per player time - } - } - - int i; - - for (i = 0; i < this.worlds.size(); ++i) { - long j = System.nanoTime(); - - // if (i == 0 || this.getAllowNether()) { - WorldServer worldserver = this.worlds.get(i); - - this.methodProfiler.a(worldserver.getWorldData().getName()); - this.methodProfiler.a("pools"); - this.methodProfiler.b(); - /* Drop global time updates - if (this.ticks % 20 == 0) { - this.methodProfiler.a("timeSync"); - this.t.a(new PacketPlayOutUpdateTime(worldserver.getTime(), worldserver.getDayTime(), worldserver.getGameRules().getBoolean("doDaylightCycle")), worldserver.worldProvider.dimension); - this.methodProfiler.b(); - } - // CraftBukkit end */ - - this.methodProfiler.a("tick"); - - CrashReport crashreport; - - try { - worldserver.doTick(); - } catch (Throwable throwable) { - crashreport = CrashReport.a(throwable, "Exception ticking world"); - worldserver.a(crashreport); - throw new ReportedException(crashreport); - } - - try { - worldserver.tickEntities(); - } catch (Throwable throwable1) { - crashreport = CrashReport.a(throwable1, "Exception ticking world entities"); - worldserver.a(crashreport); - throw new ReportedException(crashreport); - } - - this.methodProfiler.b(); - this.methodProfiler.a("tracker"); - worldserver.getTracker().updatePlayers(); - this.methodProfiler.b(); - this.methodProfiler.b(); - // } // CraftBukkit - - // this.h[i][this.ticks % 100] = System.nanoTime() - j; // CraftBukkit - } - - this.methodProfiler.c("connection"); - this.ai().c(); - this.methodProfiler.c("players"); - this.u.tick(); - this.methodProfiler.c("tickables"); - - for (i = 0; i < this.n.size(); ++i) { - ((IUpdatePlayerListBox) this.n.get(i)).a(); - } - - this.methodProfiler.b(); - } - - public boolean getAllowNether() { - return true; - } - - public void a(IUpdatePlayerListBox iupdateplayerlistbox) { - this.n.add(iupdateplayerlistbox); - } - - public static void main(final OptionSet options) { // CraftBukkit - replaces main(String[] astring) - DispenserRegistry.b(); - - try { - /* CraftBukkit start - Replace everything - boolean flag = true; - String s = null; - String s1 = "."; - String s2 = null; - boolean flag1 = false; - boolean flag2 = false; - int i = -1; - - for (int j = 0; j < astring.length; ++j) { - String s3 = astring[j]; - String s4 = j == astring.length - 1 ? null : astring[j + 1]; - boolean flag3 = false; - - if (!s3.equals("nogui") && !s3.equals("--nogui")) { - if (s3.equals("--port") && s4 != null) { - flag3 = true; - - try { - i = Integer.parseInt(s4); - } catch (NumberFormatException numberformatexception) { - ; - } - } else if (s3.equals("--singleplayer") && s4 != null) { - flag3 = true; - s = s4; - } else if (s3.equals("--universe") && s4 != null) { - flag3 = true; - s1 = s4; - } else if (s3.equals("--world") && s4 != null) { - flag3 = true; - s2 = s4; - } else if (s3.equals("--demo")) { - flag1 = true; - } else if (s3.equals("--bonusChest")) { - flag2 = true; - } - } else { - flag = false; - } - - if (flag3) { - ++j; - } - } - - DedicatedServer dedicatedserver = new DedicatedServer(new File(s1)); - - if (s != null) { - dedicatedserver.j(s); - } - - if (s2 != null) { - dedicatedserver.k(s2); - } - - if (i >= 0) { - dedicatedserver.setPort(i); - } - - if (flag1) { - dedicatedserver.b(true); - } - - if (flag2) { - dedicatedserver.c(true); - } - - if (flag) { - dedicatedserver.aD(); - } - // */ - - DedicatedServer dedicatedserver = new DedicatedServer(options); - - if (options.has("port")) { - int port = (Integer) options.valueOf("port"); - if (port > 0) { - dedicatedserver.setPort(port); - } - } - - if (options.has("universe")) { - dedicatedserver.universe = (File) options.valueOf("universe"); - } - - if (options.has("world")) { - dedicatedserver.k((String) options.valueOf("world")); - } - - dedicatedserver.primaryThread.start(); - // Runtime.getRuntime().addShutdownHook(new ThreadShutdown("Server Shutdown Thread", dedicatedserver)); - // CraftBukkit end - } catch (Exception exception) { - i.fatal("Failed to start the minecraft server", exception); - } - } - - public void x() { - // (new ThreadServerApplication(this, "Server thread")).start(); // CraftBukkit - prevent abuse - } - - public File d(String s) { - return new File(this.s(), s); - } - - public void info(String s) { - i.info(s); - } - - public void warning(String s) { - i.warn(s); - } - - public WorldServer getWorldServer(int i) { - // CraftBukkit start - for (WorldServer world : this.worlds) { - if (world.dimension == i) { - return world; - } - } - - return this.worlds.get(0); - // CraftBukkit end - } - - public String y() { - return this.serverIp; - } - - public int z() { - return this.t; - } - - public String A() { - return this.motd; - } - - public String getVersion() { - return "1.7.10"; - } - - public int C() { - return this.u.getPlayerCount(); - } - - public int D() { - return this.u.getMaxPlayers(); - } - - public String[] getPlayers() { - return this.u.f(); - } - - public GameProfile[] F() { - return this.u.g(); - } - - public String getPlugins() { - // CraftBukkit start - Whole method - StringBuilder result = new StringBuilder(); - org.bukkit.plugin.Plugin[] plugins = server.getPluginManager().getPlugins(); - - result.append(server.getName()); - result.append(" on Bukkit "); - result.append(server.getBukkitVersion()); - - if (plugins.length > 0 && this.server.getQueryPlugins()) { - result.append(": "); - - for (int i = 0; i < plugins.length; i++) { - if (i > 0) { - result.append("; "); - } - - result.append(plugins[i].getDescription().getName()); - result.append(" "); - result.append(plugins[i].getDescription().getVersion().replaceAll(";", ",")); - } - } - - return result.toString(); - // CraftBukkit end - } - - // CraftBukkit start - fire RemoteServerCommandEvent - public String g(final String s) { // final parameter - Waitable<String> waitable = new Waitable<String>() { - @Override - protected String evaluate() { - RemoteControlCommandListener.instance.e(); - // Event changes start - RemoteServerCommandEvent event = new RemoteServerCommandEvent(MinecraftServer.this.remoteConsole, s); - MinecraftServer.this.server.getPluginManager().callEvent(event); - // Event changes end - ServerCommand servercommand = new ServerCommand(event.getCommand(), RemoteControlCommandListener.instance); - MinecraftServer.this.server.dispatchServerCommand(MinecraftServer.this.remoteConsole, servercommand); // CraftBukkit - // this.o.a(RemoteControlCommandListener.instance, s); - return RemoteControlCommandListener.instance.f(); - }}; - processQueue.add(waitable); - try { - return waitable.get(); - } catch (java.util.concurrent.ExecutionException e) { - throw new RuntimeException("Exception processing rcon command " + s, e.getCause()); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); // Maintain interrupted state - throw new RuntimeException("Interrupted processing rcon command " + s, e); - } - // CraftBukkit end - } - - public boolean isDebugging() { - return this.getPropertyManager().getBoolean("debug", false); // CraftBukkit - don't hardcode - } - - public void h(String s) { - i.error(s); - } - - public void i(String s) { - if (this.isDebugging()) { - i.info(s); - } - } - - public String getServerModName() { - return server.getName(); // CraftBukkit - cb > vanilla! - } - - public CrashReport b(CrashReport crashreport) { - crashreport.g().a("Profiler Position", (Callable) (new CrashReportProfilerPosition(this))); - if (this.worlds != null && this.worlds.size() > 0 && this.worlds.get(0) != null) { // CraftBukkit - crashreport.g().a("Vec3 Pool Size", (Callable) (new CrashReportVec3DPoolSize(this))); - } - - if (this.u != null) { - crashreport.g().a("Player Count", (Callable) (new CrashReportPlayerCount(this))); - } - - return crashreport; - } - - public List a(ICommandListener icommandlistener, String s) { - // CraftBukkit start - Allow tab-completion of Bukkit commands - /* - ArrayList arraylist = new ArrayList(); - - if (s.startsWith("/")) { - s = s.substring(1); - boolean flag = !s.contains(" "); - List list = this.o.b(icommandlistener, s); - - if (list != null) { - Iterator iterator = list.iterator(); - - while (iterator.hasNext()) { - String s1 = (String) iterator.next(); - - if (flag) { - arraylist.add("/" + s1); - } else { - arraylist.add(s1); - } - } - } - - return arraylist; - } else { - String[] astring = s.split(" ", -1); - String s2 = astring[astring.length - 1]; - String[] astring1 = this.u.f(); - int i = astring1.length; - - for (int j = 0; j < i; ++j) { - String s3 = astring1[j]; - - if (CommandAbstract.a(s2, s3)) { - arraylist.add(s3); - } - } - - return arraylist; - } - */ - return this.server.tabComplete(icommandlistener, s); - // CraftBukkit end - } - - public static MinecraftServer getServer() { - return j; - } - - public String getName() { - return "Server"; - } - - public void sendMessage(IChatBaseComponent ichatbasecomponent) { - i.info(ichatbasecomponent.c()); - } - - public boolean a(int i, String s) { - return true; - } - - public ICommandHandler getCommandHandler() { - return this.o; - } - - public KeyPair K() { - return this.G; - } - - public int L() { - return this.t; - } - - public void setPort(int i) { - this.t = i; - } - - public String M() { - return this.H; - } - - public void j(String s) { - this.H = s; - } - - public boolean N() { - return this.H != null; - } - - public String O() { - return this.I; - } - - public void k(String s) { - this.I = s; - } - - public void a(KeyPair keypair) { - this.G = keypair; - } - - public void a(EnumDifficulty enumdifficulty) { - // CraftBukkit start - Use worlds list for iteration - for (int j = 0; j < this.worlds.size(); ++j) { - WorldServer worldserver = this.worlds.get(j); - // CraftBukkit end - - if (worldserver != null) { - if (worldserver.getWorldData().isHardcore()) { - worldserver.difficulty = EnumDifficulty.HARD; - worldserver.setSpawnFlags(true, true); - } else if (this.N()) { - worldserver.difficulty = enumdifficulty; - worldserver.setSpawnFlags(worldserver.difficulty != EnumDifficulty.PEACEFUL, true); - } else { - worldserver.difficulty = enumdifficulty; - worldserver.setSpawnFlags(this.getSpawnMonsters(), this.spawnAnimals); - } - } - } - } - - protected boolean getSpawnMonsters() { - return true; - } - - public boolean R() { - return this.demoMode; - } - - public void b(boolean flag) { - this.demoMode = flag; - } - - public void c(boolean flag) { - this.L = flag; - } - - public Convertable getConvertable() { - return this.convertable; - } - - public void U() { - this.M = true; - this.getConvertable().d(); - - // CraftBukkit start - for (int i = 0; i < this.worlds.size(); ++i) { - WorldServer worldserver = this.worlds.get(i); - // CraftBukkit end - - if (worldserver != null) { - worldserver.saveLevel(); - } - } - - this.getConvertable().e(this.worlds.get(0).getDataManager().g()); // CraftBukkit - this.safeShutdown(); - } - - public String getResourcePack() { - return this.N; - } - - public void setTexturePack(String s) { - this.N = s; - } - - 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.C())); - mojangstatisticsgenerator.a("players_max", Integer.valueOf(this.D())); - mojangstatisticsgenerator.a("players_seen", Integer.valueOf(this.u.getSeenPlayers().length)); - mojangstatisticsgenerator.a("uses_auth", Boolean.valueOf(this.onlineMode)); - mojangstatisticsgenerator.a("gui_state", this.ak() ? "enabled" : "disabled"); - mojangstatisticsgenerator.a("run_time", Long.valueOf((ar() - mojangstatisticsgenerator.g()) / 60L * 1000L)); - mojangstatisticsgenerator.a("avg_tick_ms", Integer.valueOf((int) (MathHelper.a(this.g) * 1.0E-6D))); - int i = 0; - - // CraftBukkit start - use worlds list for iteration - for (int j = 0; j < this.worlds.size(); ++j) { - WorldServer worldserver = this.worlds.get(j); - if (worldServer != null) { - // CraftBukkit end - WorldData worlddata = worldserver.getWorldData(); - - mojangstatisticsgenerator.a("world[" + i + "][dimension]", Integer.valueOf(worldserver.worldProvider.dimension)); - mojangstatisticsgenerator.a("world[" + i + "][mode]", worlddata.getGameType()); - mojangstatisticsgenerator.a("world[" + i + "][difficulty]", worldserver.difficulty); - mojangstatisticsgenerator.a("world[" + i + "][hardcore]", Boolean.valueOf(worlddata.isHardcore())); - 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.E)); - mojangstatisticsgenerator.a("world[" + i + "][chunks_loaded]", Integer.valueOf(worldserver.L().getLoadedChunks())); - ++i; - } - } - - mojangstatisticsgenerator.a("worlds", Integer.valueOf(i)); - } - - public void b(MojangStatisticsGenerator mojangstatisticsgenerator) { - mojangstatisticsgenerator.b("singleplayer", Boolean.valueOf(this.N())); - mojangstatisticsgenerator.b("server_brand", this.getServerModName()); - mojangstatisticsgenerator.b("gui_supported", GraphicsEnvironment.isHeadless() ? "headless" : "supported"); - mojangstatisticsgenerator.b("dedicated", Boolean.valueOf(this.X())); - } - - public boolean getSnooperEnabled() { - return true; - } - - public abstract boolean X(); - - public boolean getOnlineMode() { - return this.server.getOnlineMode(); // CraftBukkit - } - - public void setOnlineMode(boolean flag) { - this.onlineMode = flag; - } - - public boolean getSpawnAnimals() { - return this.spawnAnimals; - } - - public void setSpawnAnimals(boolean flag) { - this.spawnAnimals = flag; - } - - public boolean getSpawnNPCs() { - return this.spawnNPCs; - } - - public void setSpawnNPCs(boolean flag) { - this.spawnNPCs = flag; - } - - public boolean getPvP() { - return this.pvpMode; - } - - public void setPvP(boolean flag) { - this.pvpMode = flag; - } - - public boolean getAllowFlight() { - return this.allowFlight; - } - - public void setAllowFlight(boolean flag) { - this.allowFlight = flag; - } - - public abstract boolean getEnableCommandBlock(); - - public String getMotd() { - return this.motd; - } - - public void setMotd(String s) { - this.motd = s; - } - - public int getMaxBuildHeight() { - return this.E; - } - - public void c(int i) { - this.E = i; - } - - public boolean isStopped() { - return this.isStopped; - } - - public PlayerList getPlayerList() { - return this.u; - } - - public void a(PlayerList playerlist) { - this.u = playerlist; - } - - public void a(EnumGamemode enumgamemode) { - // CraftBukkit start - use worlds list for iteration - for (int i = 0; i < this.worlds.size(); ++i) { - getServer().worlds.get(i).getWorldData().setGameType(enumgamemode); - // CraftBukkit end - } - } - - public ServerConnection ai() { - return this.p; - } - - public boolean ak() { - return false; - } - - public abstract String a(EnumGamemode enumgamemode, boolean flag); - - public int al() { - return this.ticks; - } - - public void am() { - this.R = true; - } - - public ChunkCoordinates getChunkCoordinates() { - return new ChunkCoordinates(0, 0, 0); - } - - public World getWorld() { - return this.worlds.get(0); // CraftBukkit - } - - public int getSpawnProtection() { - return 16; - } - - public boolean a(World world, int i, int j, int k, EntityHuman entityhuman) { - return false; - } - - public void setForceGamemode(boolean flag) { - this.S = flag; - } - - public boolean getForceGamemode() { - return this.S; - } - - public Proxy aq() { - return this.d; - } - - public static long ar() { - return System.currentTimeMillis(); - } - - public int getIdleTimeout() { - return this.F; - } - - public void setIdleTimeout(int i) { - this.F = i; - } - - public IChatBaseComponent getScoreboardDisplayName() { - return new ChatComponentText(this.getName()); - } - - public boolean at() { - return true; - } - - public MinecraftSessionService av() { - return this.U; - } - - public GameProfileRepository getGameProfileRepository() { - return this.W; - } - - public UserCache getUserCache() { - return this.X; - } - - public ServerPing ay() { - return this.q; - } - - public void az() { - this.V = 0L; - } - - public static Logger getLogger() { - return i; - } - - public static PlayerList a(MinecraftServer minecraftserver) { - return minecraftserver.u; - } -} diff --git a/src/main/java/net/minecraft/server/MobEffectList.java b/src/main/java/net/minecraft/server/MobEffectList.java deleted file mode 100644 index 6ec03bbe..00000000 --- a/src/main/java/net/minecraft/server/MobEffectList.java +++ /dev/null @@ -1,231 +0,0 @@ -package net.minecraft.server; - -import java.util.Iterator; -import java.util.Map; -import java.util.UUID; -import java.util.Map.Entry; - -import net.minecraft.util.com.google.common.collect.Maps; - -// CraftBukkit start -import org.bukkit.craftbukkit.event.CraftEventFactory; -import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; -// CraftBukkit end - -public class MobEffectList { - - public static final MobEffectList[] byId = new MobEffectList[32]; - public static final MobEffectList b = null; - public static final MobEffectList FASTER_MOVEMENT = (new MobEffectList(1, false, 8171462)).b("potion.moveSpeed").b(0, 0).a(GenericAttributes.d, "91AEAA56-376B-4498-935B-2F7F68070635", 0.20000000298023224D, 2); - public static final MobEffectList SLOWER_MOVEMENT = (new MobEffectList(2, true, 5926017)).b("potion.moveSlowdown").b(1, 0).a(GenericAttributes.d, "7107DE5E-7CE8-4030-940E-514C1F160890", -0.15000000596046448D, 2); - public static final MobEffectList FASTER_DIG = (new MobEffectList(3, false, 14270531)).b("potion.digSpeed").b(2, 0).a(1.5D); - public static final MobEffectList SLOWER_DIG = (new MobEffectList(4, true, 4866583)).b("potion.digSlowDown").b(3, 0); - public static final MobEffectList INCREASE_DAMAGE = (new MobEffectAttackDamage(5, false, 9643043)).b("potion.damageBoost").b(4, 0).a(GenericAttributes.e, "648D7064-6A60-4F59-8ABE-C2C23A6DD7A9", 3.0D, 2); - public static final MobEffectList HEAL = (new InstantMobEffect(6, false, 16262179)).b("potion.heal"); - public static final MobEffectList HARM = (new InstantMobEffect(7, true, 4393481)).b("potion.harm"); - public static final MobEffectList JUMP = (new MobEffectList(8, false, 7889559)).b("potion.jump").b(2, 1); - public static final MobEffectList CONFUSION = (new MobEffectList(9, true, 5578058)).b("potion.confusion").b(3, 1).a(0.25D); - public static final MobEffectList REGENERATION = (new MobEffectList(10, false, 13458603)).b("potion.regeneration").b(7, 0).a(0.25D); - 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); - 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); - public static final MobEffectList HUNGER = (new MobEffectList(17, true, 5797459)).b("potion.hunger").b(1, 1); - public static final MobEffectList WEAKNESS = (new MobEffectAttackDamage(18, true, 4738376)).b("potion.weakness").b(5, 0).a(GenericAttributes.e, "22653B89-116E-49DC-9B6B-9971489B5BE5", 2.0D, 0); - public static final MobEffectList POISON = (new MobEffectList(19, true, 5149489)).b("potion.poison").b(6, 0).a(0.25D); - public static final MobEffectList WITHER = (new MobEffectList(20, true, 3484199)).b("potion.wither").b(1, 2).a(0.25D); - public static final MobEffectList HEALTH_BOOST = (new MobEffectHealthBoost(21, false, 16284963)).b("potion.healthBoost").b(2, 2).a(GenericAttributes.maxHealth, "5D6F0BA2-1186-46AC-B896-C61C5CEE99CC", 4.0D, 0); - public static final MobEffectList ABSORPTION = (new MobEffectAbsorption(22, false, 2445989)).b("potion.absorption").b(2, 2); - public static final MobEffectList SATURATION = (new InstantMobEffect(23, false, 16262179)).b("potion.saturation"); - public static final MobEffectList z = null; - public static final MobEffectList A = null; - public static final MobEffectList B = null; - public static final MobEffectList C = null; - public static final MobEffectList D = null; - public static final MobEffectList E = null; - public static final MobEffectList F = null; - public static final MobEffectList G = null; - public final int id; - private final Map I = Maps.newHashMap(); - private final boolean J; - private final int K; - private String L = ""; - private int M = -1; - private double N; - private boolean O; - - protected MobEffectList(int i, boolean flag, int j) { - this.id = i; - byId[i] = this; - this.J = flag; - if (flag) { - this.N = 0.5D; - } else { - this.N = 1.0D; - } - - this.K = j; - - org.bukkit.potion.PotionEffectType.registerPotionEffectType(new org.bukkit.craftbukkit.potion.CraftPotionEffectType(this)); // CraftBukkit - } - - protected MobEffectList b(int i, int j) { - this.M = i + j * 8; - return this; - } - - public int getId() { - return this.id; - } - - public void tick(EntityLiving entityliving, int i) { - if (this.id == REGENERATION.id) { - if (entityliving.getHealth() < entityliving.getMaxHealth()) { - entityliving.heal(1.0F, RegainReason.MAGIC_REGEN); // CraftBukkit - } - } else if (this.id == POISON.id) { - if (entityliving.getHealth() > 1.0F) { - entityliving.damageEntity(CraftEventFactory.POISON, 1.0F); // CraftBukkit - DamageSource.MAGIC -> CraftEventFactory.POISON - } - } else if (this.id == WITHER.id) { - entityliving.damageEntity(DamageSource.WITHER, 1.0F); - } else if (this.id == HUNGER.id && entityliving instanceof EntityHuman) { - ((EntityHuman) entityliving).applyExhaustion(0.025F * (float) (i + 1)); - } else if (this.id == SATURATION.id && entityliving instanceof EntityHuman) { - if (!entityliving.world.isStatic) { - // CraftBukkit start - EntityHuman entityhuman = (EntityHuman) entityliving; - int oldFoodLevel = entityhuman.getFoodData().foodLevel; - - org.bukkit.event.entity.FoodLevelChangeEvent event = CraftEventFactory.callFoodLevelChangeEvent(entityhuman, i + 1 + oldFoodLevel); - - if (!event.isCancelled()) { - entityhuman.getFoodData().eat(event.getFoodLevel() - oldFoodLevel, 1.0F); - } - - ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutUpdateHealth(((EntityPlayer) entityhuman).getBukkitEntity().getScaledHealth(), entityhuman.getFoodData().foodLevel, entityhuman.getFoodData().saturationLevel)); - // CraftBukkit end - } - } else if ((this.id != HEAL.id || entityliving.aR()) && (this.id != HARM.id || !entityliving.aR())) { - if (this.id == HARM.id && !entityliving.aR() || this.id == HEAL.id && entityliving.aR()) { - entityliving.damageEntity(DamageSource.MAGIC, (float) (6 << i)); - } - } else { - entityliving.heal((float) Math.max(4 << i, 0), RegainReason.MAGIC); // CraftBukkit - } - } - - public void applyInstantEffect(EntityLiving entityliving, EntityLiving entityliving1, int i, double d0) { - // CraftBukkit start - Delegate; we need EntityPotion - applyInstantEffect(entityliving, entityliving1, i, d0, null); - } - - public void applyInstantEffect(EntityLiving entityliving, EntityLiving entityliving1, int i, double d0, EntityPotion potion) { - // CraftBukkit end - int j; - - if ((this.id != HEAL.id || entityliving1.aR()) && (this.id != HARM.id || !entityliving1.aR())) { - if (this.id == HARM.id && !entityliving1.aR() || this.id == HEAL.id && entityliving1.aR()) { - j = (int) (d0 * (double) (6 << i) + 0.5D); - if (entityliving == null) { - entityliving1.damageEntity(DamageSource.MAGIC, (float) j); - } else { - // CraftBukkit - The "damager" needs to be the potion - entityliving1.damageEntity(DamageSource.b(potion != null ? potion : entityliving1, entityliving), (float) j); - } - } - } else { - j = (int) (d0 * (double) (4 << i) + 0.5D); - entityliving1.heal((float) j, RegainReason.MAGIC); // CraftBukkit - } - } - - public boolean isInstant() { - return false; - } - - public boolean a(int i, int j) { - int k; - - if (this.id == REGENERATION.id) { - k = 50 >> j; - return k > 0 ? i % k == 0 : true; - } else if (this.id == POISON.id) { - k = 25 >> j; - return k > 0 ? i % k == 0 : true; - } else if (this.id == WITHER.id) { - k = 40 >> j; - return k > 0 ? i % k == 0 : true; - } else { - return this.id == HUNGER.id; - } - } - - public MobEffectList b(String s) { - this.L = s; - return this; - } - - public String a() { - return this.L; - } - - protected MobEffectList a(double d0) { - this.N = d0; - return this; - } - - public double getDurationModifier() { - return this.N; - } - - public boolean i() { - return this.O; - } - - public int j() { - return this.K; - } - - public MobEffectList a(IAttribute iattribute, String s, double d0, int i) { - AttributeModifier attributemodifier = new AttributeModifier(UUID.fromString(s), this.a(), d0, i); - - this.I.put(iattribute, attributemodifier); - return this; - } - - public void a(EntityLiving entityliving, AttributeMapBase attributemapbase, int i) { - Iterator iterator = this.I.entrySet().iterator(); - - while (iterator.hasNext()) { - Entry entry = (Entry) iterator.next(); - AttributeInstance attributeinstance = attributemapbase.a((IAttribute) entry.getKey()); - - if (attributeinstance != null) { - attributeinstance.b((AttributeModifier) entry.getValue()); - } - } - } - - public void b(EntityLiving entityliving, AttributeMapBase attributemapbase, int i) { - Iterator iterator = this.I.entrySet().iterator(); - - while (iterator.hasNext()) { - Entry entry = (Entry) iterator.next(); - AttributeInstance attributeinstance = attributemapbase.a((IAttribute) entry.getKey()); - - if (attributeinstance != null) { - AttributeModifier attributemodifier = (AttributeModifier) entry.getValue(); - - attributeinstance.b(attributemodifier); - attributeinstance.a(new AttributeModifier(attributemodifier.a(), this.a() + " " + i, this.a(i, attributemodifier), attributemodifier.c())); - } - } - } - - public double a(int i, AttributeModifier attributemodifier) { - return attributemodifier.d() * (double) (i + 1); - } -} diff --git a/src/main/java/net/minecraft/server/MobSpawnerAbstract.java b/src/main/java/net/minecraft/server/MobSpawnerAbstract.java deleted file mode 100644 index 93bb1adc..00000000 --- a/src/main/java/net/minecraft/server/MobSpawnerAbstract.java +++ /dev/null @@ -1,286 +0,0 @@ -package net.minecraft.server; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; - -import org.bukkit.event.entity.CreatureSpawnEvent; // CraftBukkit - -public abstract class MobSpawnerAbstract { - - public int spawnDelay = 20; - private String mobName = "Pig"; - private List mobs; - private TileEntityMobSpawnerData spawnData; - public double c; - public double d; - private int minSpawnDelay = 200; - private int maxSpawnDelay = 800; - private int spawnCount = 4; - private Entity j; - private int maxNearbyEntities = 6; - private int requiredPlayerRange = 16; - private int spawnRange = 4; - - public MobSpawnerAbstract() {} - - public String getMobName() { - if (this.i() == null) { - if (this.mobName.equals("Minecart")) { - this.mobName = "MinecartRideable"; - } - - return this.mobName; - } else { - return this.i().c; - } - } - - public void setMobName(String s) { - this.mobName = s; - } - - public boolean f() { - return this.a().findNearbyPlayer((double) this.b() + 0.5D, (double) this.c() + 0.5D, (double) this.d() + 0.5D, (double) this.requiredPlayerRange) != null; - } - - public void g() { - if (this.f()) { - double d0; - - if (this.a().isStatic) { - double d1 = (double) ((float) this.b() + this.a().random.nextFloat()); - double d2 = (double) ((float) this.c() + this.a().random.nextFloat()); - - d0 = (double) ((float) this.d() + this.a().random.nextFloat()); - this.a().addParticle("smoke", d1, d2, d0, 0.0D, 0.0D, 0.0D); - this.a().addParticle("flame", d1, d2, d0, 0.0D, 0.0D, 0.0D); - if (this.spawnDelay > 0) { - --this.spawnDelay; - } - - this.d = this.c; - this.c = (this.c + (double) (1000.0F / ((float) this.spawnDelay + 200.0F))) % 360.0D; - } else { - if (this.spawnDelay == -1) { - this.j(); - } - - if (this.spawnDelay > 0) { - --this.spawnDelay; - return; - } - - boolean flag = false; - - for (int i = 0; i < this.spawnCount; ++i) { - Entity entity = EntityTypes.createEntityByName(this.getMobName(), this.a()); - - if (entity == null) { - return; - } - - int j = this.a().a(entity.getClass(), AxisAlignedBB.a((double) this.b(), (double) this.c(), (double) this.d(), (double) (this.b() + 1), (double) (this.c() + 1), (double) (this.d() + 1)).grow((double) (this.spawnRange * 2), 4.0D, (double) (this.spawnRange * 2))).size(); - - if (j >= this.maxNearbyEntities) { - this.j(); - return; - } - - d0 = (double) this.b() + (this.a().random.nextDouble() - this.a().random.nextDouble()) * (double) this.spawnRange; - double d3 = (double) (this.c() + this.a().random.nextInt(3) - 1); - double d4 = (double) this.d() + (this.a().random.nextDouble() - this.a().random.nextDouble()) * (double) this.spawnRange; - EntityInsentient entityinsentient = entity instanceof EntityInsentient ? (EntityInsentient) entity : null; - - entity.setPositionRotation(d0, d3, d4, this.a().random.nextFloat() * 360.0F, 0.0F); - if (entityinsentient == null || entityinsentient.canSpawn()) { - this.a(entity); - this.a().triggerEffect(2004, this.b(), this.c(), this.d(), 0); - if (entityinsentient != null) { - entityinsentient.s(); - } - - flag = true; - } - } - - if (flag) { - this.j(); - } - } - } - } - - public Entity a(Entity entity) { - if (this.i() != null) { - NBTTagCompound nbttagcompound = new NBTTagCompound(); - - entity.d(nbttagcompound); - Iterator iterator = this.i().b.c().iterator(); - - while (iterator.hasNext()) { - String s = (String) iterator.next(); - NBTBase nbtbase = this.i().b.get(s); - - nbttagcompound.set(s, nbtbase.clone()); - } - - entity.f(nbttagcompound); - if (entity.world != null) { - entity.world.addEntity(entity, CreatureSpawnEvent.SpawnReason.SPAWNER); // CraftBukkit - } - - NBTTagCompound nbttagcompound1; - - for (Entity entity1 = entity; nbttagcompound.hasKeyOfType("Riding", 10); nbttagcompound = nbttagcompound1) { - nbttagcompound1 = nbttagcompound.getCompound("Riding"); - Entity entity2 = EntityTypes.createEntityByName(nbttagcompound1.getString("id"), entity.world); - - if (entity2 != null) { - NBTTagCompound nbttagcompound2 = new NBTTagCompound(); - - entity2.d(nbttagcompound2); - Iterator iterator1 = nbttagcompound1.c().iterator(); - - while (iterator1.hasNext()) { - String s1 = (String) iterator1.next(); - NBTBase nbtbase1 = nbttagcompound1.get(s1); - - nbttagcompound2.set(s1, nbtbase1.clone()); - } - - entity2.f(nbttagcompound2); - entity2.setPositionRotation(entity1.locX, entity1.locY, entity1.locZ, entity1.yaw, entity1.pitch); - if (entity.world != null) { - entity.world.addEntity(entity2, CreatureSpawnEvent.SpawnReason.SPAWNER); // CraftBukkit - } - - entity1.mount(entity2); - } - - entity1 = entity2; - } - } else if (entity instanceof EntityLiving && entity.world != null) { - ((EntityInsentient) entity).prepare((GroupDataEntity) null); - this.a().addEntity(entity, CreatureSpawnEvent.SpawnReason.SPAWNER); // CraftBukkit - } - - return entity; - } - - private void j() { - if (this.maxSpawnDelay <= this.minSpawnDelay) { - this.spawnDelay = this.minSpawnDelay; - } else { - int i = this.maxSpawnDelay - this.minSpawnDelay; - - this.spawnDelay = this.minSpawnDelay + this.a().random.nextInt(i); - } - - if (this.mobs != null && this.mobs.size() > 0) { - this.a((TileEntityMobSpawnerData) WeightedRandom.a(this.a().random, (Collection) this.mobs)); - } - - this.a(1); - } - - public void a(NBTTagCompound nbttagcompound) { - this.mobName = nbttagcompound.getString("EntityId"); - this.spawnDelay = nbttagcompound.getShort("Delay"); - if (nbttagcompound.hasKeyOfType("SpawnPotentials", 9)) { - this.mobs = new ArrayList(); - NBTTagList nbttaglist = nbttagcompound.getList("SpawnPotentials", 10); - - for (int i = 0; i < nbttaglist.size(); ++i) { - this.mobs.add(new TileEntityMobSpawnerData(this, nbttaglist.get(i))); - } - } else { - this.mobs = null; - } - - if (nbttagcompound.hasKeyOfType("SpawnData", 10)) { - this.a(new TileEntityMobSpawnerData(this, nbttagcompound.getCompound("SpawnData"), this.mobName)); - } else { - this.a((TileEntityMobSpawnerData) null); - } - - if (nbttagcompound.hasKeyOfType("MinSpawnDelay", 99)) { - this.minSpawnDelay = nbttagcompound.getShort("MinSpawnDelay"); - this.maxSpawnDelay = nbttagcompound.getShort("MaxSpawnDelay"); - this.spawnCount = nbttagcompound.getShort("SpawnCount"); - } - - if (nbttagcompound.hasKeyOfType("MaxNearbyEntities", 99)) { - this.maxNearbyEntities = nbttagcompound.getShort("MaxNearbyEntities"); - this.requiredPlayerRange = nbttagcompound.getShort("RequiredPlayerRange"); - } - - if (nbttagcompound.hasKeyOfType("SpawnRange", 99)) { - this.spawnRange = nbttagcompound.getShort("SpawnRange"); - } - - if (this.a() != null && this.a().isStatic) { - this.j = null; - } - } - - public void b(NBTTagCompound nbttagcompound) { - nbttagcompound.setString("EntityId", this.getMobName()); - nbttagcompound.setShort("Delay", (short) this.spawnDelay); - 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.i() != null) { - nbttagcompound.set("SpawnData", this.i().b.clone()); - } - - if (this.i() != null || this.mobs != null && this.mobs.size() > 0) { - NBTTagList nbttaglist = new NBTTagList(); - - if (this.mobs != null && this.mobs.size() > 0) { - Iterator iterator = this.mobs.iterator(); - - while (iterator.hasNext()) { - TileEntityMobSpawnerData tileentitymobspawnerdata = (TileEntityMobSpawnerData) iterator.next(); - - nbttaglist.add(tileentitymobspawnerdata.a()); - } - } else { - nbttaglist.add(this.i().a()); - } - - nbttagcompound.set("SpawnPotentials", nbttaglist); - } - } - - public boolean b(int i) { - if (i == 1 && this.a().isStatic) { - this.spawnDelay = this.minSpawnDelay; - return true; - } else { - return false; - } - } - - public TileEntityMobSpawnerData i() { - return this.spawnData; - } - - public void a(TileEntityMobSpawnerData tileentitymobspawnerdata) { - this.spawnData = tileentitymobspawnerdata; - } - - public abstract void a(int i); - - public abstract World a(); - - public abstract int b(); - - public abstract int c(); - - public abstract int d(); -} diff --git a/src/main/java/net/minecraft/server/NameReferencingFileConverter.java b/src/main/java/net/minecraft/server/NameReferencingFileConverter.java deleted file mode 100644 index ce66cca1..00000000 --- a/src/main/java/net/minecraft/server/NameReferencingFileConverter.java +++ /dev/null @@ -1,402 +0,0 @@ -package net.minecraft.server; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.text.ParseException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.UUID; - -import net.minecraft.util.com.google.common.base.Charsets; -import net.minecraft.util.com.google.common.collect.Iterators; -import net.minecraft.util.com.google.common.collect.Lists; -import net.minecraft.util.com.google.common.collect.Maps; -import net.minecraft.util.com.google.common.io.Files; -import net.minecraft.util.com.mojang.authlib.Agent; -import net.minecraft.util.com.mojang.authlib.GameProfile; -import net.minecraft.util.com.mojang.authlib.ProfileLookupCallback; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -// CraftBukkit - Imported for package private static methods - -public class NameReferencingFileConverter { - - private static final Logger e = LogManager.getLogger(); - public static final File a = new File("banned-ips.txt"); - public static final File b = new File("banned-players.txt"); - public static final File c = new File("ops.txt"); - public static final File d = new File("white-list.txt"); - - static List a(File file1, Map map) throws IOException { // CraftBukkit - Added throws - List list = Files.readLines(file1, Charsets.UTF_8); - Iterator iterator = list.iterator(); - - while (iterator.hasNext()) { - String s = (String) iterator.next(); - - s = s.trim(); - if (!s.startsWith("#") && s.length() >= 1) { - String[] astring = s.split("\\|"); - - map.put(astring[0].toLowerCase(Locale.ROOT), astring); - } - } - - return list; - } - - private static void a(MinecraftServer minecraftserver, Collection collection, ProfileLookupCallback profilelookupcallback) { - String[] astring = (String[]) Iterators.toArray(Iterators.filter(collection.iterator(), new PredicateEmptyList()), String.class); - - if (minecraftserver.getOnlineMode()) { - minecraftserver.getGameProfileRepository().findProfilesByNames(astring, Agent.MINECRAFT, profilelookupcallback); - } else { - String[] astring1 = astring; - int i = astring.length; - - for (int j = 0; j < i; ++j) { - String s = astring1[j]; - UUID uuid = EntityHuman.a(new GameProfile((UUID) null, s)); - GameProfile gameprofile = new GameProfile(uuid, s); - - profilelookupcallback.onProfileLookupSucceeded(gameprofile); - } - } - } - - public static boolean a(MinecraftServer minecraftserver) { - GameProfileBanList gameprofilebanlist = new GameProfileBanList(PlayerList.a); - - if (b.exists() && b.isFile()) { - if (gameprofilebanlist.c().exists()) { - try { - gameprofilebanlist.load(); - // CraftBukkit start - FileNotFoundException -> IOException, don't print stacetrace - } catch (IOException filenotfoundexception) { - e.warn("Could not load existing file " + gameprofilebanlist.c().getName() + ", " + filenotfoundexception.getMessage()); - } - // CraftBukkit end - } - - try { - HashMap hashmap = Maps.newHashMap(); - - a(b, (Map) hashmap); - GameProfileBanListEntryConverter gameprofilebanlistentryconverter = new GameProfileBanListEntryConverter(minecraftserver, hashmap, gameprofilebanlist); - - a(minecraftserver, hashmap.keySet(), gameprofilebanlistentryconverter); - gameprofilebanlist.save(); - c(b); - return true; - } catch (IOException ioexception) { - e.warn("Could not read old user banlist to convert it!", ioexception); - return false; - } catch (FileConversionException fileconversionexception) { - e.error("Conversion failed, please try again later", fileconversionexception); - return false; - } - } else { - return true; - } - } - - public static boolean b(MinecraftServer minecraftserver) { - IpBanList ipbanlist = new IpBanList(PlayerList.b); - - if (a.exists() && a.isFile()) { - if (ipbanlist.c().exists()) { - try { - ipbanlist.load(); - // CraftBukkit start - FileNotFoundException -> IOException, don't print stacetrace - } catch (IOException filenotfoundexception) { - e.warn("Could not load existing file " + ipbanlist.c().getName() + ", " + filenotfoundexception.getMessage()); - } - // CraftBukkit end - } - - try { - HashMap hashmap = Maps.newHashMap(); - - a(a, (Map) hashmap); - Iterator iterator = hashmap.keySet().iterator(); - - while (iterator.hasNext()) { - String s = (String) iterator.next(); - String[] astring = (String[]) hashmap.get(s); - Date date = astring.length > 1 ? b(astring[1], (Date) null) : null; - String s1 = astring.length > 2 ? astring[2] : null; - Date date1 = astring.length > 3 ? b(astring[3], (Date) null) : null; - String s2 = astring.length > 4 ? astring[4] : null; - - ipbanlist.add(new IpBanEntry(s, date, s1, date1, s2)); - } - - ipbanlist.save(); - c(a); - return true; - } catch (IOException ioexception) { - e.warn("Could not parse old ip banlist to convert it!", ioexception); - return false; - } - } else { - return true; - } - } - - public static boolean c(MinecraftServer minecraftserver) { - OpList oplist = new OpList(PlayerList.c); - - if (c.exists() && c.isFile()) { - if (oplist.c().exists()) { - try { - oplist.load(); - // CraftBukkit start - FileNotFoundException -> IOException, don't print stacetrace - } catch (IOException filenotfoundexception) { - e.warn("Could not load existing file " + oplist.c().getName() + ", " + filenotfoundexception.getMessage()); - } - // CraftBukkit end - } - - try { - List list = Files.readLines(c, Charsets.UTF_8); - OpListProfileCallback oplistprofilecallback = new OpListProfileCallback(minecraftserver, oplist); - - a(minecraftserver, list, oplistprofilecallback); - oplist.save(); - c(c); - return true; - } catch (IOException ioexception) { - e.warn("Could not read old oplist to convert it!", ioexception); - return false; - } catch (FileConversionException fileconversionexception) { - e.error("Conversion failed, please try again later", fileconversionexception); - return false; - } - } else { - return true; - } - } - - public static boolean d(MinecraftServer minecraftserver) { - WhiteList whitelist = new WhiteList(PlayerList.d); - - if (d.exists() && d.isFile()) { - if (whitelist.c().exists()) { - try { - whitelist.load(); - // CraftBukkit start - FileNotFoundException -> IOException, don't print stacetrace - } catch (IOException filenotfoundexception) { - e.warn("Could not load existing file " + whitelist.c().getName() + ", " + filenotfoundexception.getMessage()); - } - // CraftBukkit end - } - - try { - List list = Files.readLines(d, Charsets.UTF_8); - WhiteListProfileCallback whitelistprofilecallback = new WhiteListProfileCallback(minecraftserver, whitelist); - - a(minecraftserver, list, whitelistprofilecallback); - whitelist.save(); - c(d); - return true; - } catch (IOException ioexception) { - e.warn("Could not read old whitelist to convert it!", ioexception); - return false; - } catch (FileConversionException fileconversionexception) { - e.error("Conversion failed, please try again later", fileconversionexception); - return false; - } - } else { - return true; - } - } - - public static String a(String s) { - if (!UtilColor.b(s) && s.length() <= 16) { - MinecraftServer minecraftserver = MinecraftServer.getServer(); - GameProfile gameprofile = minecraftserver.getUserCache().getProfile(s); - - if (gameprofile != null && gameprofile.getId() != null) { - return gameprofile.getId().toString(); - } else if (!minecraftserver.N() && minecraftserver.getOnlineMode()) { - ArrayList arraylist = Lists.newArrayList(); - GameProfileLookupCallback gameprofilelookupcallback = new GameProfileLookupCallback(minecraftserver, arraylist); - - a(minecraftserver, Lists.newArrayList(new String[] { s}), gameprofilelookupcallback); - return arraylist.size() > 0 && ((GameProfile) arraylist.get(0)).getId() != null ? ((GameProfile) arraylist.get(0)).getId().toString() : ""; - } else { - return EntityHuman.a(new GameProfile((UUID) null, s)).toString(); - } - } else { - return s; - } - } - - public static boolean a(DedicatedServer dedicatedserver, PropertyManager propertymanager) { - File file1 = d(propertymanager); - File file2 = new File(file1.getParentFile(), "playerdata"); - File file3 = new File(file1.getParentFile(), "unknownplayers"); - - if (file1.exists() && file1.isDirectory()) { - File[] afile = file1.listFiles(); - ArrayList arraylist = Lists.newArrayList(); - File[] afile1 = afile; - int i = afile.length; - - for (int j = 0; j < i; ++j) { - File file4 = afile1[j]; - String s = file4.getName(); - - if (s.toLowerCase(Locale.ROOT).endsWith(".dat")) { - String s1 = s.substring(0, s.length() - ".dat".length()); - - if (s1.length() > 0) { - arraylist.add(s1); - } - } - } - - try { - String[] astring = (String[]) arraylist.toArray(new String[arraylist.size()]); - PlayerDatFileConverter playerdatfileconverter = new PlayerDatFileConverter(dedicatedserver, file2, file3, file1, astring); - - a(dedicatedserver, Lists.newArrayList(astring), playerdatfileconverter); - return true; - } catch (FileConversionException fileconversionexception) { - e.error("Conversion failed, please try again later", fileconversionexception); - return false; - } - } else { - return true; - } - } - - private static void b(File file1) { - if (file1.exists()) { - if (!file1.isDirectory()) { - throw new FileConversionException("Can\'t create directory " + file1.getName() + " in world save directory.", (PredicateEmptyList) null); - } - } else if (!file1.mkdirs()) { - throw new FileConversionException("Can\'t create directory " + file1.getName() + " in world save directory.", (PredicateEmptyList) null); - } - } - - public static boolean a(PropertyManager propertymanager) { - boolean flag = b(propertymanager); - - flag = flag && c(propertymanager); - return flag; - } - - private static boolean b(PropertyManager propertymanager) { - boolean flag = false; - - if (b.exists() && b.isFile()) { - flag = true; - } - - boolean flag1 = false; - - if (a.exists() && a.isFile()) { - flag1 = true; - } - - boolean flag2 = false; - - if (c.exists() && c.isFile()) { - flag2 = true; - } - - boolean flag3 = false; - - if (d.exists() && d.isFile()) { - flag3 = true; - } - - if (!flag && !flag1 && !flag2 && !flag3) { - return true; - } else { - e.warn("**** FAILED TO START THE SERVER AFTER ACCOUNT CONVERSION!"); - e.warn("** please remove the following files and restart the server:"); - if (flag) { - e.warn("* " + b.getName()); - } - - if (flag1) { - e.warn("* " + a.getName()); - } - - if (flag2) { - e.warn("* " + c.getName()); - } - - if (flag3) { - e.warn("* " + d.getName()); - } - - return false; - } - } - - private static boolean c(PropertyManager propertymanager) { - File file1 = d(propertymanager); - - if (file1.exists() && file1.isDirectory()) { - String[] astring = file1.list(new DatFilenameFilter()); - - if (astring.length > 0) { - e.warn("**** DETECTED OLD PLAYER FILES IN THE WORLD SAVE"); - e.warn("**** THIS USUALLY HAPPENS WHEN THE AUTOMATIC CONVERSION FAILED IN SOME WAY"); - e.warn("** please restart the server and if the problem persists, remove the directory \'{}\'", new Object[] { file1.getPath()}); - return false; - } - } - - return true; - } - - private static File d(PropertyManager propertymanager) { - String s = propertymanager.getString("level-name", "world"); - File file1 = new File(MinecraftServer.getServer().server.getWorldContainer(), s); // CraftBukkit - Respect container setting - - return new File(file1, "players"); - } - - private static void c(File file1) { - File file2 = new File(file1.getName() + ".converted"); - - file1.renameTo(file2); - } - - private static Date b(String s, Date date) { - Date date1; - - try { - date1 = ExpirableListEntry.a.parse(s); - } catch (ParseException parseexception) { - date1 = date; - } - - return date1; - } - - static Logger a() { - return e; - } - - static Date a(String s, Date date) { - return b(s, date); - } - - static void a(File file1) { - b(file1); - } -} diff --git a/src/main/java/net/minecraft/server/NetworkManager.java b/src/main/java/net/minecraft/server/NetworkManager.java deleted file mode 100644 index 1b080c77..00000000 --- a/src/main/java/net/minecraft/server/NetworkManager.java +++ /dev/null @@ -1,210 +0,0 @@ -package net.minecraft.server; - -import java.net.SocketAddress; -import java.util.Queue; -import javax.crypto.SecretKey; - -import net.minecraft.util.com.google.common.collect.Queues; -import net.minecraft.util.com.google.common.util.concurrent.ThreadFactoryBuilder; -import net.minecraft.util.io.netty.channel.Channel; -import net.minecraft.util.io.netty.channel.ChannelFutureListener; -import net.minecraft.util.io.netty.channel.ChannelHandlerContext; -import net.minecraft.util.io.netty.channel.SimpleChannelInboundHandler; -import net.minecraft.util.io.netty.channel.local.LocalChannel; -import net.minecraft.util.io.netty.channel.local.LocalServerChannel; -import net.minecraft.util.io.netty.channel.nio.NioEventLoopGroup; -import net.minecraft.util.io.netty.handler.timeout.TimeoutException; -import net.minecraft.util.io.netty.util.AttributeKey; -import net.minecraft.util.io.netty.util.concurrent.GenericFutureListener; -import net.minecraft.util.org.apache.commons.lang3.Validate; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.apache.logging.log4j.Marker; -import org.apache.logging.log4j.MarkerManager; - -public class NetworkManager extends SimpleChannelInboundHandler { - - private static final Logger i = LogManager.getLogger(); - public static final Marker a = MarkerManager.getMarker("NETWORK"); - public static final Marker b = MarkerManager.getMarker("NETWORK_PACKETS", a); - public static final Marker c = MarkerManager.getMarker("NETWORK_STAT", a); - public static final AttributeKey d = new AttributeKey("protocol"); - public static final AttributeKey e = new AttributeKey("receivable_packets"); - public static final AttributeKey f = new AttributeKey("sendable_packets"); - public static final NioEventLoopGroup g = new NioEventLoopGroup(0, (new ThreadFactoryBuilder()).setNameFormat("Netty Client IO #%d").setDaemon(true).build()); - public static final NetworkStatistics h = new NetworkStatistics(); - private final boolean j; - private final Queue k = Queues.newConcurrentLinkedQueue(); - private final Queue l = Queues.newConcurrentLinkedQueue(); - private Channel m; - private SocketAddress n; - private PacketListener o; - private EnumProtocol p; - private IChatBaseComponent q; - private boolean r; - - public NetworkManager(boolean flag) { - this.j = flag; - } - - public void channelActive(ChannelHandlerContext channelhandlercontext) throws Exception { // CraftBukkit - throws Exception - super.channelActive(channelhandlercontext); - this.m = channelhandlercontext.channel(); - this.n = this.m.remoteAddress(); - this.a(EnumProtocol.HANDSHAKING); - } - - public void a(EnumProtocol enumprotocol) { - this.p = (EnumProtocol) this.m.attr(d).getAndSet(enumprotocol); - this.m.attr(e).set(enumprotocol.a(this.j)); - this.m.attr(f).set(enumprotocol.b(this.j)); - this.m.config().setAutoRead(true); - i.debug("Enabled auto read"); - } - - public void channelInactive(ChannelHandlerContext channelhandlercontext) { - this.close(new ChatMessage("disconnect.endOfStream", new Object[0])); - } - - public void exceptionCaught(ChannelHandlerContext channelhandlercontext, Throwable throwable) { - ChatMessage chatmessage; - - if (throwable instanceof TimeoutException) { - chatmessage = new ChatMessage("disconnect.timeout", new Object[0]); - } else { - chatmessage = new ChatMessage("disconnect.genericReason", new Object[] { "Internal Exception: " + throwable}); - } - - this.close(chatmessage); - } - - protected void a(ChannelHandlerContext channelhandlercontext, Packet packet) { - if (this.m.isOpen()) { - if (packet.a()) { - packet.handle(this.o); - } else { - this.k.add(packet); - } - } - } - - public void a(PacketListener packetlistener) { - Validate.notNull(packetlistener, "packetListener", new Object[0]); - i.debug("Set listener of {} to {}", new Object[] { this, packetlistener}); - this.o = packetlistener; - } - - public void handle(Packet packet, GenericFutureListener... agenericfuturelistener) { - if (this.m != null && this.m.isOpen()) { - this.i(); - this.b(packet, agenericfuturelistener); - } else { - this.l.add(new QueuedPacket(packet, agenericfuturelistener)); - } - } - - private void b(Packet packet, GenericFutureListener[] agenericfuturelistener) { - EnumProtocol enumprotocol = EnumProtocol.a(packet); - EnumProtocol enumprotocol1 = (EnumProtocol) this.m.attr(d).get(); - - if (enumprotocol1 != enumprotocol) { - i.debug("Disabled auto read"); - this.m.config().setAutoRead(false); - } - - if (this.m.eventLoop().inEventLoop()) { - if (enumprotocol != enumprotocol1) { - this.a(enumprotocol); - } - - this.m.writeAndFlush(packet).addListeners(agenericfuturelistener).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE); - } else { - this.m.eventLoop().execute(new QueuedProtocolSwitch(this, enumprotocol, enumprotocol1, packet, agenericfuturelistener)); - } - } - - private void i() { - if (this.m != null && this.m.isOpen()) { - while (!this.l.isEmpty()) { - QueuedPacket queuedpacket = (QueuedPacket) this.l.poll(); - - this.b(QueuedPacket.a(queuedpacket), QueuedPacket.b(queuedpacket)); - } - } - } - - public void a() { - this.i(); - EnumProtocol enumprotocol = (EnumProtocol) this.m.attr(d).get(); - - if (this.p != enumprotocol) { - if (this.p != null) { - this.o.a(this.p, enumprotocol); - } - - this.p = enumprotocol; - } - - if (this.o != null) { - for (int i = 1000; !this.k.isEmpty() && i >= 0; --i) { - Packet packet = (Packet) this.k.poll(); - - // CraftBukkit start - if (!this.isConnected() || !this.m.config().isAutoRead()) { - continue; - } - // CraftBukkit end - packet.handle(this.o); - } - - this.o.a(); - } - - this.m.flush(); - } - - public SocketAddress getSocketAddress() { - return this.n; - } - - public void close(IChatBaseComponent ichatbasecomponent) { - if (this.m.isOpen()) { - this.m.close(); - this.q = ichatbasecomponent; - } - } - - public boolean c() { - return this.m instanceof LocalChannel || this.m instanceof LocalServerChannel; - } - - public void a(SecretKey secretkey) { - this.m.pipeline().addBefore("splitter", "decrypt", new PacketDecrypter(MinecraftEncryption.a(2, secretkey))); - this.m.pipeline().addBefore("prepender", "encrypt", new PacketEncrypter(MinecraftEncryption.a(1, secretkey))); - this.r = true; - } - - public boolean isConnected() { - return this.m != null && this.m.isOpen(); - } - - public PacketListener getPacketListener() { - return this.o; - } - - public IChatBaseComponent f() { - return this.q; - } - - public void g() { - this.m.config().setAutoRead(false); - } - - protected void channelRead0(ChannelHandlerContext channelhandlercontext, Object object) { - this.a(channelhandlercontext, (Packet) object); - } - - static Channel a(NetworkManager networkmanager) { - return networkmanager.m; - } -} diff --git a/src/main/java/net/minecraft/server/Packet.java b/src/main/java/net/minecraft/server/Packet.java deleted file mode 100644 index 592ffc58..00000000 --- a/src/main/java/net/minecraft/server/Packet.java +++ /dev/null @@ -1,63 +0,0 @@ -package net.minecraft.server; - -import java.io.IOException; - -import net.minecraft.util.com.google.common.collect.BiMap; -import net.minecraft.util.io.netty.buffer.ByteBuf; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -public abstract class Packet { - - private static final Logger a = LogManager.getLogger(); - public final long timestamp = System.currentTimeMillis(); // CraftBukkit - - public Packet() {} - - public static Packet a(BiMap bimap, int i) { - try { - Class oclass = (Class) bimap.get(Integer.valueOf(i)); - - return oclass == null ? null : (Packet) oclass.newInstance(); - } catch (Exception exception) { - a.error("Couldn\'t create packet " + i, exception); - return null; - } - } - - public static void a(ByteBuf bytebuf, byte[] abyte) { - bytebuf.writeShort(abyte.length); - bytebuf.writeBytes(abyte); - } - - public static byte[] a(ByteBuf bytebuf) throws IOException { // CraftBukkit - added throws - short short1 = bytebuf.readShort(); - - if (short1 < 0) { - throw new IOException("Key was smaller than nothing! Weird key!"); - } else { - byte[] abyte = new byte[short1]; - - bytebuf.readBytes(abyte); - return abyte; - } - } - - public abstract void a(PacketDataSerializer packetdataserializer) throws IOException; // CraftBukkit - added throws - - public abstract void b(PacketDataSerializer packetdataserializer) throws IOException; // CraftBukkit - added throws - - public abstract void handle(PacketListener packetlistener); - - public boolean a() { - return false; - } - - public String toString() { - return this.getClass().getSimpleName(); - } - - public String b() { - return ""; - } -} diff --git a/src/main/java/net/minecraft/server/PacketDataSerializer.java b/src/main/java/net/minecraft/server/PacketDataSerializer.java deleted file mode 100644 index 8d3cf1f9..00000000 --- a/src/main/java/net/minecraft/server/PacketDataSerializer.java +++ /dev/null @@ -1,726 +0,0 @@ -package net.minecraft.server; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.nio.ByteBuffer; -import java.nio.ByteOrder; -import java.nio.channels.GatheringByteChannel; -import java.nio.channels.ScatteringByteChannel; -import java.nio.charset.Charset; - -import net.minecraft.util.com.google.common.base.Charsets; -import net.minecraft.util.io.netty.buffer.ByteBuf; -import net.minecraft.util.io.netty.buffer.ByteBufAllocator; -import net.minecraft.util.io.netty.buffer.ByteBufProcessor; - -import org.bukkit.craftbukkit.inventory.CraftItemStack; // CraftBukkit - -public class PacketDataSerializer extends ByteBuf { - - private final ByteBuf a; - - public PacketDataSerializer(ByteBuf bytebuf) { - this.a = bytebuf; - } - - public static int a(int i) { - return (i & -128) == 0 ? 1 : ((i & -16384) == 0 ? 2 : ((i & -2097152) == 0 ? 3 : ((i & -268435456) == 0 ? 4 : 5))); - } - - public int a() { - int i = 0; - int j = 0; - - byte b0; - - do { - b0 = this.readByte(); - i |= (b0 & 127) << j++ * 7; - if (j > 5) { - throw new RuntimeException("VarInt too big"); - } - } while ((b0 & 128) == 128); - - return i; - } - - public void b(int i) { - while ((i & -128) != 0) { - this.writeByte(i & 127 | 128); - i >>>= 7; - } - - this.writeByte(i); - } - - public void a(NBTTagCompound nbttagcompound) { - if (nbttagcompound == null) { - this.writeShort(-1); - } else { - byte[] abyte = NBTCompressedStreamTools.a(nbttagcompound); - - this.writeShort((short) abyte.length); - this.writeBytes(abyte); - } - } - - public NBTTagCompound b() { - short short1 = this.readShort(); - - if (short1 < 0) { - return null; - } else { - byte[] abyte = new byte[short1]; - - this.readBytes(abyte); - return NBTCompressedStreamTools.a(abyte, new NBTReadLimiter(2097152L)); - } - } - - public void a(ItemStack itemstack) { - if (itemstack == null || itemstack.getItem() == null) { // CraftBukkit - NPE fix itemstack.getItem() - this.writeShort(-1); - } else { - this.writeShort(Item.getId(itemstack.getItem())); - this.writeByte(itemstack.count); - this.writeShort(itemstack.getData()); - NBTTagCompound nbttagcompound = null; - - if (itemstack.getItem().usesDurability() || itemstack.getItem().s()) { - nbttagcompound = itemstack.tag; - } - - this.a(nbttagcompound); - } - } - - public ItemStack c() { - ItemStack itemstack = null; - short short1 = this.readShort(); - - if (short1 >= 0) { - byte b0 = this.readByte(); - short short2 = this.readShort(); - - itemstack = new ItemStack(Item.getById(short1), b0, short2); - itemstack.tag = this.b(); - // CraftBukkit start - if (itemstack.tag != null) { - CraftItemStack.setItemMeta(itemstack, CraftItemStack.getItemMeta(itemstack)); - } - // CraftBukkit end - } - - return itemstack; - } - - public String c(int i) throws IOException { // CraftBukkit - throws IOException - int j = this.a(); - - if (j > i * 4) { - throw new IOException("The received encoded string buffer length is longer than maximum allowed (" + j + " > " + i * 4 + ")"); - } else if (j < 0) { - throw new IOException("The received encoded string buffer length is less than zero! Weird string!"); - } else { - String s = new String(this.readBytes(j).array(), Charsets.UTF_8); - - if (s.length() > i) { - throw new IOException("The received string length is longer than maximum allowed (" + j + " > " + i + ")"); - } else { - return s; - } - } - } - - public void a(String s) throws IOException { // CraftBukkit - throws IOException - byte[] abyte = s.getBytes(Charsets.UTF_8); - - if (abyte.length > 32767) { - throw new IOException("String too big (was " + s.length() + " bytes encoded, max " + 32767 + ")"); - } else { - this.b(abyte.length); - this.writeBytes(abyte); - } - } - - public int capacity() { - return this.a.capacity(); - } - - public ByteBuf capacity(int i) { - return this.a.capacity(i); - } - - public int maxCapacity() { - return this.a.maxCapacity(); - } - - public ByteBufAllocator alloc() { - return this.a.alloc(); - } - - public ByteOrder order() { - return this.a.order(); - } - - public ByteBuf order(ByteOrder byteorder) { - return this.a.order(byteorder); - } - - public ByteBuf unwrap() { - return this.a.unwrap(); - } - - public boolean isDirect() { - return this.a.isDirect(); - } - - public int readerIndex() { - return this.a.readerIndex(); - } - - public ByteBuf readerIndex(int i) { - return this.a.readerIndex(i); - } - - public int writerIndex() { - return this.a.writerIndex(); - } - - public ByteBuf writerIndex(int i) { - return this.a.writerIndex(i); - } - - public ByteBuf setIndex(int i, int j) { - return this.a.setIndex(i, j); - } - - public int readableBytes() { - return this.a.readableBytes(); - } - - public int writableBytes() { - return this.a.writableBytes(); - } - - public int maxWritableBytes() { - return this.a.maxWritableBytes(); - } - - public boolean isReadable() { - return this.a.isReadable(); - } - - public boolean isReadable(int i) { - return this.a.isReadable(i); - } - - public boolean isWritable() { - return this.a.isWritable(); - } - - public boolean isWritable(int i) { - return this.a.isWritable(i); - } - - public ByteBuf clear() { - return this.a.clear(); - } - - public ByteBuf markReaderIndex() { - return this.a.markReaderIndex(); - } - - public ByteBuf resetReaderIndex() { - return this.a.resetReaderIndex(); - } - - public ByteBuf markWriterIndex() { - return this.a.markWriterIndex(); - } - - public ByteBuf resetWriterIndex() { - return this.a.resetWriterIndex(); - } - - public ByteBuf discardReadBytes() { - return this.a.discardReadBytes(); - } - - public ByteBuf discardSomeReadBytes() { - return this.a.discardSomeReadBytes(); - } - - public ByteBuf ensureWritable(int i) { - return this.a.ensureWritable(i); - } - - public int ensureWritable(int i, boolean flag) { - return this.a.ensureWritable(i, flag); - } - - public boolean getBoolean(int i) { - return this.a.getBoolean(i); - } - - public byte getByte(int i) { - return this.a.getByte(i); - } - - public short getUnsignedByte(int i) { - return this.a.getUnsignedByte(i); - } - - public short getShort(int i) { - return this.a.getShort(i); - } - - public int getUnsignedShort(int i) { - return this.a.getUnsignedShort(i); - } - - public int getMedium(int i) { - return this.a.getMedium(i); - } - - public int getUnsignedMedium(int i) { - return this.a.getUnsignedMedium(i); - } - - public int getInt(int i) { - return this.a.getInt(i); - } - - public long getUnsignedInt(int i) { - return this.a.getUnsignedInt(i); - } - - public long getLong(int i) { - return this.a.getLong(i); - } - - public char getChar(int i) { - return this.a.getChar(i); - } - - public float getFloat(int i) { - return this.a.getFloat(i); - } - - public double getDouble(int i) { - return this.a.getDouble(i); - } - - public ByteBuf getBytes(int i, ByteBuf bytebuf) { - return this.a.getBytes(i, bytebuf); - } - - public ByteBuf getBytes(int i, ByteBuf bytebuf, int j) { - return this.a.getBytes(i, bytebuf, j); - } - - public ByteBuf getBytes(int i, ByteBuf bytebuf, int j, int k) { - return this.a.getBytes(i, bytebuf, j, k); - } - - public ByteBuf getBytes(int i, byte[] abyte) { - return this.a.getBytes(i, abyte); - } - - public ByteBuf getBytes(int i, byte[] abyte, int j, int k) { - return this.a.getBytes(i, abyte, j, k); - } - - public ByteBuf getBytes(int i, ByteBuffer bytebuffer) { - return this.a.getBytes(i, bytebuffer); - } - - public ByteBuf getBytes(int i, OutputStream outputstream, int j) throws IOException { // CraftBukkit - throws IOException - return this.a.getBytes(i, outputstream, j); - } - - public int getBytes(int i, GatheringByteChannel gatheringbytechannel, int j) throws IOException { // CraftBukkit - throws IOException - return this.a.getBytes(i, gatheringbytechannel, j); - } - - public ByteBuf setBoolean(int i, boolean flag) { - return this.a.setBoolean(i, flag); - } - - public ByteBuf setByte(int i, int j) { - return this.a.setByte(i, j); - } - - public ByteBuf setShort(int i, int j) { - return this.a.setShort(i, j); - } - - public ByteBuf setMedium(int i, int j) { - return this.a.setMedium(i, j); - } - - public ByteBuf setInt(int i, int j) { - return this.a.setInt(i, j); - } - - public ByteBuf setLong(int i, long j) { - return this.a.setLong(i, j); - } - - public ByteBuf setChar(int i, int j) { - return this.a.setChar(i, j); - } - - public ByteBuf setFloat(int i, float f) { - return this.a.setFloat(i, f); - } - - public ByteBuf setDouble(int i, double d0) { - return this.a.setDouble(i, d0); - } - - public ByteBuf setBytes(int i, ByteBuf bytebuf) { - return this.a.setBytes(i, bytebuf); - } - - public ByteBuf setBytes(int i, ByteBuf bytebuf, int j) { - return this.a.setBytes(i, bytebuf, j); - } - - public ByteBuf setBytes(int i, ByteBuf bytebuf, int j, int k) { - return this.a.setBytes(i, bytebuf, j, k); - } - - public ByteBuf setBytes(int i, byte[] abyte) { - return this.a.setBytes(i, abyte); - } - - public ByteBuf setBytes(int i, byte[] abyte, int j, int k) { - return this.a.setBytes(i, abyte, j, k); - } - - public ByteBuf setBytes(int i, ByteBuffer bytebuffer) { - return this.a.setBytes(i, bytebuffer); - } - - public int setBytes(int i, InputStream inputstream, int j) throws IOException { // CraftBukkit - throws IOException - return this.a.setBytes(i, inputstream, j); - } - - public int setBytes(int i, ScatteringByteChannel scatteringbytechannel, int j) throws IOException { // CraftBukkit - throws IOException - return this.a.setBytes(i, scatteringbytechannel, j); - } - - public ByteBuf setZero(int i, int j) { - return this.a.setZero(i, j); - } - - public boolean readBoolean() { - return this.a.readBoolean(); - } - - public byte readByte() { - return this.a.readByte(); - } - - public short readUnsignedByte() { - return this.a.readUnsignedByte(); - } - - public short readShort() { - return this.a.readShort(); - } - - public int readUnsignedShort() { - return this.a.readUnsignedShort(); - } - - public int readMedium() { - return this.a.readMedium(); - } - - public int readUnsignedMedium() { - return this.a.readUnsignedMedium(); - } - - public int readInt() { - return this.a.readInt(); - } - - public long readUnsignedInt() { - return this.a.readUnsignedInt(); - } - - public long readLong() { - return this.a.readLong(); - } - - public char readChar() { - return this.a.readChar(); - } - - public float readFloat() { - return this.a.readFloat(); - } - - public double readDouble() { - return this.a.readDouble(); - } - - public ByteBuf readBytes(int i) { - return this.a.readBytes(i); - } - - public ByteBuf readSlice(int i) { - return this.a.readSlice(i); - } - - public ByteBuf readBytes(ByteBuf bytebuf) { - return this.a.readBytes(bytebuf); - } - - public ByteBuf readBytes(ByteBuf bytebuf, int i) { - return this.a.readBytes(bytebuf, i); - } - - public ByteBuf readBytes(ByteBuf bytebuf, int i, int j) { - return this.a.readBytes(bytebuf, i, j); - } - - public ByteBuf readBytes(byte[] abyte) { - return this.a.readBytes(abyte); - } - - public ByteBuf readBytes(byte[] abyte, int i, int j) { - return this.a.readBytes(abyte, i, j); - } - - public ByteBuf readBytes(ByteBuffer bytebuffer) { - return this.a.readBytes(bytebuffer); - } - - public ByteBuf readBytes(OutputStream outputstream, int i) throws IOException { // CraftBukkit - throws IOException - return this.a.readBytes(outputstream, i); - } - - public int readBytes(GatheringByteChannel gatheringbytechannel, int i) throws IOException { // CraftBukkit - throws IOException - return this.a.readBytes(gatheringbytechannel, i); - } - - public ByteBuf skipBytes(int i) { - return this.a.skipBytes(i); - } - - public ByteBuf writeBoolean(boolean flag) { - return this.a.writeBoolean(flag); - } - - public ByteBuf writeByte(int i) { - return this.a.writeByte(i); - } - - public ByteBuf writeShort(int i) { - return this.a.writeShort(i); - } - - public ByteBuf writeMedium(int i) { - return this.a.writeMedium(i); - } - - public ByteBuf writeInt(int i) { - return this.a.writeInt(i); - } - - public ByteBuf writeLong(long i) { - return this.a.writeLong(i); - } - - public ByteBuf writeChar(int i) { - return this.a.writeChar(i); - } - - public ByteBuf writeFloat(float f) { - return this.a.writeFloat(f); - } - - public ByteBuf writeDouble(double d0) { - return this.a.writeDouble(d0); - } - - public ByteBuf writeBytes(ByteBuf bytebuf) { - return this.a.writeBytes(bytebuf); - } - - public ByteBuf writeBytes(ByteBuf bytebuf, int i) { - return this.a.writeBytes(bytebuf, i); - } - - public ByteBuf writeBytes(ByteBuf bytebuf, int i, int j) { - return this.a.writeBytes(bytebuf, i, j); - } - - public ByteBuf writeBytes(byte[] abyte) { - return this.a.writeBytes(abyte); - } - - public ByteBuf writeBytes(byte[] abyte, int i, int j) { - return this.a.writeBytes(abyte, i, j); - } - - public ByteBuf writeBytes(ByteBuffer bytebuffer) { - return this.a.writeBytes(bytebuffer); - } - - public int writeBytes(InputStream inputstream, int i) throws IOException { // CraftBukkit - throws IOException - return this.a.writeBytes(inputstream, i); - } - - public int writeBytes(ScatteringByteChannel scatteringbytechannel, int i) throws IOException { // CraftBukkit - throws IOException - return this.a.writeBytes(scatteringbytechannel, i); - } - - public ByteBuf writeZero(int i) { - return this.a.writeZero(i); - } - - public int indexOf(int i, int j, byte b0) { - return this.a.indexOf(i, j, b0); - } - - public int bytesBefore(byte b0) { - return this.a.bytesBefore(b0); - } - - public int bytesBefore(int i, byte b0) { - return this.a.bytesBefore(i, b0); - } - - public int bytesBefore(int i, int j, byte b0) { - return this.a.bytesBefore(i, j, b0); - } - - public int forEachByte(ByteBufProcessor bytebufprocessor) { - return this.a.forEachByte(bytebufprocessor); - } - - public int forEachByte(int i, int j, ByteBufProcessor bytebufprocessor) { - return this.a.forEachByte(i, j, bytebufprocessor); - } - - public int forEachByteDesc(ByteBufProcessor bytebufprocessor) { - return this.a.forEachByteDesc(bytebufprocessor); - } - - public int forEachByteDesc(int i, int j, ByteBufProcessor bytebufprocessor) { - return this.a.forEachByteDesc(i, j, bytebufprocessor); - } - - public ByteBuf copy() { - return this.a.copy(); - } - - public ByteBuf copy(int i, int j) { - return this.a.copy(i, j); - } - - public ByteBuf slice() { - return this.a.slice(); - } - - public ByteBuf slice(int i, int j) { - return this.a.slice(i, j); - } - - public ByteBuf duplicate() { - return this.a.duplicate(); - } - - public int nioBufferCount() { - return this.a.nioBufferCount(); - } - - public ByteBuffer nioBuffer() { - return this.a.nioBuffer(); - } - - public ByteBuffer nioBuffer(int i, int j) { - return this.a.nioBuffer(i, j); - } - - public ByteBuffer internalNioBuffer(int i, int j) { - return this.a.internalNioBuffer(i, j); - } - - public ByteBuffer[] nioBuffers() { - return this.a.nioBuffers(); - } - - public ByteBuffer[] nioBuffers(int i, int j) { - return this.a.nioBuffers(i, j); - } - - public boolean hasArray() { - return this.a.hasArray(); - } - - public byte[] array() { - return this.a.array(); - } - - public int arrayOffset() { - return this.a.arrayOffset(); - } - - public boolean hasMemoryAddress() { - return this.a.hasMemoryAddress(); - } - - public long memoryAddress() { - return this.a.memoryAddress(); - } - - public String toString(Charset charset) { - return this.a.toString(charset); - } - - public String toString(int i, int j, Charset charset) { - return this.a.toString(i, j, charset); - } - - public int hashCode() { - return this.a.hashCode(); - } - - public boolean equals(Object object) { - return this.a.equals(object); - } - - public int compareTo(ByteBuf bytebuf) { - return this.a.compareTo(bytebuf); - } - - public String toString() { - return this.a.toString(); - } - - public ByteBuf retain(int i) { - return this.a.retain(i); - } - - public ByteBuf retain() { - return this.a.retain(); - } - - public int refCnt() { - return this.a.refCnt(); - } - - public boolean release() { - return this.a.release(); - } - - public boolean release(int i) { - return this.a.release(i); - } -} diff --git a/src/main/java/net/minecraft/server/PacketHandshakingInSetProtocol.java b/src/main/java/net/minecraft/server/PacketHandshakingInSetProtocol.java deleted file mode 100644 index 16d47650..00000000 --- a/src/main/java/net/minecraft/server/PacketHandshakingInSetProtocol.java +++ /dev/null @@ -1,47 +0,0 @@ -package net.minecraft.server; - -import java.io.IOException; // CraftBukkit - -public class PacketHandshakingInSetProtocol extends Packet { - - private int a; - public String b; // CraftBukkit private -> public - public int c; // CraftBukkit private -> public - private EnumProtocol d; - - public PacketHandshakingInSetProtocol() {} - - public void a(PacketDataSerializer packetdataserializer) throws IOException { // CraftBukkit - added throws - this.a = packetdataserializer.a(); - this.b = packetdataserializer.c(255); - this.c = packetdataserializer.readUnsignedShort(); - this.d = EnumProtocol.a(packetdataserializer.a()); - } - - public void b(PacketDataSerializer packetdataserializer) throws IOException { // CraftBukkit - added throws - packetdataserializer.b(this.a); - packetdataserializer.a(this.b); - packetdataserializer.writeShort(this.c); - packetdataserializer.b(this.d.c()); - } - - public void a(PacketHandshakingInListener packethandshakinginlistener) { - packethandshakinginlistener.a(this); - } - - public boolean a() { - return true; - } - - public EnumProtocol c() { - return this.d; - } - - public int d() { - return this.a; - } - - public void handle(PacketListener packetlistener) { - this.a((PacketHandshakingInListener) packetlistener); - } -} diff --git a/src/main/java/net/minecraft/server/PacketPlayInChat.java b/src/main/java/net/minecraft/server/PacketPlayInChat.java deleted file mode 100644 index 604a7af5..00000000 --- a/src/main/java/net/minecraft/server/PacketPlayInChat.java +++ /dev/null @@ -1,49 +0,0 @@ -package net.minecraft.server; - -import java.io.IOException; // CraftBukkit - -public class PacketPlayInChat extends Packet { - - private String message; - - public PacketPlayInChat() {} - - public PacketPlayInChat(String s) { - if (s.length() > 100) { - s = s.substring(0, 100); - } - - this.message = s; - } - - public void a(PacketDataSerializer packetdataserializer) throws IOException { // CraftBukkit - added throws - this.message = packetdataserializer.c(100); - } - - public void b(PacketDataSerializer packetdataserializer) throws IOException { // CraftBukkit - added throws - packetdataserializer.a(this.message); - } - - public void a(PacketPlayInListener packetplayinlistener) { - packetplayinlistener.a(this); - } - - public String b() { - return String.format("message=\'%s\'", new Object[] { this.message}); - } - - public String c() { - return this.message; - } - - // CraftBukkit start - make chat async - @Override - public boolean a() { - return !this.message.startsWith("/"); - } - // CraftBukkit end - - public void handle(PacketListener packetlistener) { - this.a((PacketPlayInListener) packetlistener); - } -} diff --git a/src/main/java/net/minecraft/server/PacketPlayInCloseWindow.java b/src/main/java/net/minecraft/server/PacketPlayInCloseWindow.java deleted file mode 100644 index 43df03a9..00000000 --- a/src/main/java/net/minecraft/server/PacketPlayInCloseWindow.java +++ /dev/null @@ -1,29 +0,0 @@ -package net.minecraft.server; - -public class PacketPlayInCloseWindow extends Packet { - - private int a; - - public PacketPlayInCloseWindow() {} - - // CraftBukkit start - Add constructor - public PacketPlayInCloseWindow(int id) { - this.a = id; - } - // CraftBukkit end - public void a(PacketPlayInListener packetplayinlistener) { - packetplayinlistener.a(this); - } - - public void a(PacketDataSerializer packetdataserializer) { - this.a = packetdataserializer.readByte(); - } - - public void b(PacketDataSerializer packetdataserializer) { - packetdataserializer.writeByte(this.a); - } - - public void handle(PacketListener packetlistener) { - this.a((PacketPlayInListener) packetlistener); - } -} diff --git a/src/main/java/net/minecraft/server/PacketPlayInCustomPayload.java b/src/main/java/net/minecraft/server/PacketPlayInCustomPayload.java deleted file mode 100644 index 5df99a44..00000000 --- a/src/main/java/net/minecraft/server/PacketPlayInCustomPayload.java +++ /dev/null @@ -1,45 +0,0 @@ -package net.minecraft.server; - -import java.io.IOException; // CraftBukkit - -public class PacketPlayInCustomPayload extends Packet { - - private String tag; - public int length; // CraftBukkit - private -> public - private byte[] data; - - public PacketPlayInCustomPayload() {} - - public void a(PacketDataSerializer packetdataserializer) throws IOException { // CraftBukkit - added throws - this.tag = packetdataserializer.c(20); - this.length = packetdataserializer.readShort(); - if (this.length > 0 && this.length < 32767) { - this.data = new byte[this.length]; - packetdataserializer.readBytes(this.data); - } - } - - public void b(PacketDataSerializer packetdataserializer) throws IOException { // CraftBukkit - added throws - packetdataserializer.a(this.tag); - packetdataserializer.writeShort((short) this.length); - if (this.data != null) { - packetdataserializer.writeBytes(this.data); - } - } - - public void a(PacketPlayInListener packetplayinlistener) { - packetplayinlistener.a(this); - } - - public String c() { - return this.tag; - } - - public byte[] e() { - return this.data; - } - - public void handle(PacketListener packetlistener) { - this.a((PacketPlayInListener) packetlistener); - } -} diff --git a/src/main/java/net/minecraft/server/PacketPlayOutBlockChange.java b/src/main/java/net/minecraft/server/PacketPlayOutBlockChange.java deleted file mode 100644 index 4c622e26..00000000 --- a/src/main/java/net/minecraft/server/PacketPlayOutBlockChange.java +++ /dev/null @@ -1,48 +0,0 @@ -package net.minecraft.server; - -public class PacketPlayOutBlockChange extends Packet { - - private int a; - private int b; - private int c; - public Block block; // CraftBukkit - public - public int data; // CraftBukkit - public - - public PacketPlayOutBlockChange() {} - - public PacketPlayOutBlockChange(int i, int j, int k, World world) { - this.a = i; - this.b = j; - this.c = k; - this.block = world.getType(i, j, k); - this.data = world.getData(i, j, k); - } - - public void a(PacketDataSerializer packetdataserializer) { - this.a = packetdataserializer.readInt(); - this.b = packetdataserializer.readUnsignedByte(); - this.c = packetdataserializer.readInt(); - this.block = Block.getById(packetdataserializer.a()); - this.data = packetdataserializer.readUnsignedByte(); - } - - public void b(PacketDataSerializer packetdataserializer) { - packetdataserializer.writeInt(this.a); - packetdataserializer.writeByte(this.b); - packetdataserializer.writeInt(this.c); - packetdataserializer.b(Block.getId(this.block)); - packetdataserializer.writeByte(this.data); - } - - public void a(PacketPlayOutListener packetplayoutlistener) { - packetplayoutlistener.a(this); - } - - public String b() { - return String.format("type=%d, data=%d, x=%d, y=%d, z=%d", new Object[] { Integer.valueOf(Block.getId(this.block)), Integer.valueOf(this.data), Integer.valueOf(this.a), Integer.valueOf(this.b), Integer.valueOf(this.c)}); - } - - public void handle(PacketListener packetlistener) { - this.a((PacketPlayOutListener) packetlistener); - } -} diff --git a/src/main/java/net/minecraft/server/PacketPlayOutMapChunkBulk.java b/src/main/java/net/minecraft/server/PacketPlayOutMapChunkBulk.java deleted file mode 100644 index 3eac231d..00000000 --- a/src/main/java/net/minecraft/server/PacketPlayOutMapChunkBulk.java +++ /dev/null @@ -1,190 +0,0 @@ -package net.minecraft.server; - -import java.io.IOException; -import java.util.List; -import java.util.zip.DataFormatException; -import java.util.zip.Deflater; -import java.util.zip.Inflater; - -public class PacketPlayOutMapChunkBulk extends Packet { - - private int[] a; - private int[] b; - private int[] c; - private int[] d; - private byte[] buffer; - private byte[][] inflatedBuffers; - private int size; - private boolean h; - private byte[] buildBuffer = new byte[0]; // CraftBukkit - remove static - // CraftBukkit start - static final ThreadLocal<Deflater> localDeflater = new ThreadLocal<Deflater>() { - @Override - protected Deflater initialValue() { - // Don't use higher compression level, slows things down too much - return new Deflater(6); - } - }; - // CraftBukkit end - - public PacketPlayOutMapChunkBulk() {} - - public PacketPlayOutMapChunkBulk(List list) { - int i = list.size(); - - this.a = new int[i]; - this.b = new int[i]; - this.c = new int[i]; - this.d = new int[i]; - this.inflatedBuffers = new byte[i][]; - this.h = !list.isEmpty() && !((Chunk) list.get(0)).world.worldProvider.g; - int j = 0; - - for (int k = 0; k < i; ++k) { - Chunk chunk = (Chunk) list.get(k); - ChunkMap chunkmap = PacketPlayOutMapChunk.a(chunk, true, '\uffff'); - - if (buildBuffer.length < j + chunkmap.a.length) { - byte[] abyte = new byte[j + chunkmap.a.length]; - - System.arraycopy(buildBuffer, 0, abyte, 0, buildBuffer.length); - buildBuffer = abyte; - } - - System.arraycopy(chunkmap.a, 0, buildBuffer, j, chunkmap.a.length); - j += chunkmap.a.length; - this.a[k] = chunk.locX; - this.b[k] = chunk.locZ; - this.c[k] = chunkmap.b; - this.d[k] = chunkmap.c; - this.inflatedBuffers[k] = chunkmap.a; - } - - /* CraftBukkit start - Moved to compress() - Deflater deflater = new Deflater(-1); - - try { - deflater.setInput(buildBuffer, 0, j); - deflater.finish(); - this.buffer = new byte[j]; - this.size = deflater.deflate(this.buffer); - } finally { - deflater.end(); - } - */ - } - - // Add compression method - public void compress() { - if (this.buffer != null) { - return; - } - - Deflater deflater = localDeflater.get(); - deflater.reset(); - deflater.setInput(this.buildBuffer); - deflater.finish(); - - this.buffer = new byte[this.buildBuffer.length + 100]; - this.size = deflater.deflate(this.buffer); - } - // CraftBukkit end - - public static int c() { - return 5; - } - - public void a(PacketDataSerializer packetdataserializer) throws IOException { // CraftBukkit - throws IOException - short short1 = packetdataserializer.readShort(); - - this.size = packetdataserializer.readInt(); - this.h = packetdataserializer.readBoolean(); - this.a = new int[short1]; - this.b = new int[short1]; - this.c = new int[short1]; - this.d = new int[short1]; - this.inflatedBuffers = new byte[short1][]; - if (buildBuffer.length < this.size) { - buildBuffer = new byte[this.size]; - } - - packetdataserializer.readBytes(buildBuffer, 0, this.size); - byte[] abyte = new byte[PacketPlayOutMapChunk.c() * short1]; - Inflater inflater = new Inflater(); - - inflater.setInput(buildBuffer, 0, this.size); - - try { - inflater.inflate(abyte); - } catch (DataFormatException dataformatexception) { - throw new IOException("Bad compressed data format"); - } finally { - inflater.end(); - } - - int i = 0; - - for (int j = 0; j < short1; ++j) { - this.a[j] = packetdataserializer.readInt(); - this.b[j] = packetdataserializer.readInt(); - this.c[j] = packetdataserializer.readShort(); - this.d[j] = packetdataserializer.readShort(); - int k = 0; - int l = 0; - - int i1; - - for (i1 = 0; i1 < 16; ++i1) { - k += this.c[j] >> i1 & 1; - l += this.d[j] >> i1 & 1; - } - - i1 = 2048 * 4 * k + 256; - i1 += 2048 * l; - if (this.h) { - i1 += 2048 * k; - } - - this.inflatedBuffers[j] = new byte[i1]; - System.arraycopy(abyte, i, this.inflatedBuffers[j], 0, i1); - i += i1; - } - } - - public void b(PacketDataSerializer packetdataserializer) throws IOException { // CraftBukkit - throws IOException - compress(); // CraftBukkit - packetdataserializer.writeShort(this.a.length); - packetdataserializer.writeInt(this.size); - packetdataserializer.writeBoolean(this.h); - packetdataserializer.writeBytes(this.buffer, 0, this.size); - - for (int i = 0; i < this.a.length; ++i) { - packetdataserializer.writeInt(this.a[i]); - packetdataserializer.writeInt(this.b[i]); - packetdataserializer.writeShort((short) (this.c[i] & '\uffff')); - packetdataserializer.writeShort((short) (this.d[i] & '\uffff')); - } - } - - public void a(PacketPlayOutListener packetplayoutlistener) { - packetplayoutlistener.a(this); - } - - public String b() { - StringBuilder stringbuilder = new StringBuilder(); - - for (int i = 0; i < this.a.length; ++i) { - if (i > 0) { - stringbuilder.append(", "); - } - - stringbuilder.append(String.format("{x=%d, z=%d, sections=%d, adds=%d, data=%d}", new Object[] { Integer.valueOf(this.a[i]), Integer.valueOf(this.b[i]), Integer.valueOf(this.c[i]), Integer.valueOf(this.d[i]), Integer.valueOf(this.inflatedBuffers[i].length)})); - } - - return String.format("size=%d, chunks=%d[%s]", new Object[] { Integer.valueOf(this.size), Integer.valueOf(this.a.length), stringbuilder}); - } - - public void handle(PacketListener packetlistener) { - this.a((PacketPlayOutListener) packetlistener); - } -} diff --git a/src/main/java/net/minecraft/server/PacketPlayOutNamedEntitySpawn.java b/src/main/java/net/minecraft/server/PacketPlayOutNamedEntitySpawn.java deleted file mode 100644 index 0023f18d..00000000 --- a/src/main/java/net/minecraft/server/PacketPlayOutNamedEntitySpawn.java +++ /dev/null @@ -1,102 +0,0 @@ -package net.minecraft.server; - -import java.util.Iterator; -import java.util.List; -import java.util.UUID; - -import net.minecraft.util.com.mojang.authlib.GameProfile; -import net.minecraft.util.com.mojang.authlib.properties.Property; - -import java.io.IOException; // CraftBukkit - -public class PacketPlayOutNamedEntitySpawn extends Packet { - - private int a; - private GameProfile b; - private int c; - private int d; - private int e; - private byte f; - private byte g; - private int h; - private DataWatcher i; - private List j; - - public PacketPlayOutNamedEntitySpawn() {} - - public PacketPlayOutNamedEntitySpawn(EntityHuman entityhuman) { - this.a = entityhuman.getId(); - this.b = entityhuman.getProfile(); - this.c = MathHelper.floor(entityhuman.locX * 32.0D); - this.d = MathHelper.floor(entityhuman.locY * 32.0D); - this.e = MathHelper.floor(entityhuman.locZ * 32.0D); - this.f = (byte) ((int) (entityhuman.yaw * 256.0F / 360.0F)); - this.g = (byte) ((int) (entityhuman.pitch * 256.0F / 360.0F)); - ItemStack itemstack = entityhuman.inventory.getItemInHand(); - - this.h = itemstack == null ? 0 : Item.getId(itemstack.getItem()); - this.i = entityhuman.getDataWatcher(); - } - - public void a(PacketDataSerializer packetdataserializer) throws IOException { // CraftBukkit - added throws - this.a = packetdataserializer.a(); - UUID uuid = UUID.fromString(packetdataserializer.c(36)); - - this.b = new GameProfile(uuid, packetdataserializer.c(16)); - int i = packetdataserializer.a(); - - for (int j = 0; j < i; ++j) { - String s = packetdataserializer.c(32767); - String s1 = packetdataserializer.c(32767); - String s2 = packetdataserializer.c(32767); - - this.b.getProperties().put(s, new Property(s, s1, s2)); - } - - this.c = packetdataserializer.readInt(); - this.d = packetdataserializer.readInt(); - this.e = packetdataserializer.readInt(); - this.f = packetdataserializer.readByte(); - this.g = packetdataserializer.readByte(); - this.h = packetdataserializer.readShort(); - this.j = DataWatcher.b(packetdataserializer); - } - - public void b(PacketDataSerializer packetdataserializer) throws IOException { // CraftBukkit - added throws - packetdataserializer.b(this.a); - UUID uuid = this.b.getId(); - - packetdataserializer.a(uuid == null ? "" : uuid.toString()); - packetdataserializer.a(this.b.getName().length() > 16 ? this.b.getName().substring(0, 16) : this.b.getName()); // CraftBukkit - Limit name length to 16 characters - packetdataserializer.b(this.b.getProperties().size()); - Iterator iterator = this.b.getProperties().values().iterator(); - - while (iterator.hasNext()) { - Property property = (Property) iterator.next(); - - packetdataserializer.a(property.getName()); - packetdataserializer.a(property.getValue()); - packetdataserializer.a(property.getSignature()); - } - - packetdataserializer.writeInt(this.c); - packetdataserializer.writeInt(this.d); - packetdataserializer.writeInt(this.e); - packetdataserializer.writeByte(this.f); - packetdataserializer.writeByte(this.g); - packetdataserializer.writeShort(this.h); - this.i.a(packetdataserializer); - } - - public void a(PacketPlayOutListener packetplayoutlistener) { - packetplayoutlistener.a(this); - } - - public String b() { - return String.format("id=%d, gameProfile=\'%s\', x=%.2f, y=%.2f, z=%.2f, carried=%d", new Object[] { Integer.valueOf(this.a), this.b, Float.valueOf((float) this.c / 32.0F), Float.valueOf((float) this.d / 32.0F), Float.valueOf((float) this.e / 32.0F), Integer.valueOf(this.h)}); - } - - public void handle(PacketListener packetlistener) { - this.a((PacketPlayOutListener) packetlistener); - } -} diff --git a/src/main/java/net/minecraft/server/PacketPlayOutSpawnPosition.java b/src/main/java/net/minecraft/server/PacketPlayOutSpawnPosition.java deleted file mode 100644 index 92e40367..00000000 --- a/src/main/java/net/minecraft/server/PacketPlayOutSpawnPosition.java +++ /dev/null @@ -1,44 +0,0 @@ -package net.minecraft.server; - -public class PacketPlayOutSpawnPosition extends Packet { - - public int x; // CraftBukkit - private -> public - public int y; // CraftBukkit - private -> public - public int z; // CraftBukkit - private -> public - - public PacketPlayOutSpawnPosition() {} - - public PacketPlayOutSpawnPosition(int i, int j, int k) { - this.x = i; - this.y = j; - this.z = k; - } - - public void a(PacketDataSerializer packetdataserializer) { - this.x = packetdataserializer.readInt(); - this.y = packetdataserializer.readInt(); - this.z = packetdataserializer.readInt(); - } - - public void b(PacketDataSerializer packetdataserializer) { - packetdataserializer.writeInt(this.x); - packetdataserializer.writeInt(this.y); - packetdataserializer.writeInt(this.z); - } - - public void a(PacketPlayOutListener packetplayoutlistener) { - packetplayoutlistener.a(this); - } - - public boolean a() { - return false; - } - - public String b() { - return String.format("x=%d, y=%d, z=%d", new Object[] { Integer.valueOf(this.x), Integer.valueOf(this.y), Integer.valueOf(this.z)}); - } - - public void handle(PacketListener packetlistener) { - this.a((PacketPlayOutListener) packetlistener); - } -} diff --git a/src/main/java/net/minecraft/server/PacketStatusListener.java b/src/main/java/net/minecraft/server/PacketStatusListener.java deleted file mode 100644 index cd063053..00000000 --- a/src/main/java/net/minecraft/server/PacketStatusListener.java +++ /dev/null @@ -1,128 +0,0 @@ -package net.minecraft.server; - -import java.net.InetSocketAddress; - -// CraftBukkit start -import java.util.Iterator; - -import org.bukkit.craftbukkit.util.CraftIconCache; -import org.bukkit.entity.Player; - -import net.minecraft.util.com.mojang.authlib.GameProfile; -// CraftBukkit end - -import net.minecraft.util.io.netty.util.concurrent.GenericFutureListener; - -public class PacketStatusListener implements PacketStatusInListener { - - private final MinecraftServer minecraftServer; - private final NetworkManager networkManager; - - public PacketStatusListener(MinecraftServer minecraftserver, NetworkManager networkmanager) { - this.minecraftServer = minecraftserver; - this.networkManager = networkmanager; - } - - public void a(IChatBaseComponent ichatbasecomponent) {} - - public void a(EnumProtocol enumprotocol, EnumProtocol enumprotocol1) { - if (enumprotocol1 != EnumProtocol.STATUS) { - throw new UnsupportedOperationException("Unexpected change in protocol to " + enumprotocol1); - } - } - - public void a() {} - - public void a(PacketStatusInStart packetstatusinstart) { - // CraftBukkit start - fire ping event - final Object[] players = minecraftServer.getPlayerList().players.toArray(); - class ServerListPingEvent extends org.bukkit.event.server.ServerListPingEvent { - CraftIconCache icon = minecraftServer.server.getServerIcon(); - - ServerListPingEvent() { - super(((InetSocketAddress) networkManager.getSocketAddress()).getAddress(), minecraftServer.getMotd(), minecraftServer.getPlayerList().getMaxPlayers()); - } - - @Override - public void setServerIcon(org.bukkit.util.CachedServerIcon icon) { - if (!(icon instanceof CraftIconCache)) { - throw new IllegalArgumentException(icon + " was not created by " + org.bukkit.craftbukkit.CraftServer.class); - } - this.icon = (CraftIconCache) icon; - } - - @Override - public Iterator<Player> iterator() throws UnsupportedOperationException { - return new Iterator<Player>() { - int i; - int ret = Integer.MIN_VALUE; - EntityPlayer player; - - @Override - public boolean hasNext() { - if (player != null) { - return true; - } - final Object[] currentPlayers = players; - for (int length = currentPlayers.length, i = this.i; i < length; i++) { - final EntityPlayer player = (EntityPlayer) currentPlayers[i]; - if (player != null) { - this.i = i + 1; - this.player = player; - return true; - } - } - return false; - } - - @Override - public Player next() { - if (!hasNext()) { - throw new java.util.NoSuchElementException(); - } - final EntityPlayer player = this.player; - this.player = null; - this.ret = this.i - 1; - return player.getBukkitEntity(); - } - - @Override - public void remove() { - final Object[] currentPlayers = players; - final int i = this.ret; - if (i < 0 || currentPlayers[i] == null) { - throw new IllegalStateException(); - } - currentPlayers[i] = null; - } - }; - } - } - - ServerListPingEvent event = new ServerListPingEvent(); - this.minecraftServer.server.getPluginManager().callEvent(event); - - java.util.List<GameProfile> profiles = new java.util.ArrayList<GameProfile>(players.length); - for (Object player : players) { - if (player != null) { - profiles.add(((EntityPlayer) player).getProfile()); - } - } - - ServerPingPlayerSample playerSample = new ServerPingPlayerSample(event.getMaxPlayers(), profiles.size()); - playerSample.a(profiles.toArray(new GameProfile[profiles.size()])); - - ServerPing ping = new ServerPing(); - ping.setFavicon(event.icon.value); - ping.setMOTD(new ChatComponentText(event.getMotd())); - ping.setPlayerSample(playerSample); - ping.setServerInfo(new ServerPingServerData(minecraftServer.getServerModName() + " " + minecraftServer.getVersion(), 5)); // TODO: Update when protocol changes - - this.networkManager.handle(new PacketStatusOutServerInfo(ping), new GenericFutureListener[0]); - // CraftBukkit end - } - - public void a(PacketStatusInPing packetstatusinping) { - this.networkManager.handle(new PacketStatusOutPong(packetstatusinping.c()), new GenericFutureListener[0]); - } -} diff --git a/src/main/java/net/minecraft/server/Path.java b/src/main/java/net/minecraft/server/Path.java deleted file mode 100644 index 90c3ef97..00000000 --- a/src/main/java/net/minecraft/server/Path.java +++ /dev/null @@ -1,128 +0,0 @@ -package net.minecraft.server; - -public class Path { - - private PathPoint[] a = new PathPoint[128]; // CraftBukkit - reduce default size - private int b; - - public Path() {} - - public PathPoint a(PathPoint pathpoint) { - if (pathpoint.d >= 0) { - throw new IllegalStateException("OW KNOWS!"); - } else { - if (this.b == this.a.length) { - PathPoint[] apathpoint = new PathPoint[this.b << 1]; - - System.arraycopy(this.a, 0, apathpoint, 0, this.b); - this.a = apathpoint; - } - - this.a[this.b] = pathpoint; - pathpoint.d = this.b; - this.a(this.b++); - return pathpoint; - } - } - - public void a() { - this.b = 0; - } - - public PathPoint c() { - PathPoint pathpoint = this.a[0]; - - this.a[0] = this.a[--this.b]; - this.a[this.b] = null; - if (this.b > 0) { - this.b(0); - } - - pathpoint.d = -1; - return pathpoint; - } - - public void a(PathPoint pathpoint, float f) { - float f1 = pathpoint.g; - - pathpoint.g = f; - if (f < f1) { - this.a(pathpoint.d); - } else { - this.b(pathpoint.d); - } - } - - private void a(int i) { - PathPoint pathpoint = this.a[i]; - - int j; - - for (float f = pathpoint.g; i > 0; i = j) { - j = i - 1 >> 1; - PathPoint pathpoint1 = this.a[j]; - - if (f >= pathpoint1.g) { - break; - } - - this.a[i] = pathpoint1; - pathpoint1.d = i; - } - - this.a[i] = pathpoint; - pathpoint.d = i; - } - - private void b(int i) { - PathPoint pathpoint = this.a[i]; - float f = pathpoint.g; - - while (true) { - int j = 1 + (i << 1); - int k = j + 1; - - if (j >= this.b) { - break; - } - - PathPoint pathpoint1 = this.a[j]; - float f1 = pathpoint1.g; - PathPoint pathpoint2; - float f2; - - if (k >= this.b) { - pathpoint2 = null; - f2 = Float.POSITIVE_INFINITY; - } else { - pathpoint2 = this.a[k]; - f2 = pathpoint2.g; - } - - if (f1 < f2) { - if (f1 >= f) { - break; - } - - this.a[i] = pathpoint1; - pathpoint1.d = i; - i = j; - } else { - if (f2 >= f) { - break; - } - - this.a[i] = pathpoint2; - pathpoint2.d = i; - i = k; - } - } - - this.a[i] = pathpoint; - pathpoint.d = i; - } - - public boolean e() { - return this.b == 0; - } -} diff --git a/src/main/java/net/minecraft/server/PathfinderGoalArrowAttack.java b/src/main/java/net/minecraft/server/PathfinderGoalArrowAttack.java deleted file mode 100644 index cb2af02f..00000000 --- a/src/main/java/net/minecraft/server/PathfinderGoalArrowAttack.java +++ /dev/null @@ -1,105 +0,0 @@ -package net.minecraft.server; - -import org.bukkit.event.entity.EntityTargetEvent; // CraftBukkit - -public class PathfinderGoalArrowAttack extends PathfinderGoal { - - private final EntityInsentient a; - private final IRangedEntity b; - private EntityLiving c; - private int d; - private double e; - private int f; - private int g; - private int h; - private float i; - private float j; - - public PathfinderGoalArrowAttack(IRangedEntity irangedentity, double d0, int i, float f) { - this(irangedentity, d0, i, i, f); - } - - public PathfinderGoalArrowAttack(IRangedEntity irangedentity, double d0, int i, int j, float f) { - this.d = -1; - if (!(irangedentity instanceof EntityLiving)) { - throw new IllegalArgumentException("ArrowAttackGoal requires Mob implements RangedAttackMob"); - } else { - this.b = irangedentity; - this.a = (EntityInsentient) irangedentity; - this.e = d0; - this.g = i; - this.h = j; - this.i = f; - this.j = f * f; - this.a(3); - } - } - - public boolean a() { - EntityLiving entityliving = this.a.getGoalTarget(); - - if (entityliving == null) { - return false; - } else { - this.c = entityliving; - return true; - } - } - - public boolean b() { - return this.a() || !this.a.getNavigation().g(); - } - - 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((Entity) b, null, reason); - // CraftBukkit end - this.c = null; - this.f = 0; - this.d = -1; - } - - public void e() { - double d0 = this.a.e(this.c.locX, this.c.boundingBox.b, this.c.locZ); - boolean flag = this.a.getEntitySenses().canSee(this.c); - - if (flag) { - ++this.f; - } else { - this.f = 0; - } - - if (d0 <= (double) this.j && this.f >= 20) { - this.a.getNavigation().h(); - } else { - this.a.getNavigation().a((Entity) this.c, this.e); - } - - this.a.getControllerLook().a(this.c, 30.0F, 30.0F); - float f; - - if (--this.d == 0) { - if (d0 > (double) this.j || !flag) { - return; - } - - f = MathHelper.sqrt(d0) / this.i; - float f1 = f; - - if (f < 0.1F) { - f1 = 0.1F; - } - - if (f1 > 1.0F) { - f1 = 1.0F; - } - - this.b.a(this.c, f1); - this.d = MathHelper.d(f * (float) (this.h - this.g) + (float) this.g); - } else if (this.d < 0) { - f = MathHelper.sqrt(d0) / this.i; - this.d = MathHelper.d(f * (float) (this.h - this.g) + (float) this.g); - } - } -} diff --git a/src/main/java/net/minecraft/server/PathfinderGoalBreakDoor.java b/src/main/java/net/minecraft/server/PathfinderGoalBreakDoor.java deleted file mode 100644 index 727f5f0c..00000000 --- a/src/main/java/net/minecraft/server/PathfinderGoalBreakDoor.java +++ /dev/null @@ -1,59 +0,0 @@ -package net.minecraft.server; - -public class PathfinderGoalBreakDoor extends PathfinderGoalDoorInteract { - - private int i; - private int j = -1; - - public PathfinderGoalBreakDoor(EntityInsentient entityinsentient) { - super(entityinsentient); - } - - public boolean a() { - return !super.a() ? false : (!this.a.world.getGameRules().getBoolean("mobGriefing") ? false : !this.e.f((IBlockAccess) this.a.world, this.b, this.c, this.d)); // CraftBukkit - Fix decompilation issue by casting world to IBlockAccess - } - - public void c() { - super.c(); - this.i = 0; - } - - public boolean b() { - double d0 = this.a.e((double) this.b, (double) this.c, (double) this.d); - - return this.i <= 240 && !this.e.f((IBlockAccess) this.a.world, this.b, this.c, this.d) && d0 < 4.0D; // CraftBukkit - Fix decompilation issue by casting world to IBlockAccess - } - - public void d() { - super.d(); - this.a.world.d(this.a.getId(), this.b, this.c, this.d, -1); - } - - public void e() { - super.e(); - if (this.a.aI().nextInt(20) == 0) { - this.a.world.triggerEffect(1010, this.b, this.c, this.d, 0); - } - - ++this.i; - int i = (int) ((float) this.i / 240.0F * 10.0F); - - if (i != this.j) { - this.a.world.d(this.a.getId(), this.b, this.c, this.d, i); - this.j = i; - } - - if (this.i == 240 && this.a.world.difficulty == EnumDifficulty.HARD) { - // CraftBukkit start - if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityBreakDoorEvent(this.a, this.b, this.c, this.d).isCancelled()) { - this.c(); - return; - } - // CraftBukkit end - - this.a.world.setAir(this.b, this.c, this.d); - this.a.world.triggerEffect(1012, this.b, this.c, this.d, 0); - this.a.world.triggerEffect(2001, this.b, this.c, this.d, Block.getId(this.e)); - } - } -} diff --git a/src/main/java/net/minecraft/server/PathfinderGoalBreed.java b/src/main/java/net/minecraft/server/PathfinderGoalBreed.java deleted file mode 100644 index 65f86908..00000000 --- a/src/main/java/net/minecraft/server/PathfinderGoalBreed.java +++ /dev/null @@ -1,112 +0,0 @@ -package net.minecraft.server; - -import java.util.Iterator; -import java.util.List; -import java.util.Random; - -public class PathfinderGoalBreed extends PathfinderGoal { - - private EntityAnimal d; - World a; - private EntityAnimal e; - int b; - double c; - - public PathfinderGoalBreed(EntityAnimal entityanimal, double d0) { - this.d = entityanimal; - this.a = entityanimal.world; - this.c = d0; - this.a(3); - } - - public boolean a() { - if (!this.d.ce()) { - return false; - } else { - this.e = this.f(); - return this.e != null; - } - } - - public boolean b() { - return this.e.isAlive() && this.e.ce() && this.b < 60; - } - - public void d() { - this.e = null; - this.b = 0; - } - - public void e() { - this.d.getControllerLook().a(this.e, 10.0F, (float) this.d.x()); - this.d.getNavigation().a((Entity) this.e, this.c); - ++this.b; - if (this.b >= 60 && this.d.f(this.e) < 9.0D) { - this.g(); - } - } - - private EntityAnimal f() { - float f = 8.0F; - List list = this.a.a(this.d.getClass(), this.d.boundingBox.grow((double) f, (double) f, (double) f)); - double d0 = Double.MAX_VALUE; - EntityAnimal entityanimal = null; - Iterator iterator = list.iterator(); - - while (iterator.hasNext()) { - EntityAnimal entityanimal1 = (EntityAnimal) iterator.next(); - - if (this.d.mate(entityanimal1) && this.d.f(entityanimal1) < d0) { - entityanimal = entityanimal1; - d0 = this.d.f(entityanimal1); - } - } - - return entityanimal; - } - - private void g() { - EntityAgeable entityageable = this.d.createChild(this.e); - - if (entityageable != null) { - // CraftBukkit start - set persistence for tame animals - if (entityageable instanceof EntityTameableAnimal && ((EntityTameableAnimal) entityageable).isTamed()) { - entityageable.persistent = true; - } - // CraftBukkit end - EntityHuman entityhuman = this.d.cd(); - - if (entityhuman == null && this.e.cd() != null) { - entityhuman = this.e.cd(); - } - - if (entityhuman != null) { - entityhuman.a(StatisticList.x); - if (this.d instanceof EntityCow) { - entityhuman.a((Statistic) AchievementList.H); - } - } - - this.d.setAge(6000); - this.e.setAge(6000); - this.d.cf(); - this.e.cf(); - entityageable.setAge(-24000); - entityageable.setPositionRotation(this.d.locX, this.d.locY, this.d.locZ, 0.0F, 0.0F); - this.a.addEntity(entityageable, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - added SpawnReason - Random random = this.d.aI(); - - 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.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); - } - - if (this.a.getGameRules().getBoolean("doMobLoot")) { - this.a.addEntity(new EntityExperienceOrb(this.a, this.d.locX, this.d.locY, this.d.locZ, random.nextInt(7) + 1)); - } - } - } -} diff --git a/src/main/java/net/minecraft/server/PathfinderGoalEatTile.java b/src/main/java/net/minecraft/server/PathfinderGoalEatTile.java deleted file mode 100644 index a38f2a26..00000000 --- a/src/main/java/net/minecraft/server/PathfinderGoalEatTile.java +++ /dev/null @@ -1,75 +0,0 @@ -package net.minecraft.server; - -// CraftBukkit start -import org.bukkit.craftbukkit.event.CraftEventFactory; -import org.bukkit.Material; -// CraftBukkit end - -public class PathfinderGoalEatTile extends PathfinderGoal { - - private EntityInsentient b; - private World c; - int a; - - public PathfinderGoalEatTile(EntityInsentient entityinsentient) { - this.b = entityinsentient; - this.c = entityinsentient.world; - this.a(7); - } - - public boolean a() { - if (this.b.aI().nextInt(this.b.isBaby() ? 50 : 1000) != 0) { - return false; - } else { - int i = MathHelper.floor(this.b.locX); - int j = MathHelper.floor(this.b.locY); - int k = MathHelper.floor(this.b.locZ); - - return this.c.getType(i, j, k) == Blocks.LONG_GRASS && this.c.getData(i, j, k) == 1 ? true : this.c.getType(i, j - 1, k) == Blocks.GRASS; - } - } - - public void c() { - this.a = 40; - this.c.broadcastEntityEffect(this.b, (byte) 10); - this.b.getNavigation().h(); - } - - public void d() { - this.a = 0; - } - - public boolean b() { - return this.a > 0; - } - - public int f() { - return this.a; - } - - public void e() { - this.a = Math.max(0, this.a - 1); - if (this.a == 4) { - int i = MathHelper.floor(this.b.locX); - int j = MathHelper.floor(this.b.locY); - int k = MathHelper.floor(this.b.locZ); - - if (this.c.getType(i, j, k) == Blocks.LONG_GRASS) { - // CraftBukkit - if (!CraftEventFactory.callEntityChangeBlockEvent(this.b, this.b.world.getWorld().getBlockAt(i, j, k), Material.AIR, !this.c.getGameRules().getBoolean("mobGriefing")).isCancelled()) { - this.c.setAir(i, j, k, false); - } - - this.b.p(); - } else if (this.c.getType(i, j - 1, k) == Blocks.GRASS) { - // CraftBukkit - if (!CraftEventFactory.callEntityChangeBlockEvent(this.b, this.b.world.getWorld().getBlockAt(i, j - 1, k), Material.DIRT, !this.c.getGameRules().getBoolean("mobGriefing")).isCancelled()) { - this.c.triggerEffect(2001, i, j - 1, k, Block.getId(Blocks.GRASS)); - this.c.setTypeAndData(i, j - 1, k, Blocks.DIRT, 0, 2); - } - - this.b.p(); - } - } - } -} diff --git a/src/main/java/net/minecraft/server/PathfinderGoalHurtByTarget.java b/src/main/java/net/minecraft/server/PathfinderGoalHurtByTarget.java deleted file mode 100644 index 4f476e6f..00000000 --- a/src/main/java/net/minecraft/server/PathfinderGoalHurtByTarget.java +++ /dev/null @@ -1,48 +0,0 @@ -package net.minecraft.server; - -import java.util.Iterator; -import java.util.List; - -public class PathfinderGoalHurtByTarget extends PathfinderGoalTarget { - - boolean a; - private int b; - - public PathfinderGoalHurtByTarget(EntityCreature entitycreature, boolean flag) { - super(entitycreature, false); - this.a = flag; - this.a(1); - } - - public boolean a() { - int i = this.c.aK(); - - return i != this.b && this.a(this.c.getLastDamager(), false); - } - - public void c() { - this.c.setGoalTarget(this.c.getLastDamager()); - this.b = this.c.aK(); - if (this.a) { - double d0 = this.f(); - List list = this.c.world.a(this.c.getClass(), AxisAlignedBB.a(this.c.locX, this.c.locY, this.c.locZ, this.c.locX + 1.0D, this.c.locY + 1.0D, this.c.locZ + 1.0D).grow(d0, 10.0D, d0)); - Iterator iterator = list.iterator(); - - while (iterator.hasNext()) { - EntityCreature entitycreature = (EntityCreature) iterator.next(); - - if (this.c != entitycreature && entitycreature.getGoalTarget() == null && !entitycreature.c(this.c.getLastDamager())) { - // CraftBukkit start - call EntityTargetEvent - org.bukkit.event.entity.EntityTargetLivingEntityEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTargetLivingEvent(entitycreature, this.c.getLastDamager(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_NEARBY_ENTITY); - if (event.isCancelled()) { - continue; - } - entitycreature.setGoalTarget(event.getTarget() == null ? null : ((org.bukkit.craftbukkit.entity.CraftLivingEntity) event.getTarget()).getHandle()); - // CraftBukkit end - } - } - } - - super.c(); - } -} diff --git a/src/main/java/net/minecraft/server/PathfinderGoalMakeLove.java b/src/main/java/net/minecraft/server/PathfinderGoalMakeLove.java deleted file mode 100644 index f7bd8e82..00000000 --- a/src/main/java/net/minecraft/server/PathfinderGoalMakeLove.java +++ /dev/null @@ -1,90 +0,0 @@ -package net.minecraft.server; - -public class PathfinderGoalMakeLove extends PathfinderGoal { - - private EntityVillager b; - private EntityVillager c; - private World d; - private int e; - Village a; - - public PathfinderGoalMakeLove(EntityVillager entityvillager) { - this.b = entityvillager; - this.d = entityvillager.world; - this.a(3); - } - - public boolean a() { - if (this.b.getAge() != 0) { - return false; - } else if (this.b.aI().nextInt(500) != 0) { - return false; - } else { - this.a = this.d.villages.getClosestVillage(MathHelper.floor(this.b.locX), MathHelper.floor(this.b.locY), MathHelper.floor(this.b.locZ), 0); - if (this.a == null) { - return false; - } else if (!this.f()) { - return false; - } else { - Entity entity = this.d.a(EntityVillager.class, this.b.boundingBox.grow(8.0D, 3.0D, 8.0D), (Entity) this.b); - - if (entity == null) { - return false; - } else { - this.c = (EntityVillager) entity; - return this.c.getAge() == 0; - } - } - } - } - - public void c() { - this.e = 300; - this.b.i(true); - } - - public void d() { - this.a = null; - this.c = null; - this.b.i(false); - } - - public boolean b() { - return this.e >= 0 && this.f() && this.b.getAge() == 0; - } - - public void e() { - --this.e; - this.b.getControllerLook().a(this.c, 10.0F, 30.0F); - if (this.b.f(this.c) > 2.25D) { - this.b.getNavigation().a((Entity) this.c, 0.25D); - } else if (this.e == 0 && this.c.ca()) { - this.g(); - } - - if (this.b.aI().nextInt(35) == 0) { - this.d.broadcastEntityEffect(this.b, (byte) 12); - } - } - - private boolean f() { - if (!this.a.i()) { - return false; - } else { - int i = (int) ((double) ((float) this.a.getDoorCount()) * 0.35D); - - return this.a.getPopulationCount() < i; - } - } - - private void g() { - EntityVillager entityvillager = this.b.b((EntityAgeable) this.c); - - this.c.setAge(6000); - this.b.setAge(6000); - entityvillager.setAge(-24000); - entityvillager.setPositionRotation(this.b.locX, this.b.locY, this.b.locZ, 0.0F, 0.0F); - this.d.addEntity(entityvillager, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - added SpawnReason - this.d.broadcastEntityEffect(entityvillager, (byte) 12); - } -} diff --git a/src/main/java/net/minecraft/server/PathfinderGoalMeleeAttack.java b/src/main/java/net/minecraft/server/PathfinderGoalMeleeAttack.java deleted file mode 100644 index be541f81..00000000 --- a/src/main/java/net/minecraft/server/PathfinderGoalMeleeAttack.java +++ /dev/null @@ -1,103 +0,0 @@ -package net.minecraft.server; - -import org.bukkit.event.entity.EntityTargetEvent; // CraftBukkit - -public class PathfinderGoalMeleeAttack extends PathfinderGoal { - - World a; - EntityCreature b; - int c; - double d; - boolean e; - PathEntity f; - Class g; - private int h; - private double i; - private double j; - private double k; - - public PathfinderGoalMeleeAttack(EntityCreature entitycreature, Class oclass, double d0, boolean flag) { - this(entitycreature, d0, flag); - this.g = oclass; - } - - public PathfinderGoalMeleeAttack(EntityCreature entitycreature, double d0, boolean flag) { - this.b = entitycreature; - this.a = entitycreature.world; - this.d = d0; - this.e = flag; - this.a(3); - } - - public boolean a() { - EntityLiving entityliving = this.b.getGoalTarget(); - - if (entityliving == null) { - return false; - } else if (!entityliving.isAlive()) { - return false; - } else if (this.g != null && !this.g.isAssignableFrom(entityliving.getClass())) { - return false; - } else { - this.f = this.b.getNavigation().a(entityliving); - return this.f != null; - } - } - - public boolean b() { - EntityLiving entityliving = this.b.getGoalTarget(); - - // CraftBukkit start - EntityTargetEvent.TargetReason reason = this.b.getGoalTarget() == null ? EntityTargetEvent.TargetReason.FORGOT_TARGET : EntityTargetEvent.TargetReason.TARGET_DIED; - if (this.b.getGoalTarget() == null || (this.b.getGoalTarget() != null && !this.b.getGoalTarget().isAlive())) { - org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTargetEvent(b, null, reason); - } - // CraftBukkit end - - return entityliving == null ? false : (!entityliving.isAlive() ? false : (!this.e ? !this.b.getNavigation().g() : this.b.b(MathHelper.floor(entityliving.locX), MathHelper.floor(entityliving.locY), MathHelper.floor(entityliving.locZ)))); - } - - public void c() { - this.b.getNavigation().a(this.f, this.d); - this.h = 0; - } - - public void d() { - this.b.getNavigation().h(); - } - - public void e() { - EntityLiving entityliving = this.b.getGoalTarget(); - - this.b.getControllerLook().a(entityliving, 30.0F, 30.0F); - double d0 = this.b.e(entityliving.locX, entityliving.boundingBox.b, entityliving.locZ); - double d1 = (double) (this.b.width * 2.0F * this.b.width * 2.0F + entityliving.width); - - --this.h; - if ((this.e || this.b.getEntitySenses().canSee(entityliving)) && this.h <= 0 && (this.i == 0.0D && this.j == 0.0D && this.k == 0.0D || entityliving.e(this.i, this.j, this.k) >= 1.0D || this.b.aI().nextFloat() < 0.05F)) { - this.i = entityliving.locX; - this.j = entityliving.boundingBox.b; - this.k = entityliving.locZ; - this.h = 4 + this.b.aI().nextInt(7); - if (d0 > 1024.0D) { - this.h += 10; - } else if (d0 > 256.0D) { - this.h += 5; - } - - if (!this.b.getNavigation().a((Entity) entityliving, this.d)) { - this.h += 15; - } - } - - this.c = Math.max(this.c - 1, 0); - if (d0 <= d1 && this.c <= 20) { - this.c = 20; - if (this.b.be() != null) { - this.b.ba(); - } - - this.b.n(entityliving); - } - } -} diff --git a/src/main/java/net/minecraft/server/PathfinderGoalOcelotAttack.java b/src/main/java/net/minecraft/server/PathfinderGoalOcelotAttack.java deleted file mode 100644 index 0c08df38..00000000 --- a/src/main/java/net/minecraft/server/PathfinderGoalOcelotAttack.java +++ /dev/null @@ -1,63 +0,0 @@ -package net.minecraft.server; - -import org.bukkit.event.entity.EntityTargetEvent; // CraftBukkit - -public class PathfinderGoalOcelotAttack extends PathfinderGoal { - - World a; - EntityInsentient b; - EntityLiving c; - int d; - - public PathfinderGoalOcelotAttack(EntityInsentient entityinsentient) { - this.b = entityinsentient; - this.a = entityinsentient.world; - this.a(3); - } - - public boolean a() { - EntityLiving entityliving = this.b.getGoalTarget(); - - if (entityliving == null) { - return false; - } else { - this.c = entityliving; - return true; - } - } - - public boolean b() { - return !this.c.isAlive() ? false : (this.b.f(this.c) > 225.0D ? false : !this.b.getNavigation().g() || this.a()); - } - - 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(this.c, null, reason); - // CraftBukkit end - this.c = null; - this.b.getNavigation().h(); - } - - public void e() { - this.b.getControllerLook().a(this.c, 30.0F, 30.0F); - double d0 = (double) (this.b.width * 2.0F * this.b.width * 2.0F); - double d1 = this.b.e(this.c.locX, this.c.boundingBox.b, this.c.locZ); - double d2 = 0.8D; - - if (d1 > d0 && d1 < 16.0D) { - d2 = 1.33D; - } else if (d1 < 225.0D) { - d2 = 0.6D; - } - - this.b.getNavigation().a((Entity) this.c, d2); - this.d = Math.max(this.d - 1, 0); - if (d1 <= d0) { - if (this.d <= 0) { - this.d = 20; - this.b.n(this.c); - } - } - } -} diff --git a/src/main/java/net/minecraft/server/PathfinderGoalPanic.java b/src/main/java/net/minecraft/server/PathfinderGoalPanic.java deleted file mode 100644 index 1b8608d0..00000000 --- a/src/main/java/net/minecraft/server/PathfinderGoalPanic.java +++ /dev/null @@ -1,47 +0,0 @@ -package net.minecraft.server; - -public class PathfinderGoalPanic extends PathfinderGoal { - - private EntityCreature a; - private double b; - private double c; - private double d; - private double e; - - public PathfinderGoalPanic(EntityCreature entitycreature, double d0) { - this.a = entitycreature; - this.b = d0; - this.a(1); - } - - public boolean a() { - if (this.a.getLastDamager() == null && !this.a.isBurning()) { - return false; - } else { - Vec3D vec3d = RandomPositionGenerator.a(this.a, 5, 4); - - if (vec3d == null) { - return false; - } else { - this.c = vec3d.a; - this.d = vec3d.b; - this.e = vec3d.c; - return true; - } - } - } - - public void c() { - this.a.getNavigation().a(this.c, this.d, this.e, this.b); - } - - public boolean b() { - // CraftBukkit start - introduce a temporary timeout hack until this is fixed properly - if ((this.a.ticksLived - this.a.aK()) > 100) { - this.a.b((EntityLiving) null); - return false; - } - // CraftBukkit end - return !this.a.getNavigation().g(); - } -} diff --git a/src/main/java/net/minecraft/server/PathfinderGoalSelector.java b/src/main/java/net/minecraft/server/PathfinderGoalSelector.java deleted file mode 100644 index 33aded08..00000000 --- a/src/main/java/net/minecraft/server/PathfinderGoalSelector.java +++ /dev/null @@ -1,153 +0,0 @@ -package net.minecraft.server; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import org.bukkit.craftbukkit.util.UnsafeList; // CraftBukkit - -public class PathfinderGoalSelector { - - private static final Logger a = LogManager.getLogger(); - // CraftBukkit start - ArrayList -> UnsafeList - private List b = new UnsafeList(); - private List c = new UnsafeList(); - // CraftBukkit end - private final MethodProfiler d; - private int e; - private int f = 3; - - public PathfinderGoalSelector(MethodProfiler methodprofiler) { - this.d = methodprofiler; - } - - public void a(int i, PathfinderGoal pathfindergoal) { - this.b.add(new PathfinderGoalSelectorItem(this, i, pathfindergoal)); - } - - public void a(PathfinderGoal pathfindergoal) { - Iterator iterator = this.b.iterator(); - - while (iterator.hasNext()) { - PathfinderGoalSelectorItem pathfindergoalselectoritem = (PathfinderGoalSelectorItem) iterator.next(); - PathfinderGoal pathfindergoal1 = pathfindergoalselectoritem.a; - - if (pathfindergoal1 == pathfindergoal) { - if (this.c.contains(pathfindergoalselectoritem)) { - pathfindergoal1.d(); - this.c.remove(pathfindergoalselectoritem); - } - - iterator.remove(); - } - } - } - - public void a() { - // ArrayList arraylist = new ArrayList(); // CraftBukkit - remove usage - Iterator iterator; - PathfinderGoalSelectorItem pathfindergoalselectoritem; - - if (this.e++ % this.f == 0) { - iterator = this.b.iterator(); - - while (iterator.hasNext()) { - pathfindergoalselectoritem = (PathfinderGoalSelectorItem) iterator.next(); - boolean flag = this.c.contains(pathfindergoalselectoritem); - - if (flag) { - if (this.b(pathfindergoalselectoritem) && this.a(pathfindergoalselectoritem)) { - continue; - } - - pathfindergoalselectoritem.a.d(); - this.c.remove(pathfindergoalselectoritem); - } - - if (this.b(pathfindergoalselectoritem) && pathfindergoalselectoritem.a.a()) { - // CraftBukkit start - call method now instead of queueing - // arraylist.add(pathfindergoalselectoritem); - pathfindergoalselectoritem.a.c(); - // CraftBukkit end - this.c.add(pathfindergoalselectoritem); - } - } - } else { - iterator = this.c.iterator(); - - while (iterator.hasNext()) { - pathfindergoalselectoritem = (PathfinderGoalSelectorItem) iterator.next(); - if (!pathfindergoalselectoritem.a.b()) { - pathfindergoalselectoritem.a.d(); - iterator.remove(); - } - } - } - - this.d.a("goalStart"); - // CraftBukkit start - removed usage of arraylist - /*iterator = arraylist.iterator(); - - while (iterator.hasNext()) { - pathfindergoalselectoritem = (PathfinderGoalSelectorItem) iterator.next(); - this.d.a(pathfindergoalselectoritem.a.getClass().getSimpleName()); - pathfindergoalselectoritem.a.c(); - this.d.b(); - }*/ - // CraftBukkit end - - this.d.b(); - this.d.a("goalTick"); - iterator = this.c.iterator(); - - while (iterator.hasNext()) { - pathfindergoalselectoritem = (PathfinderGoalSelectorItem) iterator.next(); - pathfindergoalselectoritem.a.e(); - } - - this.d.b(); - } - - private boolean a(PathfinderGoalSelectorItem pathfindergoalselectoritem) { - this.d.a("canContinue"); - boolean flag = pathfindergoalselectoritem.a.b(); - - this.d.b(); - return flag; - } - - private boolean b(PathfinderGoalSelectorItem pathfindergoalselectoritem) { - this.d.a("canUse"); - Iterator iterator = this.b.iterator(); - - while (iterator.hasNext()) { - PathfinderGoalSelectorItem pathfindergoalselectoritem1 = (PathfinderGoalSelectorItem) iterator.next(); - - if (pathfindergoalselectoritem1 != pathfindergoalselectoritem) { - if (pathfindergoalselectoritem.b >= pathfindergoalselectoritem1.b) { - // CraftBukkit - switch order - if (!this.a(pathfindergoalselectoritem, pathfindergoalselectoritem1) && this.c.contains(pathfindergoalselectoritem1)) { - this.d.b(); - ((UnsafeList.Itr) iterator).valid = false; // CraftBukkit - mark iterator for reuse - return false; - } - // CraftBukkit - switch order - } else if (!pathfindergoalselectoritem1.a.i() && this.c.contains(pathfindergoalselectoritem1)) { - this.d.b(); - ((UnsafeList.Itr) iterator).valid = false; // CraftBukkit - mark iterator for reuse - return false; - } - } - } - - this.d.b(); - return true; - } - - private boolean a(PathfinderGoalSelectorItem pathfindergoalselectoritem, PathfinderGoalSelectorItem pathfindergoalselectoritem1) { - return (pathfindergoalselectoritem.a.j() & pathfindergoalselectoritem1.a.j()) == 0; - } -} diff --git a/src/main/java/net/minecraft/server/PathfinderGoalSit.java b/src/main/java/net/minecraft/server/PathfinderGoalSit.java deleted file mode 100644 index 60371bed..00000000 --- a/src/main/java/net/minecraft/server/PathfinderGoalSit.java +++ /dev/null @@ -1,39 +0,0 @@ -package net.minecraft.server; - -public class PathfinderGoalSit extends PathfinderGoal { - - private EntityTameableAnimal entity; - private boolean willSit; - - public PathfinderGoalSit(EntityTameableAnimal entitytameableanimal) { - this.entity = entitytameableanimal; - this.a(5); - } - - public boolean a() { - if (!this.entity.isTamed()) { - return this.willSit && this.entity.getGoalTarget() == null; // CraftBukkit - Allow sitting for wild animals - } else if (this.entity.M()) { - return false; - } else if (!this.entity.onGround) { - return false; - } else { - EntityLiving entityliving = this.entity.getOwner(); - - return entityliving == null ? true : (this.entity.f(entityliving) < 144.0D && entityliving.getLastDamager() != null ? false : this.willSit); - } - } - - public void c() { - this.entity.getNavigation().h(); - this.entity.setSitting(true); - } - - public void d() { - this.entity.setSitting(false); - } - - public void setSitting(boolean flag) { - this.willSit = flag; - } -} diff --git a/src/main/java/net/minecraft/server/PathfinderGoalTame.java b/src/main/java/net/minecraft/server/PathfinderGoalTame.java deleted file mode 100644 index a13c6382..00000000 --- a/src/main/java/net/minecraft/server/PathfinderGoalTame.java +++ /dev/null @@ -1,72 +0,0 @@ -package net.minecraft.server; - -public class PathfinderGoalTame extends PathfinderGoal { - - private EntityHorse entity; - private double b; - private double c; - private double d; - private double e; - - public PathfinderGoalTame(EntityHorse entityhorse, double d0) { - this.entity = entityhorse; - this.b = d0; - this.a(1); - } - - public boolean a() { - if (!this.entity.isTame() && this.entity.passenger != null) { - Vec3D vec3d = RandomPositionGenerator.a(this.entity, 5, 4); - - if (vec3d == null) { - return false; - } else { - this.c = vec3d.a; - this.d = vec3d.b; - this.e = vec3d.c; - return true; - } - } else { - return false; - } - } - - public void c() { - this.entity.getNavigation().a(this.c, this.d, this.e, this.b); - } - - public boolean b() { - return !this.entity.getNavigation().g() && this.entity.passenger != null; - } - - public void e() { - if (this.entity.aI().nextInt(50) == 0) { - if (this.entity.passenger instanceof EntityHuman) { - int i = this.entity.getTemper(); - int j = this.entity.getMaxDomestication(); - - // CraftBukkit - fire EntityTameEvent - if (j > 0 && this.entity.aI().nextInt(j) < i && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this.entity, (EntityHuman) this.entity.passenger).isCancelled() && this.entity.passenger instanceof EntityHuman) { - this.entity.h((EntityHuman) this.entity.passenger); - this.entity.world.broadcastEntityEffect(this.entity, (byte) 7); - return; - } - - this.entity.v(5); - } - - // CraftBukkit start - Handle dismounting to account for VehicleExitEvent being fired. - if (this.entity.passenger != null) { - this.entity.passenger.mount((Entity) null); - // If the entity still has a passenger, then a plugin cancelled the event. - if (this.entity.passenger != null) { - return; - } - } - // this.entity.passenger = null; - // CraftBukkit end - this.entity.cJ(); - this.entity.world.broadcastEntityEffect(this.entity, (byte) 6); - } - } -} diff --git a/src/main/java/net/minecraft/server/PathfinderGoalTarget.java b/src/main/java/net/minecraft/server/PathfinderGoalTarget.java deleted file mode 100644 index 761fe6da..00000000 --- a/src/main/java/net/minecraft/server/PathfinderGoalTarget.java +++ /dev/null @@ -1,165 +0,0 @@ -package net.minecraft.server; - -import net.minecraft.util.org.apache.commons.lang3.StringUtils; - -// CraftBukkit start -import org.bukkit.craftbukkit.entity.CraftEntity; -import org.bukkit.event.entity.EntityTargetEvent; -// CraftBukkit end - -public abstract class PathfinderGoalTarget extends PathfinderGoal { - - protected EntityCreature c; - protected boolean d; - private boolean a; - private int b; - private int e; - private int f; - - public PathfinderGoalTarget(EntityCreature entitycreature, boolean flag) { - this(entitycreature, flag, false); - } - - public PathfinderGoalTarget(EntityCreature entitycreature, boolean flag, boolean flag1) { - this.c = entitycreature; - this.d = flag; - this.a = flag1; - } - - public boolean b() { - EntityLiving entityliving = this.c.getGoalTarget(); - - if (entityliving == null) { - return false; - } else if (!entityliving.isAlive()) { - return false; - } else { - double d0 = this.f(); - - if (this.c.f(entityliving) > d0 * d0) { - return false; - } else { - if (this.d) { - if (this.c.getEntitySenses().canSee(entityliving)) { - this.f = 0; - } else if (++this.f > 60) { - return false; - } - } - - return !(entityliving instanceof EntityPlayer) || !((EntityPlayer) entityliving).playerInteractManager.isCreative(); - } - } - } - - protected double f() { - AttributeInstance attributeinstance = this.c.getAttributeInstance(GenericAttributes.b); - - return attributeinstance == null ? 16.0D : attributeinstance.getValue(); - } - - public void c() { - this.b = 0; - this.e = 0; - this.f = 0; - } - - public void d() { - this.c.setGoalTarget((EntityLiving) null); - } - - protected boolean a(EntityLiving entityliving, boolean flag) { - if (entityliving == null) { - return false; - } else if (entityliving == this.c) { - return false; - } else if (!entityliving.isAlive()) { - return false; - } else if (!this.c.a(entityliving.getClass())) { - return false; - } else { - if (this.c instanceof EntityOwnable && StringUtils.isNotEmpty(((EntityOwnable) this.c).getOwnerUUID())) { - if (entityliving instanceof EntityOwnable && ((EntityOwnable) this.c).getOwnerUUID().equals(((EntityOwnable) entityliving).getOwnerUUID())) { - return false; - } - - if (entityliving == ((EntityOwnable) this.c).getOwner()) { - return false; - } - } else if (entityliving instanceof EntityHuman && !flag && ((EntityHuman) entityliving).abilities.isInvulnerable) { - return false; - } - - if (!this.c.b(MathHelper.floor(entityliving.locX), MathHelper.floor(entityliving.locY), MathHelper.floor(entityliving.locZ))) { - return false; - } else if (this.d && !this.c.getEntitySenses().canSee(entityliving)) { - return false; - } else { - if (this.a) { - if (--this.e <= 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; - - 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.c, entityliving, reason); - if (event.isCancelled() || event.getTarget() == null) { - this.c.setGoalTarget(null); - return false; - } else if (entityliving.getBukkitEntity() != event.getTarget()) { - this.c.setGoalTarget((EntityLiving) ((CraftEntity) event.getTarget()).getHandle()); - } - if (this.c instanceof EntityCreature) { - ((EntityCreature) this.c).target = ((CraftEntity) event.getTarget()).getHandle(); - } - // CraftBukkit end - - return true; - } - } - } - - private boolean a(EntityLiving entityliving) { - this.e = 10 + this.c.aI().nextInt(5); - PathEntity pathentity = this.c.getNavigation().a(entityliving); - - if (pathentity == null) { - return false; - } else { - PathPoint pathpoint = pathentity.c(); - - if (pathpoint == null) { - return false; - } else { - int i = pathpoint.a - MathHelper.floor(entityliving.locX); - int j = pathpoint.c - MathHelper.floor(entityliving.locZ); - - return (double) (i * i + j * j) <= 2.25D; - } - } - } -} diff --git a/src/main/java/net/minecraft/server/PlayerAbilities.java b/src/main/java/net/minecraft/server/PlayerAbilities.java deleted file mode 100644 index 88718ce0..00000000 --- a/src/main/java/net/minecraft/server/PlayerAbilities.java +++ /dev/null @@ -1,54 +0,0 @@ -package net.minecraft.server; - -public class PlayerAbilities { - - public boolean isInvulnerable; - public boolean isFlying; - public boolean canFly; - public boolean canInstantlyBuild; - public boolean mayBuild = true; - public float flySpeed = 0.05F; // CraftBukkit private -> public - public float walkSpeed = 0.1F; // CraftBukkit private -> public - - public PlayerAbilities() {} - - public void a(NBTTagCompound nbttagcompound) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - - nbttagcompound1.setBoolean("invulnerable", this.isInvulnerable); - nbttagcompound1.setBoolean("flying", this.isFlying); - nbttagcompound1.setBoolean("mayfly", this.canFly); - nbttagcompound1.setBoolean("instabuild", this.canInstantlyBuild); - nbttagcompound1.setBoolean("mayBuild", this.mayBuild); - nbttagcompound1.setFloat("flySpeed", this.flySpeed); - nbttagcompound1.setFloat("walkSpeed", this.walkSpeed); - nbttagcompound.set("abilities", nbttagcompound1); - } - - public void b(NBTTagCompound nbttagcompound) { - if (nbttagcompound.hasKeyOfType("abilities", 10)) { - NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("abilities"); - - this.isInvulnerable = nbttagcompound1.getBoolean("invulnerable"); - this.isFlying = nbttagcompound1.getBoolean("flying"); - this.canFly = nbttagcompound1.getBoolean("mayfly"); - this.canInstantlyBuild = nbttagcompound1.getBoolean("instabuild"); - if (nbttagcompound1.hasKeyOfType("flySpeed", 99)) { - this.flySpeed = nbttagcompound1.getFloat("flySpeed"); - this.walkSpeed = nbttagcompound1.getFloat("walkSpeed"); - } - - if (nbttagcompound1.hasKeyOfType("mayBuild", 1)) { - this.mayBuild = nbttagcompound1.getBoolean("mayBuild"); - } - } - } - - public float a() { - return this.flySpeed; - } - - public float b() { - return this.walkSpeed; - } -} diff --git a/src/main/java/net/minecraft/server/PlayerChunk.java b/src/main/java/net/minecraft/server/PlayerChunk.java deleted file mode 100644 index f5afcb7e..00000000 --- a/src/main/java/net/minecraft/server/PlayerChunk.java +++ /dev/null @@ -1,215 +0,0 @@ -package net.minecraft.server; - -import java.util.ArrayList; -import java.util.List; - -// CraftBukkit start -import org.bukkit.craftbukkit.chunkio.ChunkIOExecutor; -import java.util.HashMap; -// CraftBukkit end - -class PlayerChunk { - - private final List b; - private final ChunkCoordIntPair location; - private short[] dirtyBlocks; - private int dirtyCount; - private int f; - private long g; - final PlayerChunkMap playerChunkMap; - // CraftBukkit start - add fields - private final HashMap<EntityPlayer, Runnable> players = new HashMap<EntityPlayer, Runnable>(); - private boolean loaded = false; - private Runnable loadedRunnable = new Runnable() { - public void run() { - PlayerChunk.this.loaded = true; - } - }; - // CraftBukkit end - - public PlayerChunk(PlayerChunkMap playerchunkmap, int i, int j) { - this.playerChunkMap = playerchunkmap; - this.b = new ArrayList(); - this.dirtyBlocks = new short[64]; - this.location = new ChunkCoordIntPair(i, j); - playerchunkmap.a().chunkProviderServer.getChunkAt(i, j, this.loadedRunnable); // CraftBukkit - } - - public void a(final EntityPlayer entityplayer) { // CraftBukkit - added final to argument - if (this.b.contains(entityplayer)) { - PlayerChunkMap.c().debug("Failed to add player. {} already is in chunk {}, {}", new Object[] { entityplayer, Integer.valueOf(this.location.x), Integer.valueOf(this.location.z)}); - } else { - if (this.b.isEmpty()) { - this.g = PlayerChunkMap.a(this.playerChunkMap).getTime(); - } - - this.b.add(entityplayer); - // CraftBukkit start - use async chunk io - Runnable playerRunnable; - if (this.loaded) { - playerRunnable = null; - entityplayer.chunkCoordIntPairQueue.add(this.location); - } else { - playerRunnable = new Runnable() { - public void run() { - entityplayer.chunkCoordIntPairQueue.add(PlayerChunk.this.location); - } - }; - this.playerChunkMap.a().chunkProviderServer.getChunkAt(this.location.x, this.location.z, playerRunnable); - } - - this.players.put(entityplayer, playerRunnable); - // CraftBukkit end - } - } - - public void b(EntityPlayer entityplayer) { - if (this.b.contains(entityplayer)) { - // CraftBukkit start - If we haven't loaded yet don't load the chunk just so we can clean it up - if (!this.loaded) { - ChunkIOExecutor.dropQueuedChunkLoad(this.playerChunkMap.a(), this.location.x, this.location.z, this.players.get(entityplayer)); - this.b.remove(entityplayer); - this.players.remove(entityplayer); - - if (this.b.isEmpty()) { - ChunkIOExecutor.dropQueuedChunkLoad(this.playerChunkMap.a(), this.location.x, this.location.z, this.loadedRunnable); - long i = (long) this.location.x + 2147483647L | (long) this.location.z + 2147483647L << 32; - PlayerChunkMap.b(this.playerChunkMap).remove(i); - PlayerChunkMap.c(this.playerChunkMap).remove(this); - } - - return; - } - // CraftBukkit end - - Chunk chunk = PlayerChunkMap.a(this.playerChunkMap).getChunkAt(this.location.x, this.location.z); - - if (chunk.isReady()) { - entityplayer.playerConnection.sendPacket(new PacketPlayOutMapChunk(chunk, true, 0)); - } - - this.players.remove(entityplayer); // CraftBukkit - this.b.remove(entityplayer); - entityplayer.chunkCoordIntPairQueue.remove(this.location); - if (this.b.isEmpty()) { - long i = (long) this.location.x + 2147483647L | (long) this.location.z + 2147483647L << 32; - - this.a(chunk); - PlayerChunkMap.b(this.playerChunkMap).remove(i); - PlayerChunkMap.c(this.playerChunkMap).remove(this); - if (this.dirtyCount > 0) { - PlayerChunkMap.d(this.playerChunkMap).remove(this); - } - - this.playerChunkMap.a().chunkProviderServer.queueUnload(this.location.x, this.location.z); - } - } - } - - public void a() { - this.a(PlayerChunkMap.a(this.playerChunkMap).getChunkAt(this.location.x, this.location.z)); - } - - private void a(Chunk chunk) { - chunk.s += PlayerChunkMap.a(this.playerChunkMap).getTime() - this.g; - this.g = PlayerChunkMap.a(this.playerChunkMap).getTime(); - } - - public void a(int i, int j, int k) { - if (this.dirtyCount == 0) { - PlayerChunkMap.d(this.playerChunkMap).add(this); - } - - this.f |= 1 << (j >> 4); - if (this.dirtyCount < 64) { - short short1 = (short) (i << 12 | k << 8 | j); - - for (int l = 0; l < this.dirtyCount; ++l) { - if (this.dirtyBlocks[l] == short1) { - return; - } - } - - this.dirtyBlocks[this.dirtyCount++] = short1; - } - } - - public void sendAll(Packet packet) { - for (int i = 0; i < this.b.size(); ++i) { - EntityPlayer entityplayer = (EntityPlayer) this.b.get(i); - - if (!entityplayer.chunkCoordIntPairQueue.contains(this.location)) { - entityplayer.playerConnection.sendPacket(packet); - } - } - } - - public void b() { - if (this.dirtyCount != 0) { - int i; - int j; - int k; - - if (this.dirtyCount == 1) { - i = this.location.x * 16 + (this.dirtyBlocks[0] >> 12 & 15); - j = this.dirtyBlocks[0] & 255; - k = this.location.z * 16 + (this.dirtyBlocks[0] >> 8 & 15); - this.sendAll(new PacketPlayOutBlockChange(i, j, k, PlayerChunkMap.a(this.playerChunkMap))); - if (PlayerChunkMap.a(this.playerChunkMap).getType(i, j, k).isTileEntity()) { - this.sendTileEntity(PlayerChunkMap.a(this.playerChunkMap).getTileEntity(i, j, k)); - } - } else { - int l; - - if (this.dirtyCount == 64) { - i = this.location.x * 16; - j = this.location.z * 16; - this.sendAll(new PacketPlayOutMapChunk(PlayerChunkMap.a(this.playerChunkMap).getChunkAt(this.location.x, this.location.z), (this.f == 0xFFFF), this.f)); // CraftBukkit - send everything (including biome) if all sections flagged - - for (k = 0; k < 16; ++k) { - if ((this.f & 1 << k) != 0) { - l = k << 4; - List list = PlayerChunkMap.a(this.playerChunkMap).getTileEntities(i, l, j, i + 16, l + 16, j + 16); - - for (int i1 = 0; i1 < list.size(); ++i1) { - this.sendTileEntity((TileEntity) list.get(i1)); - } - } - } - } else { - this.sendAll(new PacketPlayOutMultiBlockChange(this.dirtyCount, this.dirtyBlocks, PlayerChunkMap.a(this.playerChunkMap).getChunkAt(this.location.x, this.location.z))); - - for (i = 0; i < this.dirtyCount; ++i) { - j = this.location.x * 16 + (this.dirtyBlocks[i] >> 12 & 15); - k = this.dirtyBlocks[i] & 255; - l = this.location.z * 16 + (this.dirtyBlocks[i] >> 8 & 15); - if (PlayerChunkMap.a(this.playerChunkMap).getType(j, k, l).isTileEntity()) { - this.sendTileEntity(PlayerChunkMap.a(this.playerChunkMap).getTileEntity(j, k, l)); - } - } - } - } - - this.dirtyCount = 0; - this.f = 0; - } - } - - private void sendTileEntity(TileEntity tileentity) { - if (tileentity != null) { - Packet packet = tileentity.getUpdatePacket(); - - if (packet != null) { - this.sendAll(packet); - } - } - } - - static ChunkCoordIntPair a(PlayerChunk playerchunk) { - return playerchunk.location; - } - - static List b(PlayerChunk playerchunk) { - return playerchunk.b; - } -} diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java deleted file mode 100644 index ae53635d..00000000 --- a/src/main/java/net/minecraft/server/PlayerChunkMap.java +++ /dev/null @@ -1,371 +0,0 @@ -package net.minecraft.server; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -// CraftBukkit start -import java.util.Collections; -import java.util.Queue; -import java.util.LinkedList; -// CraftBukkit end - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -public class PlayerChunkMap { - - private static final Logger a = LogManager.getLogger(); - private final WorldServer world; - private final List managedPlayers = new ArrayList(); - private final LongHashMap d = new LongHashMap(); - private final Queue e = new java.util.concurrent.ConcurrentLinkedQueue(); // CraftBukkit ArrayList -> ConcurrentLinkedQueue - private final Queue f = new java.util.concurrent.ConcurrentLinkedQueue(); // CraftBukkit ArrayList -> ConcurrentLinkedQueue - private int g; - private long h; - private final int[][] i = new int[][] { { 1, 0}, { 0, 1}, { -1, 0}, { 0, -1}}; - private boolean wasNotEmpty; // CraftBukkit - add field - - public PlayerChunkMap(WorldServer worldserver) { - this.world = worldserver; - this.a(worldserver.getMinecraftServer().getPlayerList().s()); - } - - public WorldServer a() { - return this.world; - } - - public void flush() { - long i = this.world.getTime(); - int j; - PlayerChunk playerchunk; - - if (i - this.h > 8000L) { - this.h = i; - - // CraftBukkit start - Use iterator - java.util.Iterator iterator = this.f.iterator(); - while (iterator.hasNext()) { - playerchunk = (PlayerChunk) iterator.next(); - playerchunk.b(); - playerchunk.a(); - } - } else { - java.util.Iterator iterator = this.e.iterator(); - - while (iterator.hasNext()) { - playerchunk = (PlayerChunk) iterator.next(); - playerchunk.b(); - iterator.remove(); - // CraftBukkit end - } - } - - // this.e.clear(); // CraftBukkit - Removals are already covered - if (this.managedPlayers.isEmpty()) { - if (!wasNotEmpty) return; // CraftBukkit - Only do unload when we go from non-empty to empty - WorldProvider worldprovider = this.world.worldProvider; - - if (!worldprovider.e()) { - this.world.chunkProviderServer.b(); - } - // CraftBukkit start - wasNotEmpty = false; - } else { - wasNotEmpty = true; - } - // CraftBukkit end - } - - public boolean a(int i, int j) { - long k = (long) i + 2147483647L | (long) j + 2147483647L << 32; - - return this.d.getEntry(k) != null; - } - - private PlayerChunk a(int i, int j, boolean flag) { - long k = (long) i + 2147483647L | (long) j + 2147483647L << 32; - PlayerChunk playerchunk = (PlayerChunk) this.d.getEntry(k); - - if (playerchunk == null && flag) { - playerchunk = new PlayerChunk(this, i, j); - this.d.put(k, playerchunk); - this.f.add(playerchunk); - } - - return playerchunk; - } - // CraftBukkit start - add method - public final boolean isChunkInUse(int x, int z) { - PlayerChunk pi = a(x, z, false); - if (pi != null) { - return (PlayerChunk.b(pi).size() > 0); - } - return false; - } - // CraftBukkit end - - public void flagDirty(int i, int j, int k) { - int l = i >> 4; - int i1 = k >> 4; - PlayerChunk playerchunk = this.a(l, i1, false); - - if (playerchunk != null) { - playerchunk.a(i & 15, j, k & 15); - } - } - - public void addPlayer(EntityPlayer entityplayer) { - int i = (int) entityplayer.locX >> 4; - int j = (int) entityplayer.locZ >> 4; - - entityplayer.d = entityplayer.locX; - entityplayer.e = entityplayer.locZ; - - // CraftBukkit start - Load nearby chunks first - List<ChunkCoordIntPair> chunkList = new LinkedList<ChunkCoordIntPair>(); - for (int k = i - this.g; k <= i + this.g; ++k) { - for (int l = j - this.g; l <= j + this.g; ++l) { - chunkList.add(new ChunkCoordIntPair(k, l)); - } - } - - Collections.sort(chunkList, new ChunkCoordComparator(entityplayer)); - for (ChunkCoordIntPair pair : chunkList) { - this.a(pair.x, pair.z, true).a(entityplayer); - } - // CraftBukkit end - - this.managedPlayers.add(entityplayer); - this.b(entityplayer); - } - - public void b(EntityPlayer entityplayer) { - ArrayList arraylist = new ArrayList(entityplayer.chunkCoordIntPairQueue); - int i = 0; - int j = this.g; - int k = (int) entityplayer.locX >> 4; - int l = (int) entityplayer.locZ >> 4; - int i1 = 0; - int j1 = 0; - ChunkCoordIntPair chunkcoordintpair = PlayerChunk.a(this.a(k, l, true)); - - entityplayer.chunkCoordIntPairQueue.clear(); - if (arraylist.contains(chunkcoordintpair)) { - entityplayer.chunkCoordIntPairQueue.add(chunkcoordintpair); - } - - int k1; - - for (k1 = 1; k1 <= j * 2; ++k1) { - for (int l1 = 0; l1 < 2; ++l1) { - int[] aint = this.i[i++ % 4]; - - for (int i2 = 0; i2 < k1; ++i2) { - i1 += aint[0]; - j1 += aint[1]; - chunkcoordintpair = PlayerChunk.a(this.a(k + i1, l + j1, true)); - if (arraylist.contains(chunkcoordintpair)) { - entityplayer.chunkCoordIntPairQueue.add(chunkcoordintpair); - } - } - } - } - - i %= 4; - - for (k1 = 0; k1 < j * 2; ++k1) { - i1 += this.i[i][0]; - j1 += this.i[i][1]; - chunkcoordintpair = PlayerChunk.a(this.a(k + i1, l + j1, true)); - if (arraylist.contains(chunkcoordintpair)) { - entityplayer.chunkCoordIntPairQueue.add(chunkcoordintpair); - } - } - } - - public void removePlayer(EntityPlayer entityplayer) { - int i = (int) entityplayer.d >> 4; - int j = (int) entityplayer.e >> 4; - - for (int k = i - this.g; k <= i + this.g; ++k) { - for (int l = j - this.g; l <= j + this.g; ++l) { - PlayerChunk playerchunk = this.a(k, l, false); - - if (playerchunk != null) { - playerchunk.b(entityplayer); - } - } - } - - this.managedPlayers.remove(entityplayer); - } - - private boolean a(int i, int j, int k, int l, int i1) { - int j1 = i - k; - int k1 = j - l; - - return j1 >= -i1 && j1 <= i1 ? k1 >= -i1 && k1 <= i1 : false; - } - - public void movePlayer(EntityPlayer entityplayer) { - int i = (int) entityplayer.locX >> 4; - int j = (int) entityplayer.locZ >> 4; - double d0 = entityplayer.d - entityplayer.locX; - double d1 = entityplayer.e - entityplayer.locZ; - double d2 = d0 * d0 + d1 * d1; - - if (d2 >= 64.0D) { - int k = (int) entityplayer.d >> 4; - int l = (int) entityplayer.e >> 4; - int i1 = this.g; - int j1 = i - k; - int k1 = j - l; - List<ChunkCoordIntPair> chunksToLoad = new LinkedList<ChunkCoordIntPair>(); // CraftBukkit - - if (j1 != 0 || k1 != 0) { - for (int l1 = i - i1; l1 <= i + i1; ++l1) { - for (int i2 = j - i1; i2 <= j + i1; ++i2) { - if (!this.a(l1, i2, k, l, i1)) { - chunksToLoad.add(new ChunkCoordIntPair(l1, i2)); // CraftBukkit - } - - if (!this.a(l1 - j1, i2 - k1, i, j, i1)) { - PlayerChunk playerchunk = this.a(l1 - j1, i2 - k1, false); - - if (playerchunk != null) { - playerchunk.b(entityplayer); - } - } - } - } - - this.b(entityplayer); - entityplayer.d = entityplayer.locX; - entityplayer.e = entityplayer.locZ; - - // CraftBukkit start - send nearest chunks first - Collections.sort(chunksToLoad, new ChunkCoordComparator(entityplayer)); - for (ChunkCoordIntPair pair : chunksToLoad) { - this.a(pair.x, pair.z, true).a(entityplayer); - } - - if (i1 > 1 || i1 < -1 || j1 > 1 || j1 < -1) { - Collections.sort(entityplayer.chunkCoordIntPairQueue, new ChunkCoordComparator(entityplayer)); - } - // CraftBukkit end - } - } - } - - public boolean a(EntityPlayer entityplayer, int i, int j) { - PlayerChunk playerchunk = this.a(i, j, false); - - return playerchunk != null && PlayerChunk.b(playerchunk).contains(entityplayer) && !entityplayer.chunkCoordIntPairQueue.contains(PlayerChunk.a(playerchunk)); - } - - public void a(int i) { - i = MathHelper.a(i, 3, 20); - if (i != this.g) { - int j = i - this.g; - Iterator iterator = this.managedPlayers.iterator(); - - while (iterator.hasNext()) { - EntityPlayer entityplayer = (EntityPlayer) iterator.next(); - int k = (int) entityplayer.locX >> 4; - int l = (int) entityplayer.locZ >> 4; - int i1; - int j1; - - if (j > 0) { - for (i1 = k - i; i1 <= k + i; ++i1) { - for (j1 = l - i; j1 <= l + i; ++j1) { - PlayerChunk playerchunk = this.a(i1, j1, true); - - if (!PlayerChunk.b(playerchunk).contains(entityplayer)) { - playerchunk.a(entityplayer); - } - } - } - } else { - for (i1 = k - this.g; i1 <= k + this.g; ++i1) { - for (j1 = l - this.g; j1 <= l + this.g; ++j1) { - if (!this.a(i1, j1, k, l, i)) { - this.a(i1, j1, true).b(entityplayer); - } - } - } - } - } - - this.g = i; - } - } - - public static int getFurthestViewableBlock(int i) { - return i * 16 - 16; - } - - static Logger c() { - return a; - } - - static WorldServer a(PlayerChunkMap playerchunkmap) { - return playerchunkmap.world; - } - - static LongHashMap b(PlayerChunkMap playerchunkmap) { - return playerchunkmap.d; - } - - static Queue c(PlayerChunkMap playermanager) { // CraftBukkit List -> Queue - return playermanager.f; - } - - static Queue d(PlayerChunkMap playermanager) { // CraftBukkit List -> Queue - return playermanager.e; - } - - // CraftBukkit start - Sorter to load nearby chunks first - private static class ChunkCoordComparator implements java.util.Comparator<ChunkCoordIntPair> { - private int x; - private int z; - - public ChunkCoordComparator (EntityPlayer entityplayer) { - x = (int) entityplayer.locX >> 4; - z = (int) entityplayer.locZ >> 4; - } - - public int compare(ChunkCoordIntPair a, ChunkCoordIntPair b) { - if (a.equals(b)) { - return 0; - } - - // Subtract current position to set center point - int ax = a.x - this.x; - int az = a.z - this.z; - int bx = b.x - this.x; - int bz = b.z - this.z; - - int result = ((ax - bx) * (ax + bx)) + ((az - bz) * (az + bz)); - if (result != 0) { - return result; - } - - if (ax < 0) { - if (bx < 0) { - return bz - az; - } else { - return -1; - } - } else { - if (bx < 0) { - return 1; - } else { - return az - bz; - } - } - } - } - // CraftBukkit end -} diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java deleted file mode 100644 index 3a984394..00000000 --- a/src/main/java/net/minecraft/server/PlayerConnection.java +++ /dev/null @@ -1,1855 +0,0 @@ -package net.minecraft.server; - -import java.io.ByteArrayInputStream; -import java.io.DataInputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Date; -import java.util.Iterator; -import java.util.Random; -import java.util.concurrent.Callable; - -import net.minecraft.util.com.google.common.base.Charsets; -import net.minecraft.util.com.google.common.collect.Lists; -import net.minecraft.util.io.netty.buffer.Unpooled; -import net.minecraft.util.io.netty.util.concurrent.GenericFutureListener; -import net.minecraft.util.org.apache.commons.lang3.StringUtils; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -// CraftBukkit start -import java.io.UnsupportedEncodingException; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; -import java.util.HashSet; - -import org.bukkit.craftbukkit.entity.CraftPlayer; -import org.bukkit.craftbukkit.event.CraftEventFactory; -import org.bukkit.craftbukkit.inventory.CraftInventoryView; -import org.bukkit.craftbukkit.inventory.CraftItemStack; -import org.bukkit.craftbukkit.util.CraftChatMessage; -import org.bukkit.craftbukkit.util.LazyPlayerSet; -import org.bukkit.craftbukkit.util.Waitable; - -import org.bukkit.Location; -import org.bukkit.entity.Player; -import org.bukkit.event.Event; -import org.bukkit.event.block.Action; -import org.bukkit.event.block.SignChangeEvent; -import org.bukkit.event.inventory.ClickType; -import org.bukkit.event.inventory.CraftItemEvent; -import org.bukkit.event.inventory.InventoryAction; -import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.event.inventory.InventoryCreativeEvent; -import org.bukkit.event.inventory.InventoryType.SlotType; -import org.bukkit.event.player.AsyncPlayerChatEvent; -import org.bukkit.event.player.PlayerAnimationEvent; -import org.bukkit.event.player.PlayerChatEvent; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.event.player.PlayerInteractEntityEvent; -import org.bukkit.event.player.PlayerItemHeldEvent; -import org.bukkit.event.player.PlayerKickEvent; -import org.bukkit.event.player.PlayerMoveEvent; -import org.bukkit.event.player.PlayerTeleportEvent; -import org.bukkit.event.player.PlayerToggleFlightEvent; -import org.bukkit.event.player.PlayerToggleSneakEvent; -import org.bukkit.event.player.PlayerToggleSprintEvent; -import org.bukkit.inventory.CraftingInventory; -import org.bukkit.inventory.InventoryView; -import org.bukkit.util.NumberConversions; -// CraftBukkit end - -public class PlayerConnection implements PacketPlayInListener { - - private static final Logger c = LogManager.getLogger(); - public final NetworkManager networkManager; - private final MinecraftServer minecraftServer; - public EntityPlayer player; - private int e; - private int f; - private boolean g; - private int h; - private long i; - private static Random j = new Random(); - private long k; - private volatile int chatThrottle; private static final AtomicIntegerFieldUpdater chatSpamField = AtomicIntegerFieldUpdater.newUpdater(PlayerConnection.class, "chatThrottle"); // CraftBukkit - multithreaded field - private int x; - private IntHashMap n = new IntHashMap(); - private double y; - private double z; - private double q; - public boolean checkMovement = true; // CraftBukkit - private -> public - private boolean processedDisconnect; // CraftBukkit - added - - public PlayerConnection(MinecraftServer minecraftserver, NetworkManager networkmanager, EntityPlayer entityplayer) { - this.minecraftServer = minecraftserver; - this.networkManager = networkmanager; - networkmanager.a((PacketListener) this); - this.player = entityplayer; - entityplayer.playerConnection = this; - - // CraftBukkit start - add fields and methods - this.server = minecraftserver.server; - } - - private final org.bukkit.craftbukkit.CraftServer server; - private int lastTick = MinecraftServer.currentTick; - private int lastDropTick = MinecraftServer.currentTick; - private int dropCount = 0; - private static final int SURVIVAL_PLACE_DISTANCE_SQUARED = 6 * 6; - private static final int CREATIVE_PLACE_DISTANCE_SQUARED = 7 * 7; - - // Get position of last block hit for BlockDamageLevel.STOPPED - private double lastPosX = Double.MAX_VALUE; - private double lastPosY = Double.MAX_VALUE; - private double lastPosZ = Double.MAX_VALUE; - private float lastPitch = Float.MAX_VALUE; - private float lastYaw = Float.MAX_VALUE; - private boolean justTeleported = false; - - // For the PacketPlayOutBlockPlace hack :( - Long lastPacket; - - // Store the last block right clicked and what type it was - private Item lastMaterial; - - public CraftPlayer getPlayer() { - return (this.player == null) ? null : (CraftPlayer) this.player.getBukkitEntity(); - } - private final static HashSet<Integer> invalidItems = new HashSet<Integer>(java.util.Arrays.asList(8, 9, 10, 11, 26, 34, 36, 43, 51, 52, 55, 59, 60, 62, 63, 64, 68, 71, 74, 75, 83, 90, 92, 93, 94, 104, 105, 115, 117, 118, 119, 125, 127, 132, 140, 141, 142, 144)); // TODO: Check after every update. - // CraftBukkit end - - public void a() { - this.g = false; - ++this.e; - this.minecraftServer.methodProfiler.a("keepAlive"); - if ((long) this.e - this.k > 40L) { - this.k = (long) this.e; - this.i = this.d(); - this.h = (int) this.i; - this.sendPacket(new PacketPlayOutKeepAlive(this.h)); - } - - // CraftBukkit start - for (int spam; (spam = this.chatThrottle) > 0 && !chatSpamField.compareAndSet(this, spam, spam - 1); ) ; - /* Use thread-safe field access instead - if (this.chatThrottle > 0) { - --this.chatThrottle; - } - */ - // CraftBukkit end - - if (this.x > 0) { - --this.x; - } - - if (this.player.x() > 0L && this.minecraftServer.getIdleTimeout() > 0 && MinecraftServer.ar() - this.player.x() > (long) (this.minecraftServer.getIdleTimeout() * 1000 * 60)) { - this.disconnect("You have been idle for too long!"); - } - } - - public NetworkManager b() { - return this.networkManager; - } - - public void disconnect(String s) { - // CraftBukkit start - fire PlayerKickEvent - String leaveMessage = EnumChatFormat.YELLOW + this.player.getName() + " left the game."; - - PlayerKickEvent event = new PlayerKickEvent(this.server.getPlayer(this.player), s, leaveMessage); - - if (this.server.getServer().isRunning()) { - this.server.getPluginManager().callEvent(event); - } - - if (event.isCancelled()) { - // Do not kick the player - return; - } - // Send the possibly modified leave message - s = event.getReason(); - // CraftBukkit end - ChatComponentText chatcomponenttext = new ChatComponentText(s); - - this.networkManager.handle(new PacketPlayOutKickDisconnect(chatcomponenttext), new GenericFutureListener[] { new PlayerConnectionFuture(this, chatcomponenttext)}); - this.a(chatcomponenttext); // CraftBukkit - Process quit immediately - this.networkManager.g(); - } - - public void a(PacketPlayInSteerVehicle packetplayinsteervehicle) { - this.player.a(packetplayinsteervehicle.c(), packetplayinsteervehicle.d(), packetplayinsteervehicle.e(), packetplayinsteervehicle.f()); - } - - public void a(PacketPlayInFlying packetplayinflying) { - // CraftBukkit start - Check for NaN - if (Double.isNaN(packetplayinflying.x) || Double.isNaN(packetplayinflying.y) || Double.isNaN(packetplayinflying.z) || Double.isNaN(packetplayinflying.stance)) { - c.warn(player.getName() + " was caught trying to crash the server with an invalid position."); - getPlayer().kickPlayer("Nope!"); - return; - } - // CraftBukkit end - WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); - - this.g = true; - if (!this.player.viewingCredits) { - double d0; - - if (!this.checkMovement) { - d0 = packetplayinflying.d() - this.z; - if (packetplayinflying.c() == this.y && d0 * d0 < 0.01D && packetplayinflying.e() == this.q) { - this.checkMovement = true; - } - } - - // CraftBukkit start - fire PlayerMoveEvent - Player player = this.getPlayer(); - Location from = new Location(player.getWorld(), lastPosX, lastPosY, lastPosZ, lastYaw, lastPitch); // Get the Players previous Event location. - Location to = player.getLocation().clone(); // Start off the To location as the Players current location. - - // If the packet contains movement information then we update the To location with the correct XYZ. - if (packetplayinflying.hasPos && !(packetplayinflying.hasPos && packetplayinflying.y == -999.0D && packetplayinflying.stance == -999.0D)) { - to.setX(packetplayinflying.x); - to.setY(packetplayinflying.y); - to.setZ(packetplayinflying.z); - } - - // If the packet contains look information then we update the To location with the correct Yaw & Pitch. - if (packetplayinflying.hasLook) { - to.setYaw(packetplayinflying.yaw); - to.setPitch(packetplayinflying.pitch); - } - - // Prevent 40 event-calls for less than a single pixel of movement >.> - double delta = Math.pow(this.lastPosX - to.getX(), 2) + Math.pow(this.lastPosY - to.getY(), 2) + Math.pow(this.lastPosZ - to.getZ(), 2); - float deltaAngle = Math.abs(this.lastYaw - to.getYaw()) + Math.abs(this.lastPitch - to.getPitch()); - - if ((delta > 1f / 256 || deltaAngle > 10f) && (this.checkMovement && !this.player.dead)) { - this.lastPosX = to.getX(); - this.lastPosY = to.getY(); - this.lastPosZ = to.getZ(); - this.lastYaw = to.getYaw(); - this.lastPitch = to.getPitch(); - - // Skip the first time we do this - if (from.getX() != Double.MAX_VALUE) { - PlayerMoveEvent event = new PlayerMoveEvent(player, from, to); - this.server.getPluginManager().callEvent(event); - - // If the event is cancelled we move the player back to their old location. - if (event.isCancelled()) { - this.player.playerConnection.sendPacket(new PacketPlayOutPosition(from.getX(), from.getY() + 1.6200000047683716D, from.getZ(), from.getYaw(), from.getPitch(), false)); - return; - } - - /* If a Plugin has changed the To destination then we teleport the Player - there to avoid any 'Moved wrongly' or 'Moved too quickly' errors. - We only do this if the Event was not cancelled. */ - if (!to.equals(event.getTo()) && !event.isCancelled()) { - this.player.getBukkitEntity().teleport(event.getTo(), PlayerTeleportEvent.TeleportCause.UNKNOWN); - return; - } - - /* Check to see if the Players Location has some how changed during the call of the event. - This can happen due to a plugin teleporting the player instead of using .setTo() */ - if (!from.equals(this.getPlayer().getLocation()) && this.justTeleported) { - this.justTeleported = false; - return; - } - } - } - - if (this.checkMovement && !this.player.dead) { - // CraftBukkit end - double d1; - double d2; - double d3; - - if (this.player.vehicle != null) { - float f = this.player.yaw; - float f1 = this.player.pitch; - - this.player.vehicle.ac(); - d1 = this.player.locX; - d2 = this.player.locY; - d3 = this.player.locZ; - if (packetplayinflying.k()) { - f = packetplayinflying.g(); - f1 = packetplayinflying.h(); - } - - this.player.onGround = packetplayinflying.i(); - this.player.i(); - this.player.V = 0.0F; - this.player.setLocation(d1, d2, d3, f, f1); - if (this.player.vehicle != null) { - this.player.vehicle.ac(); - } - - this.minecraftServer.getPlayerList().d(this.player); - if (this.checkMovement) { - this.y = this.player.locX; - this.z = this.player.locY; - this.q = this.player.locZ; - } - - worldserver.playerJoinedWorld(this.player); - return; - } - - if (this.player.isSleeping()) { - this.player.i(); - this.player.setLocation(this.y, this.z, this.q, this.player.yaw, this.player.pitch); - worldserver.playerJoinedWorld(this.player); - return; - } - - d0 = this.player.locY; - this.y = this.player.locX; - this.z = this.player.locY; - this.q = this.player.locZ; - d1 = this.player.locX; - d2 = this.player.locY; - d3 = this.player.locZ; - float f2 = this.player.yaw; - float f3 = this.player.pitch; - - if (packetplayinflying.j() && packetplayinflying.d() == -999.0D && packetplayinflying.f() == -999.0D) { - packetplayinflying.a(false); - } - - double d4; - - if (packetplayinflying.j()) { - d1 = packetplayinflying.c(); - d2 = packetplayinflying.d(); - d3 = packetplayinflying.e(); - d4 = packetplayinflying.f() - packetplayinflying.d(); - if (!this.player.isSleeping() && (d4 > 1.65D || d4 < 0.1D)) { - this.disconnect("Illegal stance"); - c.warn(this.player.getName() + " had an illegal stance: " + d4); - return; - } - - if (Math.abs(packetplayinflying.c()) > 3.2E7D || Math.abs(packetplayinflying.e()) > 3.2E7D) { - this.disconnect("Illegal position"); - return; - } - } - - if (packetplayinflying.k()) { - f2 = packetplayinflying.g(); - f3 = packetplayinflying.h(); - } - - this.player.i(); - this.player.V = 0.0F; - this.player.setLocation(this.y, this.z, this.q, f2, f3); - if (!this.checkMovement) { - return; - } - - d4 = d1 - this.player.locX; - double d5 = d2 - this.player.locY; - double d6 = d3 - this.player.locZ; - // CraftBukkit start - min to max - double d7 = Math.max(Math.abs(d4), Math.abs(this.player.motX)); - double d8 = Math.max(Math.abs(d5), Math.abs(this.player.motY)); - double d9 = Math.max(Math.abs(d6), Math.abs(this.player.motZ)); - // CraftBukkit end - double d10 = d7 * d7 + d8 * d8 + d9 * d9; - - if (d10 > 100.0D && this.checkMovement && (!this.minecraftServer.N() || !this.minecraftServer.M().equals(this.player.getName()))) { // CraftBukkit - Added this.checkMovement condition to solve this check being triggered by teleports - c.warn(this.player.getName() + " moved too quickly! " + d4 + "," + d5 + "," + d6 + " (" + d7 + ", " + d8 + ", " + d9 + ")"); - this.a(this.y, this.z, this.q, this.player.yaw, this.player.pitch); - return; - } - - float f4 = 0.0625F; - boolean flag = worldserver.getCubes(this.player, this.player.boundingBox.clone().shrink((double) f4, (double) f4, (double) f4)).isEmpty(); - - if (this.player.onGround && !packetplayinflying.i() && d5 > 0.0D) { - this.player.bj(); - } - - this.player.move(d4, d5, d6); - this.player.onGround = packetplayinflying.i(); - this.player.checkMovement(d4, d5, d6); - double d11 = d5; - - d4 = d1 - this.player.locX; - d5 = d2 - this.player.locY; - if (d5 > -0.5D || d5 < 0.5D) { - d5 = 0.0D; - } - - d6 = d3 - this.player.locZ; - d10 = d4 * d4 + d5 * d5 + d6 * d6; - boolean flag1 = false; - - if (d10 > 0.0625D && !this.player.isSleeping() && !this.player.playerInteractManager.isCreative()) { - flag1 = true; - c.warn(this.player.getName() + " moved wrongly!"); - } - - this.player.setLocation(d1, d2, d3, f2, f3); - boolean flag2 = worldserver.getCubes(this.player, this.player.boundingBox.clone().shrink((double) f4, (double) f4, (double) f4)).isEmpty(); - - if (flag && (flag1 || !flag2) && !this.player.isSleeping()) { - this.a(this.y, this.z, this.q, f2, f3); - return; - } - - AxisAlignedBB axisalignedbb = this.player.boundingBox.clone().grow((double) f4, (double) f4, (double) f4).a(0.0D, -0.55D, 0.0D); - - if (!this.minecraftServer.getAllowFlight() && !this.player.abilities.canFly && !worldserver.c(axisalignedbb)) { // CraftBukkit - check abilities instead of creative mode - if (d11 >= -0.03125D) { - ++this.f; - if (this.f > 80) { - c.warn(this.player.getName() + " was kicked for floating too long!"); - this.disconnect("Flying is not enabled on this server"); - return; - } - } - } else { - this.f = 0; - } - - this.player.onGround = packetplayinflying.i(); - this.minecraftServer.getPlayerList().d(this.player); - this.player.b(this.player.locY - d0, packetplayinflying.i()); - } else if (this.e % 20 == 0) { - this.a(this.y, this.z, this.q, this.player.yaw, this.player.pitch); - } - } - } - - public void a(double d0, double d1, double d2, float f, float f1) { - // CraftBukkit start - Delegate to teleport(Location) - Player player = this.getPlayer(); - Location from = player.getLocation(); - Location to = new Location(this.getPlayer().getWorld(), d0, d1, d2, f, f1); - PlayerTeleportEvent event = new PlayerTeleportEvent(player, from, to, PlayerTeleportEvent.TeleportCause.UNKNOWN); - this.server.getPluginManager().callEvent(event); - - from = event.getFrom(); - to = event.isCancelled() ? from : event.getTo(); - - this.teleport(to); - } - - public void teleport(Location dest) { - double d0, d1, d2; - float f, f1; - - d0 = dest.getX(); - d1 = dest.getY(); - d2 = dest.getZ(); - f = dest.getYaw(); - f1 = dest.getPitch(); - - // TODO: make sure this is the best way to address this. - if (Float.isNaN(f)) { - f = 0; - } - - if (Float.isNaN(f1)) { - f1 = 0; - } - - this.lastPosX = d0; - this.lastPosY = d1; - this.lastPosZ = d2; - this.lastYaw = f; - this.lastPitch = f1; - this.justTeleported = true; - // CraftBukkit end - - this.checkMovement = false; - this.y = d0; - this.z = d1; - this.q = d2; - this.player.setLocation(d0, d1, d2, f, f1); - this.player.playerConnection.sendPacket(new PacketPlayOutPosition(d0, d1 + 1.6200000047683716D, d2, f, f1, false)); - } - - public void a(PacketPlayInBlockDig packetplayinblockdig) { - if (this.player.dead) return; // CraftBukkit - WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); - - this.player.v(); - if (packetplayinblockdig.g() == 4) { - // CraftBukkit start - limit how quickly items can be dropped - // If the ticks aren't the same then the count starts from 0 and we update the lastDropTick. - if (this.lastDropTick != MinecraftServer.currentTick) { - this.dropCount = 0; - this.lastDropTick = MinecraftServer.currentTick; - } else { - // Else we increment the drop count and check the amount. - this.dropCount++; - if (this.dropCount >= 20) { - this.c.warn(this.player.getName() + " dropped their items too quickly!"); - this.disconnect("You dropped your items too quickly (Hacking?)"); - return; - } - } - // CraftBukkit end - this.player.a(false); - } else if (packetplayinblockdig.g() == 3) { - this.player.a(true); - } else if (packetplayinblockdig.g() == 5) { - this.player.bA(); - } else { - boolean flag = false; - - if (packetplayinblockdig.g() == 0) { - flag = true; - } - - if (packetplayinblockdig.g() == 1) { - flag = true; - } - - if (packetplayinblockdig.g() == 2) { - flag = true; - } - - int i = packetplayinblockdig.c(); - int j = packetplayinblockdig.d(); - int k = packetplayinblockdig.e(); - - if (flag) { - double d0 = this.player.locX - ((double) i + 0.5D); - double d1 = this.player.locY - ((double) j + 0.5D) + 1.5D; - double d2 = this.player.locZ - ((double) k + 0.5D); - double d3 = d0 * d0 + d1 * d1 + d2 * d2; - - if (d3 > 36.0D) { - return; - } - - if (j >= this.minecraftServer.getMaxBuildHeight()) { - return; - } - } - - if (packetplayinblockdig.g() == 0) { - if (!this.minecraftServer.a(worldserver, i, j, k, this.player)) { - this.player.playerInteractManager.dig(i, j, k, packetplayinblockdig.f()); - } else { - // CraftBukkit start - fire PlayerInteractEvent - CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, i, j, k, packetplayinblockdig.f(), this.player.inventory.getItemInHand()); - this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(i, j, k, worldserver)); - // Update any tile entity data for this block - TileEntity tileentity = worldserver.getTileEntity(i, j, k); - if (tileentity != null) { - this.player.playerConnection.sendPacket(tileentity.getUpdatePacket()); - } - // CraftBukkit end - } - } else if (packetplayinblockdig.g() == 2) { - this.player.playerInteractManager.a(i, j, k); - if (worldserver.getType(i, j, k).getMaterial() != Material.AIR) { - this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(i, j, k, worldserver)); - } - } else if (packetplayinblockdig.g() == 1) { - this.player.playerInteractManager.c(i, j, k); - if (worldserver.getType(i, j, k).getMaterial() != Material.AIR) { - this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(i, j, k, worldserver)); - } - } - } - } - - public void a(PacketPlayInBlockPlace packetplayinblockplace) { - WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); - - // CraftBukkit start - if (this.player.dead) return; - - // This is a horrible hack needed because the client sends 2 packets on 'right mouse click' - // aimed at a block. We shouldn't need to get the second packet if the data is handled - // but we cannot know what the client will do, so we might still get it - // - // If the time between packets is small enough, and the 'signature' similar, we discard the - // second one. This sadly has to remain until Mojang makes their packets saner. :( - // -- Grum - if (packetplayinblockplace.getFace() == 255) { - if (packetplayinblockplace.getItemStack() != null && packetplayinblockplace.getItemStack().getItem() == this.lastMaterial && this.lastPacket != null && packetplayinblockplace.timestamp - this.lastPacket < 100) { - this.lastPacket = null; - return; - } - } else { - this.lastMaterial = packetplayinblockplace.getItemStack() == null ? null : packetplayinblockplace.getItemStack().getItem(); - this.lastPacket = packetplayinblockplace.timestamp; - } - // CraftBukkit - if rightclick decremented the item, always send the update packet. */ - // this is not here for CraftBukkit's own functionality; rather it is to fix - // a notch bug where the item doesn't update correctly. - boolean always = false; - // CraftBukkit end - - ItemStack itemstack = this.player.inventory.getItemInHand(); - boolean flag = false; - int i = packetplayinblockplace.c(); - int j = packetplayinblockplace.d(); - int k = packetplayinblockplace.e(); - int l = packetplayinblockplace.getFace(); - - this.player.v(); - if (packetplayinblockplace.getFace() == 255) { - if (itemstack == null) { - return; - } - - // CraftBukkit start - int itemstackAmount = itemstack.count; - org.bukkit.event.player.PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.RIGHT_CLICK_AIR, itemstack); - if (event.useItemInHand() != Event.Result.DENY) { - this.player.playerInteractManager.useItem(this.player, this.player.world, itemstack); - } - - // CraftBukkit - notch decrements the counter by 1 in the above method with food, - // snowballs and so forth, but he does it in a place that doesn't cause the - // inventory update packet to get sent - always = (itemstack.count != itemstackAmount) || itemstack.getItem() == Item.getItemOf(Blocks.WATER_LILY); - // CraftBukkit end - } else if (packetplayinblockplace.d() >= this.minecraftServer.getMaxBuildHeight() - 1 && (packetplayinblockplace.getFace() == 1 || packetplayinblockplace.d() >= this.minecraftServer.getMaxBuildHeight())) { - ChatMessage chatmessage = new ChatMessage("build.tooHigh", new Object[] { Integer.valueOf(this.minecraftServer.getMaxBuildHeight())}); - - chatmessage.getChatModifier().setColor(EnumChatFormat.RED); - this.player.playerConnection.sendPacket(new PacketPlayOutChat(chatmessage)); - flag = true; - } else { - // CraftBukkit start - Check if we can actually do something over this large a distance - Location eyeLoc = this.getPlayer().getEyeLocation(); - double reachDistance = NumberConversions.square(eyeLoc.getX() - i) + NumberConversions.square(eyeLoc.getY() - j) + NumberConversions.square(eyeLoc.getZ() - k); - if (reachDistance > (this.getPlayer().getGameMode() == org.bukkit.GameMode.CREATIVE ? CREATIVE_PLACE_DISTANCE_SQUARED : SURVIVAL_PLACE_DISTANCE_SQUARED)) { - return; - } - - if (!this.player.playerInteractManager.interact(this.player, worldserver, itemstack, i, j, k, l, packetplayinblockplace.h(), packetplayinblockplace.i(), packetplayinblockplace.j())) { - always = true; // force PacketPlayOutSetSlot to be sent to client to update ItemStack count - } - // CraftBukkit end - - flag = true; - } - - if (flag) { - this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(i, j, k, worldserver)); - if (l == 0) { - --j; - } - - if (l == 1) { - ++j; - } - - if (l == 2) { - --k; - } - - if (l == 3) { - ++k; - } - - if (l == 4) { - --i; - } - - if (l == 5) { - ++i; - } - - this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(i, j, k, worldserver)); - } - - itemstack = this.player.inventory.getItemInHand(); - if (itemstack != null && itemstack.count == 0) { - this.player.inventory.items[this.player.inventory.itemInHandIndex] = null; - itemstack = null; - } - - if (itemstack == null || itemstack.n() == 0) { - this.player.g = true; - this.player.inventory.items[this.player.inventory.itemInHandIndex] = ItemStack.b(this.player.inventory.items[this.player.inventory.itemInHandIndex]); - Slot slot = this.player.activeContainer.getSlot((IInventory) this.player.inventory, this.player.inventory.itemInHandIndex); - - this.player.activeContainer.b(); - this.player.g = 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(), packetplayinblockplace.getItemStack()) || always) { - this.sendPacket(new PacketPlayOutSetSlot(this.player.activeContainer.windowId, slot.rawSlotIndex, this.player.inventory.getItemInHand())); - } - } - } - - public void a(IChatBaseComponent ichatbasecomponent) { - // CraftBukkit start - Rarely it would send a disconnect line twice - if (this.processedDisconnect) { - return; - } else { - this.processedDisconnect = true; - } - // CraftBukkit end - c.info(this.player.getName() + " lost connection: " + ichatbasecomponent.c()); // CraftBukkit - Don't toString the component - this.minecraftServer.az(); - // CraftBukkit start - Replace vanilla quit message handling with our own. - /* - ChatMessage chatmessage = new ChatMessage("multiplayer.player.left", new Object[] { this.player.getScoreboardDisplayName()}); - - chatmessage.getChatModifier().setColor(EnumChatFormat.YELLOW); - this.minecraftServer.getPlayerList().sendMessage(chatmessage); - */ - - this.player.n(); - String quitMessage = this.minecraftServer.getPlayerList().disconnect(this.player); - if ((quitMessage != null) && (quitMessage.length() > 0)) { - this.minecraftServer.getPlayerList().sendMessage(CraftChatMessage.fromString(quitMessage)); - } - // CraftBukkit end - if (this.minecraftServer.N() && this.player.getName().equals(this.minecraftServer.M())) { - c.info("Stopping singleplayer server as player logged out"); - this.minecraftServer.safeShutdown(); - } - } - - public void sendPacket(Packet packet) { - if (packet instanceof PacketPlayOutChat) { - PacketPlayOutChat packetplayoutchat = (PacketPlayOutChat) packet; - EnumChatVisibility enumchatvisibility = this.player.getChatFlags(); - - if (enumchatvisibility == EnumChatVisibility.HIDDEN) { - return; - } - - if (enumchatvisibility == EnumChatVisibility.SYSTEM && !packetplayoutchat.d()) { - return; - } - } - - // CraftBukkit start - if (packet == null) { - return; - } else if (packet instanceof PacketPlayOutSpawnPosition) { - PacketPlayOutSpawnPosition packet6 = (PacketPlayOutSpawnPosition) packet; - this.player.compassTarget = new Location(this.getPlayer().getWorld(), packet6.x, packet6.y, packet6.z); - } - // CraftBukkit end - - try { - this.networkManager.handle(packet, new GenericFutureListener[0]); - } catch (Throwable throwable) { - CrashReport crashreport = CrashReport.a(throwable, "Sending packet"); - CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Packet being sent"); - - crashreportsystemdetails.a("Packet class", (Callable) (new CrashReportConnectionPacketClass(this, packet))); - throw new ReportedException(crashreport); - } - } - - public void a(PacketPlayInHeldItemSlot packetplayinhelditemslot) { - // CraftBukkit start - if (this.player.dead) return; - - if (packetplayinhelditemslot.c() >= 0 && packetplayinhelditemslot.c() < PlayerInventory.getHotbarSize()) { - PlayerItemHeldEvent event = new PlayerItemHeldEvent(this.getPlayer(), this.player.inventory.itemInHandIndex, packetplayinhelditemslot.c()); - this.server.getPluginManager().callEvent(event); - if (event.isCancelled()) { - this.sendPacket(new PacketPlayOutHeldItemSlot(this.player.inventory.itemInHandIndex)); - this.player.v(); - return; - } - // CraftBukkit end - - this.player.inventory.itemInHandIndex = packetplayinhelditemslot.c(); - this.player.v(); - } else { - c.warn(this.player.getName() + " tried to set an invalid carried item"); - this.disconnect("Nope!"); // CraftBukkit - } - } - - public void a(PacketPlayInChat packetplayinchat) { - if (this.player.dead || this.player.getChatFlags() == EnumChatVisibility.HIDDEN) { // CraftBukkit - dead men tell no tales - ChatMessage chatmessage = new ChatMessage("chat.cannotSend", new Object[0]); - - chatmessage.getChatModifier().setColor(EnumChatFormat.RED); - this.sendPacket(new PacketPlayOutChat(chatmessage)); - } else { - this.player.v(); - String s = packetplayinchat.c(); - - s = StringUtils.normalizeSpace(s); - - for (int i = 0; i < s.length(); ++i) { - if (!SharedConstants.isAllowedChatCharacter(s.charAt(i))) { - // CraftBukkit start - threadsafety - if (packetplayinchat.a()) { - Waitable waitable = new Waitable() { - @Override - protected Object evaluate() { - PlayerConnection.this.disconnect("Illegal characters in chat"); - return null; - } - }; - - this.minecraftServer.processQueue.add(waitable); - - try { - waitable.get(); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - } catch (ExecutionException e) { - throw new RuntimeException(e); - } - } else { - this.disconnect("Illegal characters in chat"); - } - // CraftBukkit end - return; - } - } - - // CraftBukkit start - if (!packetplayinchat.a()) { - try { - this.minecraftServer.server.playerCommandState = true; - this.handleCommand(s); - } finally { - this.minecraftServer.server.playerCommandState = false; - } - } else if (s.isEmpty()) { - c.warn(this.player.getName() + " tried to send an empty message"); - } else if (getPlayer().isConversing()) { - getPlayer().acceptConversationInput(s); - } else if (this.player.getChatFlags() == EnumChatVisibility.SYSTEM) { // Re-add "Command Only" flag check - ChatMessage chatmessage = new ChatMessage("chat.cannotSend", new Object[0]); - - chatmessage.getChatModifier().setColor(EnumChatFormat.RED); - this.sendPacket(new PacketPlayOutChat(chatmessage)); - } else if (true) { - this.chat(s, true); - // CraftBukkit end - the below is for reference. :) - } else { - ChatMessage chatmessage1 = new ChatMessage("chat.type.text", new Object[] { this.player.getScoreboardDisplayName(), s}); - - this.minecraftServer.getPlayerList().sendMessage(chatmessage1, false); - } - - // CraftBukkit start - replaced with thread safe throttle - // this.chatThrottle += 20; - if (chatSpamField.addAndGet(this, 20) > 200 && !this.minecraftServer.getPlayerList().isOp(this.player.getProfile())) { - if (packetplayinchat.a()) { - Waitable waitable = new Waitable() { - @Override - protected Object evaluate() { - PlayerConnection.this.disconnect("disconnect.spam"); - return null; - } - }; - - this.minecraftServer.processQueue.add(waitable); - - try { - waitable.get(); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - } catch (ExecutionException e) { - throw new RuntimeException(e); - } - } else { - this.disconnect("disconnect.spam"); - } - // CraftBukkit end - } - } - } - - // CraftBukkit start - add method - public void chat(String s, boolean async) { - if (s.isEmpty() || this.player.getChatFlags() == EnumChatVisibility.HIDDEN) { - return; - } - - if (!async && s.startsWith("/")) { - this.handleCommand(s); - } else if (this.player.getChatFlags() == EnumChatVisibility.SYSTEM) { - // Do nothing, this is coming from a plugin - } else { - Player player = this.getPlayer(); - AsyncPlayerChatEvent event = new AsyncPlayerChatEvent(async, player, s, new LazyPlayerSet()); - this.server.getPluginManager().callEvent(event); - - if (PlayerChatEvent.getHandlerList().getRegisteredListeners().length != 0) { - // Evil plugins still listening to deprecated event - final PlayerChatEvent queueEvent = new PlayerChatEvent(player, event.getMessage(), event.getFormat(), event.getRecipients()); - queueEvent.setCancelled(event.isCancelled()); - Waitable waitable = new Waitable() { - @Override - protected Object evaluate() { - org.bukkit.Bukkit.getPluginManager().callEvent(queueEvent); - - if (queueEvent.isCancelled()) { - return null; - } - - String message = String.format(queueEvent.getFormat(), queueEvent.getPlayer().getDisplayName(), queueEvent.getMessage()); - PlayerConnection.this.minecraftServer.console.sendMessage(message); - if (((LazyPlayerSet) queueEvent.getRecipients()).isLazy()) { - for (Object player : PlayerConnection.this.minecraftServer.getPlayerList().players) { - ((EntityPlayer) player).sendMessage(CraftChatMessage.fromString(message)); - } - } else { - for (Player player : queueEvent.getRecipients()) { - player.sendMessage(message); - } - } - return null; - }}; - if (async) { - minecraftServer.processQueue.add(waitable); - } else { - waitable.run(); - } - try { - waitable.get(); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); // This is proper habit for java. If we aren't handling it, pass it on! - } catch (ExecutionException e) { - throw new RuntimeException("Exception processing chat event", e.getCause()); - } - } else { - if (event.isCancelled()) { - return; - } - - s = String.format(event.getFormat(), event.getPlayer().getDisplayName(), event.getMessage()); - minecraftServer.console.sendMessage(s); - if (((LazyPlayerSet) event.getRecipients()).isLazy()) { - for (Object recipient : minecraftServer.getPlayerList().players) { - ((EntityPlayer) recipient).sendMessage(CraftChatMessage.fromString(s)); - } - } else { - for (Player recipient : event.getRecipients()) { - recipient.sendMessage(s); - } - } - } - } - } - // CraftBukkit end - - private void handleCommand(String s) { - // CraftBukkit start - whole method - this.c.info(this.player.getName() + " issued server command: " + s); - - CraftPlayer player = this.getPlayer(); - - PlayerCommandPreprocessEvent event = new PlayerCommandPreprocessEvent(player, s, new LazyPlayerSet()); - this.server.getPluginManager().callEvent(event); - - if (event.isCancelled()) { - return; - } - - try { - if (this.server.dispatchCommand(event.getPlayer(), event.getMessage().substring(1))) { - return; - } - } catch (org.bukkit.command.CommandException ex) { - player.sendMessage(org.bukkit.ChatColor.RED + "An internal error occurred while attempting to perform this command"); - java.util.logging.Logger.getLogger(PlayerConnection.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - return; - } - //this.minecraftServer.getCommandHandler().a(this.player, s); - // CraftBukkit end - } - - public void a(PacketPlayInArmAnimation packetplayinarmanimation) { - if (this.player.dead) return; // CraftBukkit - this.player.v(); - if (packetplayinarmanimation.d() == 1) { - // CraftBukkit start - Raytrace to look for 'rogue armswings' - float f = 1.0F; - float f1 = this.player.lastPitch + (this.player.pitch - this.player.lastPitch) * f; - float f2 = this.player.lastYaw + (this.player.yaw - this.player.lastYaw) * f; - 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(d0, d1, d2); - - float f3 = MathHelper.cos(-f2 * 0.017453292F - 3.1415927F); - float f4 = MathHelper.sin(-f2 * 0.017453292F - 3.1415927F); - float f5 = -MathHelper.cos(-f1 * 0.017453292F); - float f6 = MathHelper.sin(-f1 * 0.017453292F); - float f7 = f4 * f5; - float f8 = f3 * f5; - double d3 = 5.0D; - Vec3D vec3d1 = vec3d.add((double) f7 * d3, (double) f6 * d3, (double) f8 * d3); - MovingObjectPosition movingobjectposition = this.player.world.rayTrace(vec3d, vec3d1, false); - - if (movingobjectposition == null || movingobjectposition.type != EnumMovingObjectType.BLOCK) { - CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_AIR, this.player.inventory.getItemInHand()); - } - - // Arm swing animation - PlayerAnimationEvent event = new PlayerAnimationEvent(this.getPlayer()); - this.server.getPluginManager().callEvent(event); - - if (event.isCancelled()) return; - // CraftBukkit end - - this.player.ba(); - } - } - - public void a(PacketPlayInEntityAction packetplayinentityaction) { - // CraftBukkit start - if (this.player.dead) return; - - this.player.v(); - if (packetplayinentityaction.d() == 1 || packetplayinentityaction.d() == 2) { - PlayerToggleSneakEvent event = new PlayerToggleSneakEvent(this.getPlayer(), packetplayinentityaction.d() == 1); - this.server.getPluginManager().callEvent(event); - - if (event.isCancelled()) { - return; - } - } - - if (packetplayinentityaction.d() == 4 || packetplayinentityaction.d() == 5) { - PlayerToggleSprintEvent event = new PlayerToggleSprintEvent(this.getPlayer(), packetplayinentityaction.d() == 4); - this.server.getPluginManager().callEvent(event); - - if (event.isCancelled()) { - return; - } - } - // CraftBukkit end - - if (packetplayinentityaction.d() == 1) { - this.player.setSneaking(true); - } else if (packetplayinentityaction.d() == 2) { - this.player.setSneaking(false); - } else if (packetplayinentityaction.d() == 4) { - this.player.setSprinting(true); - } else if (packetplayinentityaction.d() == 5) { - this.player.setSprinting(false); - } else if (packetplayinentityaction.d() == 3) { - this.player.a(false, true, true); - //this.checkMovement = false; // CraftBukkit - this is handled in teleport - } else if (packetplayinentityaction.d() == 6) { - if (this.player.vehicle != null && this.player.vehicle instanceof EntityHorse) { - ((EntityHorse) this.player.vehicle).w(packetplayinentityaction.e()); - } - } else if (packetplayinentityaction.d() == 7 && this.player.vehicle != null && this.player.vehicle instanceof EntityHorse) { - ((EntityHorse) this.player.vehicle).g(this.player); - } - } - - public void a(PacketPlayInUseEntity packetplayinuseentity) { - if (this.player.dead) return; // CraftBukkit - WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); - Entity entity = packetplayinuseentity.a((World) worldserver); - - this.player.v(); - if (entity != null) { - boolean flag = this.player.hasLineOfSight(entity); - double d0 = 36.0D; - - if (!flag) { - d0 = 9.0D; - } - - if (this.player.f(entity) < d0) { - ItemStack itemInHand = this.player.inventory.getItemInHand(); // CraftBukkit - if (packetplayinuseentity.c() == EnumEntityUseAction.INTERACT) { - // CraftBukkit start - boolean triggerTagUpdate = itemInHand != null && itemInHand.getItem() == Items.NAME_TAG && entity instanceof EntityInsentient; - boolean triggerChestUpdate = itemInHand != null && itemInHand.getItem() == Item.getItemOf(Blocks.CHEST) && entity instanceof EntityHorse; - boolean triggerLeashUpdate = itemInHand != null && itemInHand.getItem() == Items.LEASH && entity instanceof EntityInsentient; - PlayerInteractEntityEvent event = new PlayerInteractEntityEvent((Player) this.getPlayer(), entity.getBukkitEntity()); - this.server.getPluginManager().callEvent(event); - - if (triggerLeashUpdate && (event.isCancelled() || this.player.inventory.getItemInHand() == null || this.player.inventory.getItemInHand().getItem() != Items.LEASH)) { - // Refresh the current leash state - this.sendPacket(new PacketPlayOutAttachEntity(1, entity, ((EntityInsentient) entity).getLeashHolder())); - } - - if (triggerTagUpdate && (event.isCancelled() || this.player.inventory.getItemInHand() == null || this.player.inventory.getItemInHand().getItem() != Items.NAME_TAG)) { - // Refresh the current entity metadata - this.sendPacket(new PacketPlayOutEntityMetadata(entity.getId(), entity.datawatcher, true)); - } - if (triggerChestUpdate && (event.isCancelled() || this.player.inventory.getItemInHand() == null || this.player.inventory.getItemInHand().getItem() != Item.getItemOf(Blocks.CHEST))) { - this.sendPacket(new PacketPlayOutEntityMetadata(entity.getId(), entity.datawatcher, true)); - } - - if (event.isCancelled()) { - return; - } - // CraftBukkit end - - this.player.q(entity); - - // CraftBukkit start - if (itemInHand != null && itemInHand.count <= -1) { - this.player.updateInventory(this.player.activeContainer); - } - // CraftBukkit end - } else if (packetplayinuseentity.c() == EnumEntityUseAction.ATTACK) { - if (entity instanceof EntityItem || entity instanceof EntityExperienceOrb || entity instanceof EntityArrow || entity == this.player) { - this.disconnect("Attempting to attack an invalid entity"); - this.minecraftServer.warning("Player " + this.player.getName() + " tried to attack an invalid entity"); - return; - } - - this.player.attack(entity); - - // CraftBukkit start - if (itemInHand != null && itemInHand.count <= -1) { - this.player.updateInventory(this.player.activeContainer); - } - // CraftBukkit end - } - } - } - } - - public void a(PacketPlayInClientCommand packetplayinclientcommand) { - this.player.v(); - EnumClientCommand enumclientcommand = packetplayinclientcommand.c(); - - switch (ClientCommandOrdinalWrapper.a[enumclientcommand.ordinal()]) { - case 1: - if (this.player.viewingCredits) { - this.minecraftServer.getPlayerList().changeDimension(this.player, 0, PlayerTeleportEvent.TeleportCause.END_PORTAL); // CraftBukkit - reroute logic through custom portal management - } else if (this.player.r().getWorldData().isHardcore()) { - if (this.minecraftServer.N() && this.player.getName().equals(this.minecraftServer.M())) { - this.player.playerConnection.disconnect("You have died. Game over, man, it\'s game over!"); - this.minecraftServer.U(); - } else { - GameProfileBanEntry gameprofilebanentry = new GameProfileBanEntry(this.player.getProfile(), (Date) null, "(You just lost the game)", (Date) null, "Death in Hardcore"); - - this.minecraftServer.getPlayerList().getProfileBans().add(gameprofilebanentry); - this.player.playerConnection.disconnect("You have died. Game over, man, it\'s game over!"); - } - } else { - if (this.player.getHealth() > 0.0F) { - return; - } - - this.player = this.minecraftServer.getPlayerList().moveToWorld(this.player, 0, false); - } - break; - - case 2: - this.player.getStatisticManager().a(this.player); - break; - - case 3: - this.player.a((Statistic) AchievementList.f); - } - } - - public void a(PacketPlayInCloseWindow packetplayinclosewindow) { - if (this.player.dead) return; // CraftBukkit - - CraftEventFactory.handleInventoryCloseEvent(this.player); // CraftBukkit - - this.player.m(); - } - - public void a(PacketPlayInWindowClick packetplayinwindowclick) { - if (this.player.dead) return; // CraftBukkit - - this.player.v(); - if (this.player.activeContainer.windowId == packetplayinwindowclick.c() && this.player.activeContainer.c(this.player)) { - // CraftBukkit start - Call InventoryClickEvent - if (packetplayinwindowclick.d() < -1 && packetplayinwindowclick.d() != -999) { - return; - } - - InventoryView inventory = this.player.activeContainer.getBukkitView(); - SlotType type = CraftInventoryView.getSlotType(inventory, packetplayinwindowclick.d()); - - InventoryClickEvent event = null; - ClickType click = ClickType.UNKNOWN; - InventoryAction action = InventoryAction.UNKNOWN; - - ItemStack itemstack = null; - - if (packetplayinwindowclick.d() == -1) { - type = SlotType.OUTSIDE; // override - click = packetplayinwindowclick.e() == 0 ? ClickType.WINDOW_BORDER_LEFT : ClickType.WINDOW_BORDER_RIGHT; - action = InventoryAction.NOTHING; - } else if (packetplayinwindowclick.h() == 0) { - if (packetplayinwindowclick.e() == 0) { - click = ClickType.LEFT; - } else if (packetplayinwindowclick.e() == 1) { - click = ClickType.RIGHT; - } - if (packetplayinwindowclick.e() == 0 || packetplayinwindowclick.e() == 1) { - action = InventoryAction.NOTHING; // Don't want to repeat ourselves - if (packetplayinwindowclick.d() == -999) { - if (player.inventory.getCarried() != null) { - action = packetplayinwindowclick.e() == 0 ? InventoryAction.DROP_ALL_CURSOR : InventoryAction.DROP_ONE_CURSOR; - } - } else { - Slot slot = this.player.activeContainer.getSlot(packetplayinwindowclick.d()); - if (slot != null) { - ItemStack clickedItem = slot.getItem(); - ItemStack cursor = player.inventory.getCarried(); - if (clickedItem == null) { - if (cursor != null) { - action = packetplayinwindowclick.e() == 0 ? InventoryAction.PLACE_ALL : InventoryAction.PLACE_ONE; - } - } else if (slot.isAllowed(player)) { - if (cursor == null) { - action = packetplayinwindowclick.e() == 0 ? InventoryAction.PICKUP_ALL : InventoryAction.PICKUP_HALF; - } else if (slot.isAllowed(cursor)) { - if (clickedItem.doMaterialsMatch(cursor) && ItemStack.equals(clickedItem, cursor)) { - int toPlace = packetplayinwindowclick.e() == 0 ? cursor.count : 1; - toPlace = Math.min(toPlace, clickedItem.getMaxStackSize() - clickedItem.count); - toPlace = Math.min(toPlace, slot.inventory.getMaxStackSize() - clickedItem.count); - if (toPlace == 1) { - action = InventoryAction.PLACE_ONE; - } else if (toPlace == cursor.count) { - action = InventoryAction.PLACE_ALL; - } else if (toPlace < 0) { - action = toPlace != -1 ? InventoryAction.PICKUP_SOME : InventoryAction.PICKUP_ONE; // this happens with oversized stacks - } else if (toPlace != 0) { - action = InventoryAction.PLACE_SOME; - } - } else if (cursor.count <= slot.getMaxStackSize()) { - action = InventoryAction.SWAP_WITH_CURSOR; - } - } else if (cursor.getItem() == clickedItem.getItem() && (!cursor.usesData() || cursor.getData() == clickedItem.getData()) && ItemStack.equals(cursor, clickedItem)) { - if (clickedItem.count >= 0) { - if (clickedItem.count + cursor.count <= cursor.getMaxStackSize()) { - // As of 1.5, this is result slots only - action = InventoryAction.PICKUP_ALL; - } - } - } - } - } - } - } - } else if (packetplayinwindowclick.h() == 1) { - if (packetplayinwindowclick.e() == 0) { - click = ClickType.SHIFT_LEFT; - } else if (packetplayinwindowclick.e() == 1) { - click = ClickType.SHIFT_RIGHT; - } - if (packetplayinwindowclick.e() == 0 || packetplayinwindowclick.e() == 1) { - if (packetplayinwindowclick.d() < 0) { - action = InventoryAction.NOTHING; - } else { - Slot slot = this.player.activeContainer.getSlot(packetplayinwindowclick.d()); - if (slot != null && slot.isAllowed(this.player) && slot.hasItem()) { - action = InventoryAction.MOVE_TO_OTHER_INVENTORY; - } else { - action = InventoryAction.NOTHING; - } - } - } - } else if (packetplayinwindowclick.h() == 2) { - if (packetplayinwindowclick.e() >= 0 && packetplayinwindowclick.e() < 9) { - click = ClickType.NUMBER_KEY; - Slot clickedSlot = this.player.activeContainer.getSlot(packetplayinwindowclick.d()); - if (clickedSlot.isAllowed(player)) { - ItemStack hotbar = this.player.inventory.getItem(packetplayinwindowclick.e()); - boolean canCleanSwap = hotbar == null || (clickedSlot.inventory == player.inventory && clickedSlot.isAllowed(hotbar)); // the slot will accept the hotbar item - if (clickedSlot.hasItem()) { - if (canCleanSwap) { - action = InventoryAction.HOTBAR_SWAP; - } else { - int firstEmptySlot = player.inventory.getFirstEmptySlotIndex(); - if (firstEmptySlot > -1) { - action = InventoryAction.HOTBAR_MOVE_AND_READD; - } else { - action = InventoryAction.NOTHING; // This is not sane! Mojang: You should test for other slots of same type - } - } - } else if (!clickedSlot.hasItem() && hotbar != null && clickedSlot.isAllowed(hotbar)) { - action = InventoryAction.HOTBAR_SWAP; - } else { - action = InventoryAction.NOTHING; - } - } else { - action = InventoryAction.NOTHING; - } - // Special constructor for number key - event = new InventoryClickEvent(inventory, type, packetplayinwindowclick.d(), click, action, packetplayinwindowclick.e()); - } - } else if (packetplayinwindowclick.h() == 3) { - if (packetplayinwindowclick.e() == 2) { - click = ClickType.MIDDLE; - if (packetplayinwindowclick.d() == -999) { - action = InventoryAction.NOTHING; - } else { - Slot slot = this.player.activeContainer.getSlot(packetplayinwindowclick.d()); - if (slot != null && slot.hasItem() && player.abilities.canInstantlyBuild && player.inventory.getCarried() == null) { - action = InventoryAction.CLONE_STACK; - } else { - action = InventoryAction.NOTHING; - } - } - } else { - click = ClickType.UNKNOWN; - action = InventoryAction.UNKNOWN; - } - } else if (packetplayinwindowclick.h() == 4) { - if (packetplayinwindowclick.d() >= 0) { - if (packetplayinwindowclick.e() == 0) { - click = ClickType.DROP; - Slot slot = this.player.activeContainer.getSlot(packetplayinwindowclick.d()); - if (slot != null && slot.hasItem() && slot.isAllowed(player) && slot.getItem() != null && slot.getItem().getItem() != Item.getItemOf(Blocks.AIR)) { - action = InventoryAction.DROP_ONE_SLOT; - } else { - action = InventoryAction.NOTHING; - } - } else if (packetplayinwindowclick.e() == 1) { - click = ClickType.CONTROL_DROP; - Slot slot = this.player.activeContainer.getSlot(packetplayinwindowclick.d()); - if (slot != null && slot.hasItem() && slot.isAllowed(player) && slot.getItem() != null && slot.getItem().getItem() != Item.getItemOf(Blocks.AIR)) { - action = InventoryAction.DROP_ALL_SLOT; - } else { - action = InventoryAction.NOTHING; - } - } - } else { - // Sane default (because this happens when they are holding nothing. Don't ask why.) - click = ClickType.LEFT; - if (packetplayinwindowclick.e() == 1) { - click = ClickType.RIGHT; - } - action = InventoryAction.NOTHING; - } - } else if (packetplayinwindowclick.h() == 5) { - itemstack = this.player.activeContainer.clickItem(packetplayinwindowclick.d(), packetplayinwindowclick.e(), 5, this.player); - } else if (packetplayinwindowclick.h() == 6) { - click = ClickType.DOUBLE_CLICK; - action = InventoryAction.NOTHING; - if (packetplayinwindowclick.d() >= 0 && this.player.inventory.getCarried() != null) { - ItemStack cursor = this.player.inventory.getCarried(); - action = InventoryAction.NOTHING; - // Quick check for if we have any of the item - if (inventory.getTopInventory().contains(org.bukkit.Material.getMaterial(Item.getId(cursor.getItem()))) || inventory.getBottomInventory().contains(org.bukkit.Material.getMaterial(Item.getId(cursor.getItem())))) { - action = InventoryAction.COLLECT_TO_CURSOR; - } - } - } - // TODO check on updates - - if (packetplayinwindowclick.h() != 5) { - if (click == ClickType.NUMBER_KEY) { - event = new InventoryClickEvent(inventory, type, packetplayinwindowclick.d(), click, action, packetplayinwindowclick.e()); - } else { - event = new InventoryClickEvent(inventory, type, packetplayinwindowclick.d(), click, action); - } - - org.bukkit.inventory.Inventory top = inventory.getTopInventory(); - if (packetplayinwindowclick.d() == 0 && top instanceof CraftingInventory) { - org.bukkit.inventory.Recipe recipe = ((CraftingInventory) top).getRecipe(); - if (recipe != null) { - if (click == ClickType.NUMBER_KEY) { - event = new CraftItemEvent(recipe, inventory, type, packetplayinwindowclick.d(), click, action, packetplayinwindowclick.e()); - } else { - event = new CraftItemEvent(recipe, inventory, type, packetplayinwindowclick.d(), click, action); - } - } - } - - server.getPluginManager().callEvent(event); - - switch (event.getResult()) { - case ALLOW: - case DEFAULT: - itemstack = this.player.activeContainer.clickItem(packetplayinwindowclick.d(), packetplayinwindowclick.e(), packetplayinwindowclick.h(), this.player); - break; - case DENY: - /* Needs enum constructor in InventoryAction - if (action.modifiesOtherSlots()) { - - } else { - if (action.modifiesCursor()) { - this.player.playerConnection.sendPacket(new Packet103SetSlot(-1, -1, this.player.inventory.getCarried())); - } - if (action.modifiesClicked()) { - this.player.playerConnection.sendPacket(new Packet103SetSlot(this.player.activeContainer.windowId, packet102windowclick.slot, this.player.activeContainer.getSlot(packet102windowclick.slot).getItem())); - } - }*/ - switch (action) { - // Modified other slots - case PICKUP_ALL: - case MOVE_TO_OTHER_INVENTORY: - case HOTBAR_MOVE_AND_READD: - case HOTBAR_SWAP: - case COLLECT_TO_CURSOR: - case UNKNOWN: - this.player.updateInventory(this.player.activeContainer); - break; - // Modified cursor and clicked - case PICKUP_SOME: - case PICKUP_HALF: - case PICKUP_ONE: - case PLACE_ALL: - case PLACE_SOME: - case PLACE_ONE: - case SWAP_WITH_CURSOR: - this.player.playerConnection.sendPacket(new PacketPlayOutSetSlot(-1, -1, this.player.inventory.getCarried())); - this.player.playerConnection.sendPacket(new PacketPlayOutSetSlot(this.player.activeContainer.windowId, packetplayinwindowclick.d(), this.player.activeContainer.getSlot(packetplayinwindowclick.d()).getItem())); - break; - // Modified clicked only - case DROP_ALL_SLOT: - case DROP_ONE_SLOT: - this.player.playerConnection.sendPacket(new PacketPlayOutSetSlot(this.player.activeContainer.windowId, packetplayinwindowclick.d(), this.player.activeContainer.getSlot(packetplayinwindowclick.d()).getItem())); - break; - // Modified cursor only - case DROP_ALL_CURSOR: - case DROP_ONE_CURSOR: - case CLONE_STACK: - this.player.playerConnection.sendPacket(new PacketPlayOutSetSlot(-1, -1, this.player.inventory.getCarried())); - break; - // Nothing - case NOTHING: - break; - } - return; - } - } - // CraftBukkit end - - if (ItemStack.matches(packetplayinwindowclick.g(), itemstack)) { - this.player.playerConnection.sendPacket(new PacketPlayOutTransaction(packetplayinwindowclick.c(), packetplayinwindowclick.f(), true)); - this.player.g = true; - this.player.activeContainer.b(); - this.player.broadcastCarriedItem(); - this.player.g = false; - } else { - this.n.a(this.player.activeContainer.windowId, Short.valueOf(packetplayinwindowclick.f())); - this.player.playerConnection.sendPacket(new PacketPlayOutTransaction(packetplayinwindowclick.c(), packetplayinwindowclick.f(), false)); - this.player.activeContainer.a(this.player, false); - ArrayList arraylist = new ArrayList(); - - for (int i = 0; i < this.player.activeContainer.c.size(); ++i) { - arraylist.add(((Slot) this.player.activeContainer.c.get(i)).getItem()); - } - - this.player.a(this.player.activeContainer, arraylist); - - // CraftBukkit start - Send a Set Slot to update the crafting result slot - if (type == SlotType.RESULT && itemstack != null) { - this.player.playerConnection.sendPacket(new PacketPlayOutSetSlot(this.player.activeContainer.windowId, 0, itemstack)); - } - // CraftBukkit end - } - } - } - - public void a(PacketPlayInEnchantItem packetplayinenchantitem) { - this.player.v(); - if (this.player.activeContainer.windowId == packetplayinenchantitem.c() && this.player.activeContainer.c(this.player)) { - this.player.activeContainer.a(this.player, packetplayinenchantitem.d()); - this.player.activeContainer.b(); - } - } - - public void a(PacketPlayInSetCreativeSlot packetplayinsetcreativeslot) { - if (this.player.playerInteractManager.isCreative()) { - boolean flag = packetplayinsetcreativeslot.c() < 0; - ItemStack itemstack = packetplayinsetcreativeslot.getItemStack(); - boolean flag1 = packetplayinsetcreativeslot.c() >= 1 && packetplayinsetcreativeslot.c() < 36 + PlayerInventory.getHotbarSize(); - // CraftBukkit - Add invalidItems check - boolean flag2 = itemstack == null || itemstack.getItem() != null && !invalidItems.contains(Item.getId(itemstack.getItem())); - boolean flag3 = itemstack == null || itemstack.getData() >= 0 && itemstack.count <= 64 && itemstack.count > 0; - - // CraftBukkit start - Call click event - if (flag || (flag1 && !ItemStack.matches(this.player.defaultContainer.getSlot(packetplayinsetcreativeslot.c()).getItem(), packetplayinsetcreativeslot.getItemStack()))) { // Insist on valid slot - - org.bukkit.entity.HumanEntity player = this.player.getBukkitEntity(); - InventoryView inventory = new CraftInventoryView(player, player.getInventory(), this.player.defaultContainer); - org.bukkit.inventory.ItemStack item = CraftItemStack.asBukkitCopy(packetplayinsetcreativeslot.getItemStack()); - - SlotType type = SlotType.QUICKBAR; - if (flag) { - type = SlotType.OUTSIDE; - } else if (packetplayinsetcreativeslot.c() < 36) { - if (packetplayinsetcreativeslot.c() >= 5 && packetplayinsetcreativeslot.c() < 9) { - type = SlotType.ARMOR; - } else { - type = SlotType.CONTAINER; - } - } - InventoryCreativeEvent event = new InventoryCreativeEvent(inventory, type, flag ? -999 : packetplayinsetcreativeslot.c(), item); - server.getPluginManager().callEvent(event); - - itemstack = CraftItemStack.asNMSCopy(event.getCursor()); - - switch (event.getResult()) { - case ALLOW: - // Plugin cleared the id / stacksize checks - flag2 = flag3 = true; - break; - case DEFAULT: - break; - case DENY: - // Reset the slot - if (packetplayinsetcreativeslot.c() >= 0) { - this.player.playerConnection.sendPacket(new PacketPlayOutSetSlot(this.player.defaultContainer.windowId, packetplayinsetcreativeslot.c(), this.player.defaultContainer.getSlot(packetplayinsetcreativeslot.c()).getItem())); - this.player.playerConnection.sendPacket(new PacketPlayOutSetSlot(-1, -1, null)); - } - return; - } - } - // CraftBukkit end - - if (flag1 && flag2 && flag3) { - if (itemstack == null) { - this.player.defaultContainer.setItem(packetplayinsetcreativeslot.c(), (ItemStack) null); - } else { - this.player.defaultContainer.setItem(packetplayinsetcreativeslot.c(), itemstack); - } - - this.player.defaultContainer.a(this.player, true); - } else if (flag && flag2 && flag3 && this.x < 200) { - this.x += 20; - EntityItem entityitem = this.player.drop(itemstack, true); - - if (entityitem != null) { - entityitem.e(); - } - } - } - } - - public void a(PacketPlayInTransaction packetplayintransaction) { - if (this.player.dead) return; // CraftBukkit - Short oshort = (Short) this.n.get(this.player.activeContainer.windowId); - - if (oshort != null && packetplayintransaction.d() == oshort.shortValue() && this.player.activeContainer.windowId == packetplayintransaction.c() && !this.player.activeContainer.c(this.player)) { - this.player.activeContainer.a(this.player, true); - } - } - - public void a(PacketPlayInUpdateSign packetplayinupdatesign) { - if (this.player.dead) return; // CraftBukkit - - this.player.v(); - WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); - - if (worldserver.isLoaded(packetplayinupdatesign.c(), packetplayinupdatesign.d(), packetplayinupdatesign.e())) { - TileEntity tileentity = worldserver.getTileEntity(packetplayinupdatesign.c(), packetplayinupdatesign.d(), packetplayinupdatesign.e()); - - if (tileentity instanceof TileEntitySign) { - TileEntitySign tileentitysign = (TileEntitySign) tileentity; - - if (!tileentitysign.a() || tileentitysign.b() != this.player) { - this.minecraftServer.warning("Player " + this.player.getName() + " just tried to change non-editable sign"); - this.sendPacket(new PacketPlayOutUpdateSign(packetplayinupdatesign.c(), packetplayinupdatesign.d(), packetplayinupdatesign.e(), tileentitysign.lines)); // CraftBukkit - return; - } - } - - int i; - int j; - - for (j = 0; j < 4; ++j) { - boolean flag = true; - - if (packetplayinupdatesign.f()[j].length() > 15) { - flag = false; - } else { - for (i = 0; i < packetplayinupdatesign.f()[j].length(); ++i) { - if (!SharedConstants.isAllowedChatCharacter(packetplayinupdatesign.f()[j].charAt(i))) { - flag = false; - } - } - } - - if (!flag) { - packetplayinupdatesign.f()[j] = "!?"; - } - } - - if (tileentity instanceof TileEntitySign) { - j = packetplayinupdatesign.c(); - int k = packetplayinupdatesign.d(); - - i = packetplayinupdatesign.e(); - TileEntitySign tileentitysign1 = (TileEntitySign) tileentity; - - // CraftBukkit start - Player player = this.server.getPlayer(this.player); - SignChangeEvent event = new SignChangeEvent((org.bukkit.craftbukkit.block.CraftBlock) player.getWorld().getBlockAt(j, k, i), this.server.getPlayer(this.player), packetplayinupdatesign.f()); - this.server.getPluginManager().callEvent(event); - - if (!event.isCancelled()) { - tileentitysign1.lines = org.bukkit.craftbukkit.block.CraftSign.sanitizeLines(event.getLines()); - tileentitysign1.isEditable = false; - } - // System.arraycopy(packetplayinupdatesign.f(), 0, tileentitysign1.lines, 0, 4); - // CraftBukkit end - - tileentitysign1.update(); - worldserver.notify(j, k, i); - } - } - } - - public void a(PacketPlayInKeepAlive packetplayinkeepalive) { - if (packetplayinkeepalive.c() == this.h) { - int i = (int) (this.d() - this.i); - - this.player.ping = (this.player.ping * 3 + i) / 4; - } - } - - private long d() { - return System.nanoTime() / 1000000L; - } - - public void a(PacketPlayInAbilities packetplayinabilities) { - // CraftBukkit start - if (this.player.abilities.canFly && this.player.abilities.isFlying != packetplayinabilities.isFlying()) { - PlayerToggleFlightEvent event = new PlayerToggleFlightEvent(this.server.getPlayer(this.player), packetplayinabilities.isFlying()); - this.server.getPluginManager().callEvent(event); - if (!event.isCancelled()) { - this.player.abilities.isFlying = packetplayinabilities.isFlying(); // Actually set the player's flying status - } else { - this.player.updateAbilities(); // Tell the player their ability was reverted - } - } - // CraftBukkit end - } - - public void a(PacketPlayInTabComplete packetplayintabcomplete) { - ArrayList arraylist = Lists.newArrayList(); - Iterator iterator = this.minecraftServer.a(this.player, packetplayintabcomplete.c()).iterator(); - - while (iterator.hasNext()) { - String s = (String) iterator.next(); - - arraylist.add(s); - } - - this.player.playerConnection.sendPacket(new PacketPlayOutTabComplete((String[]) arraylist.toArray(new String[arraylist.size()]))); - } - - public void a(PacketPlayInSettings packetplayinsettings) { - this.player.a(packetplayinsettings); - } - - public void a(PacketPlayInCustomPayload packetplayincustompayload) { - PacketDataSerializer packetdataserializer; - ItemStack itemstack; - ItemStack itemstack1; - - // CraftBukkit start - Ignore empty payloads - if (packetplayincustompayload.length <= 0) { - return; - } - // CraftBukkit end - - if ("MC|BEdit".equals(packetplayincustompayload.c())) { - packetdataserializer = new PacketDataSerializer(Unpooled.wrappedBuffer(packetplayincustompayload.e())); - - try { - itemstack = packetdataserializer.c(); - if (itemstack != null) { - if (!ItemBookAndQuill.a(itemstack.getTag())) { - throw new IOException("Invalid book tag!"); - } - - itemstack1 = this.player.inventory.getItemInHand(); - if (itemstack1 == null) { - return; - } - - if (itemstack.getItem() == Items.BOOK_AND_QUILL && itemstack.getItem() == itemstack1.getItem()) { - CraftEventFactory.handleEditBookEvent(player, itemstack); // CraftBukkit - } - - return; - } - // CraftBukkit start - } catch (Exception exception) { - c.error("Couldn\'t handle book info", exception); - this.disconnect("Invalid book data!"); - return; - // CraftBukkit end - } finally { - packetdataserializer.release(); - } - - return; - } else if ("MC|BSign".equals(packetplayincustompayload.c())) { - packetdataserializer = new PacketDataSerializer(Unpooled.wrappedBuffer(packetplayincustompayload.e())); - - try { - itemstack = packetdataserializer.c(); - if (itemstack != null) { - if (!ItemWrittenBook.a(itemstack.getTag())) { - throw new IOException("Invalid book tag!"); - } - - itemstack1 = this.player.inventory.getItemInHand(); - if (itemstack1 == null) { - return; - } - - if (itemstack.getItem() == Items.WRITTEN_BOOK && itemstack1.getItem() == Items.BOOK_AND_QUILL) { - CraftEventFactory.handleEditBookEvent(player, itemstack); // CraftBukkit - } - - return; - } - // CraftBukkit start - } catch (Throwable exception1) { - c.error("Couldn\'t sign book", exception1); - this.disconnect("Invalid book data!"); - // CraftBukkit end - return; - } finally { - packetdataserializer.release(); - } - - return; - } else { - int i; - DataInputStream datainputstream; - - if ("MC|TrSel".equals(packetplayincustompayload.c())) { - try { - datainputstream = new DataInputStream(new ByteArrayInputStream(packetplayincustompayload.e())); - i = datainputstream.readInt(); - Container container = this.player.activeContainer; - - if (container instanceof ContainerMerchant) { - ((ContainerMerchant) container).e(i); - } - // CraftBukkit start - } catch (Throwable exception2) { - c.error("Couldn\'t select trade", exception2); - this.disconnect("Invalid trade data!"); - // CraftBukkit end - } - } else if ("MC|AdvCdm".equals(packetplayincustompayload.c())) { - if (!this.minecraftServer.getEnableCommandBlock()) { - this.player.sendMessage(new ChatMessage("advMode.notEnabled", new Object[0])); - } else if (this.player.a(2, "") && this.player.abilities.canInstantlyBuild) { - packetdataserializer = new PacketDataSerializer(Unpooled.wrappedBuffer(packetplayincustompayload.e())); - - try { - byte b0 = packetdataserializer.readByte(); - CommandBlockListenerAbstract commandblocklistenerabstract = null; - - if (b0 == 0) { - TileEntity tileentity = this.player.world.getTileEntity(packetdataserializer.readInt(), packetdataserializer.readInt(), packetdataserializer.readInt()); - - if (tileentity instanceof TileEntityCommand) { - commandblocklistenerabstract = ((TileEntityCommand) tileentity).getCommandBlock(); - } - } else if (b0 == 1) { - Entity entity = this.player.world.getEntity(packetdataserializer.readInt()); - - if (entity instanceof EntityMinecartCommandBlock) { - commandblocklistenerabstract = ((EntityMinecartCommandBlock) entity).getCommandBlock(); - } - } - - String s = packetdataserializer.c(packetdataserializer.readableBytes()); - - if (commandblocklistenerabstract != null) { - commandblocklistenerabstract.setCommand(s); - commandblocklistenerabstract.e(); - this.player.sendMessage(new ChatMessage("advMode.setCommand.success", new Object[] { s})); - } - // CraftBukkit start - } catch (Throwable exception3) { - c.error("Couldn\'t set command block", exception3); - this.disconnect("Invalid CommandBlock data!"); - // CraftBukkit end - } finally { - packetdataserializer.release(); - } - } else { - this.player.sendMessage(new ChatMessage("advMode.notAllowed", new Object[0])); - } - } else if ("MC|Beacon".equals(packetplayincustompayload.c())) { - if (this.player.activeContainer instanceof ContainerBeacon) { - try { - datainputstream = new DataInputStream(new ByteArrayInputStream(packetplayincustompayload.e())); - i = datainputstream.readInt(); - int j = datainputstream.readInt(); - ContainerBeacon containerbeacon = (ContainerBeacon) this.player.activeContainer; - Slot slot = containerbeacon.getSlot(0); - - if (slot.hasItem()) { - slot.a(1); - TileEntityBeacon tileentitybeacon = containerbeacon.e(); - - tileentitybeacon.d(i); - tileentitybeacon.e(j); - tileentitybeacon.update(); - } - // CraftBukkit start - } catch (Throwable exception4) { - c.error("Couldn\'t set beacon", exception4); - this.disconnect("Invalid beacon data!"); - // CraftBukkit end - } - } - } else if ("MC|ItemName".equals(packetplayincustompayload.c()) && this.player.activeContainer instanceof ContainerAnvil) { - ContainerAnvil containeranvil = (ContainerAnvil) this.player.activeContainer; - - if (packetplayincustompayload.e() != null && packetplayincustompayload.e().length >= 1) { - String s1 = SharedConstants.a(new String(packetplayincustompayload.e(), Charsets.UTF_8)); - - if (s1.length() <= 30) { - containeranvil.a(s1); - } - } else { - containeranvil.a(""); - } - } - // CraftBukkit start - else if (packetplayincustompayload.c().equals("REGISTER")) { - try { - String channels = new String(packetplayincustompayload.e(), "UTF8"); - for (String channel : channels.split("\0")) { - getPlayer().addChannel(channel); - } - } catch (UnsupportedEncodingException ex) { - throw new AssertionError(ex); - } - } else if (packetplayincustompayload.c().equals("UNREGISTER")) { - try { - String channels = new String(packetplayincustompayload.e(), "UTF8"); - for (String channel : channels.split("\0")) { - getPlayer().removeChannel(channel); - } - } catch (UnsupportedEncodingException ex) { - throw new AssertionError(ex); - } - } else { - server.getMessenger().dispatchIncomingMessage(player.getBukkitEntity(), packetplayincustompayload.c(), packetplayincustompayload.e()); - } - // CraftBukkit end - } - } - - public void a(EnumProtocol enumprotocol, EnumProtocol enumprotocol1) { - if (enumprotocol1 != EnumProtocol.PLAY) { - throw new IllegalStateException("Unexpected change in protocol!"); - } - } - - // CraftBukkit start - Add "isDisconnected" method - public final boolean isDisconnected() { - return !this.player.joining && !NetworkManager.a(this.networkManager).config().isAutoRead(); - } - // CraftBukkit end -} diff --git a/src/main/java/net/minecraft/server/PlayerDatFileConverter.java b/src/main/java/net/minecraft/server/PlayerDatFileConverter.java deleted file mode 100644 index 27651b5a..00000000 --- a/src/main/java/net/minecraft/server/PlayerDatFileConverter.java +++ /dev/null @@ -1,98 +0,0 @@ -package net.minecraft.server; - -import java.io.File; -import java.util.UUID; - -import net.minecraft.util.com.mojang.authlib.GameProfile; -import net.minecraft.util.com.mojang.authlib.ProfileLookupCallback; -import net.minecraft.util.com.mojang.authlib.yggdrasil.ProfileNotFoundException; - -final class PlayerDatFileConverter implements ProfileLookupCallback { - - final DedicatedServer a; - final File b; - final File c; - final File d; - final String[] e; - - PlayerDatFileConverter(DedicatedServer dedicatedserver, File file1, File file2, File file3, String[] astring) { - this.a = dedicatedserver; - this.b = file1; - this.c = file2; - this.d = file3; - this.e = astring; - } - - public void onProfileLookupSucceeded(GameProfile gameprofile) { - this.a.getUserCache().a(gameprofile); - UUID uuid = gameprofile.getId(); - - if (uuid == null) { - throw new FileConversionException("Missing UUID for user profile " + gameprofile.getName(), (PredicateEmptyList) null); - } else { - this.a(this.b, this.a(gameprofile), uuid.toString()); - } - } - - public void onProfileLookupFailed(GameProfile gameprofile, Exception exception) { - NameReferencingFileConverter.a().warn("Could not lookup user uuid for " + gameprofile.getName(), exception); - if (exception instanceof ProfileNotFoundException) { - String s = this.a(gameprofile); - - this.a(this.c, s, s); - } else { - throw new FileConversionException("Could not request user " + gameprofile.getName() + " from backend systems", exception, (PredicateEmptyList) null); - } - } - - private void a(File file1, String s, String s1) { - File file2 = new File(this.d, s + ".dat"); - File file3 = new File(file1, s1 + ".dat"); - - // CraftBukkit start - Use old file name to seed lastKnownName - NBTTagCompound root = null; - - try { - root = NBTCompressedStreamTools.a(new java.io.FileInputStream(file2)); - } catch (Exception exception) { - exception.printStackTrace(); - } - - if (root != null) { - if (!root.hasKey("bukkit")) { - root.set("bukkit", new NBTTagCompound()); - } - NBTTagCompound data = root.getCompound("bukkit"); - data.setString("lastKnownName", s); - - try { - NBTCompressedStreamTools.a(root, new java.io.FileOutputStream(file2)); - } catch (Exception exception) { - exception.printStackTrace(); - } - } - // CraftBukkit end - - NameReferencingFileConverter.a(file1); - if (!file2.renameTo(file3)) { - throw new FileConversionException("Could not convert file for " + s, (PredicateEmptyList) null); - } - } - - private String a(GameProfile gameprofile) { - String s = null; - - for (int i = 0; i < this.e.length; ++i) { - if (this.e[i] != null && this.e[i].equalsIgnoreCase(gameprofile.getName())) { - s = this.e[i]; - break; - } - } - - if (s == null) { - throw new FileConversionException("Could not find the filename for " + gameprofile.getName() + " anymore", (PredicateEmptyList) null); - } else { - return s; - } - } -} diff --git a/src/main/java/net/minecraft/server/PlayerInteractManager.java b/src/main/java/net/minecraft/server/PlayerInteractManager.java deleted file mode 100644 index 7607155f..00000000 --- a/src/main/java/net/minecraft/server/PlayerInteractManager.java +++ /dev/null @@ -1,411 +0,0 @@ -package net.minecraft.server; - -// CraftBukkit start -import org.bukkit.event.block.BlockBreakEvent; -import org.bukkit.craftbukkit.event.CraftEventFactory; -import org.bukkit.event.Event; -import org.bukkit.event.block.Action; -import org.bukkit.event.player.PlayerInteractEvent; -// CraftBukkit end - -public class PlayerInteractManager { - - public World world; - public EntityPlayer player; - private EnumGamemode gamemode; - private boolean d; - private int lastDigTick; - private int f; - private int g; - private int h; - private int currentTick; - private boolean j; - private int k; - private int l; - private int m; - private int n; - private int o; - - public PlayerInteractManager(World world) { - this.gamemode = EnumGamemode.NONE; - this.o = -1; - this.world = world; - } - - public void setGameMode(EnumGamemode enumgamemode) { - this.gamemode = enumgamemode; - enumgamemode.a(this.player.abilities); - this.player.updateAbilities(); - } - - public EnumGamemode getGameMode() { - return this.gamemode; - } - - public boolean isCreative() { - return this.gamemode.d(); - } - - public void b(EnumGamemode enumgamemode) { - if (this.gamemode == EnumGamemode.NONE) { - this.gamemode = enumgamemode; - } - - this.setGameMode(this.gamemode); - } - - public void a() { - this.currentTick = MinecraftServer.currentTick; // CraftBukkit - float f; - int i; - - if (this.j) { - int j = this.currentTick - this.n; - Block block = this.world.getType(this.k, this.l, this.m); - - if (block.getMaterial() == Material.AIR) { - this.j = false; - } else { - f = block.getDamage(this.player, this.player.world, this.k, this.l, this.m) * (float) (j + 1); - i = (int) (f * 10.0F); - if (i != this.o) { - this.world.d(this.player.getId(), this.k, this.l, this.m, i); - this.o = i; - } - - if (f >= 1.0F) { - this.j = false; - this.breakBlock(this.k, this.l, this.m); - } - } - } else if (this.d) { - Block block1 = this.world.getType(this.f, this.g, this.h); - - if (block1.getMaterial() == Material.AIR) { - this.world.d(this.player.getId(), this.f, this.g, this.h, -1); - this.o = -1; - this.d = false; - } else { - int k = this.currentTick - this.lastDigTick; - - f = block1.getDamage(this.player, this.player.world, this.f, this.g, this.h) * (float) (k + 1); - i = (int) (f * 10.0F); - if (i != this.o) { - this.world.d(this.player.getId(), this.f, this.g, this.h, i); - this.o = i; - } - } - } - } - - public void dig(int i, int j, int k, int l) { - // CraftBukkit start - PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, i, j, k, l, this.player.inventory.getItemInHand()); - if (!this.gamemode.isAdventure() || this.player.d(i, j, k)) { - if (event.isCancelled()) { - // Let the client know the block still exists - ((EntityPlayer) this.player).playerConnection.sendPacket(new PacketPlayOutBlockChange(i, j, k, this.world)); - // Update any tile entity data for this block - TileEntity tileentity = this.world.getTileEntity(i, j, k); - if (tileentity != null) { - this.player.playerConnection.sendPacket(tileentity.getUpdatePacket()); - } - return; - } - // CraftBukkit end - if (this.isCreative()) { - if (!this.world.douseFire((EntityHuman) null, i, j, k, l)) { - this.breakBlock(i, j, k); - } - } else { - // this.world.douseFire((EntityHuman) null, i, j, k, l); // CraftBukkit - Moved down - this.lastDigTick = this.currentTick; - float f = 1.0F; - Block block = this.world.getType(i, j, k); - // CraftBukkit start - Swings at air do *NOT* exist. - if (event.useInteractedBlock() == Event.Result.DENY) { - // If we denied a door from opening, we need to send a correcting update to the client, as it already opened the door. - if (block == Blocks.WOODEN_DOOR) { - // For some reason *BOTH* the bottom/top part have to be marked updated. - boolean bottom = (this.world.getData(i, j, k) & 8) == 0; - ((EntityPlayer) this.player).playerConnection.sendPacket(new PacketPlayOutBlockChange(i, j, k, this.world)); - ((EntityPlayer) this.player).playerConnection.sendPacket(new PacketPlayOutBlockChange(i, j + (bottom ? 1 : -1), k, this.world)); - } else if (block == Blocks.TRAP_DOOR) { - ((EntityPlayer) this.player).playerConnection.sendPacket(new PacketPlayOutBlockChange(i, j, k, this.world)); - } - } else if (block.getMaterial() != Material.AIR) { - block.attack(this.world, i, j, k, this.player); - f = block.getDamage(this.player, this.player.world, i, j, k); - // Allow fire punching to be blocked - this.world.douseFire((EntityHuman) null, i, j, k, l); - } - - if (event.useItemInHand() == Event.Result.DENY) { - // If we 'insta destroyed' then the client needs to be informed. - if (f > 1.0f) { - ((EntityPlayer) this.player).playerConnection.sendPacket(new PacketPlayOutBlockChange(i, j, k, this.world)); - } - return; - } - org.bukkit.event.block.BlockDamageEvent blockEvent = CraftEventFactory.callBlockDamageEvent(this.player, i, j, k, this.player.inventory.getItemInHand(), f >= 1.0f); - - if (blockEvent.isCancelled()) { - // Let the client know the block still exists - ((EntityPlayer) this.player).playerConnection.sendPacket(new PacketPlayOutBlockChange(i, j, k, this.world)); - return; - } - - if (blockEvent.getInstaBreak()) { - f = 2.0f; - } - // CraftBukkit end - - if (block.getMaterial() != Material.AIR && f >= 1.0F) { - this.breakBlock(i, j, k); - } else { - this.d = true; - this.f = i; - this.g = j; - this.h = k; - int i1 = (int) (f * 10.0F); - - this.world.d(this.player.getId(), i, j, k, i1); - this.o = i1; - } - } - } - } - - public void a(int i, int j, int k) { - if (i == this.f && j == this.g && k == this.h) { - this.currentTick = MinecraftServer.currentTick; // CraftBukkit - int l = this.currentTick - this.lastDigTick; - Block block = this.world.getType(i, j, k); - - if (block.getMaterial() != Material.AIR) { - float f = block.getDamage(this.player, this.player.world, i, j, k) * (float) (l + 1); - - if (f >= 0.7F) { - this.d = false; - this.world.d(this.player.getId(), i, j, k, -1); - this.breakBlock(i, j, k); - } else if (!this.j) { - this.d = false; - this.j = true; - this.k = i; - this.l = j; - this.m = k; - this.n = this.lastDigTick; - } - } - // CraftBukkit start - Force block reset to client - } else { - this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(i, j, k, this.world)); - // CraftBukkit end - } - } - - public void c(int i, int j, int k) { - this.d = false; - this.world.d(this.player.getId(), this.f, this.g, this.h, -1); - } - - private boolean d(int i, int j, int k) { - Block block = this.world.getType(i, j, k); - int l = this.world.getData(i, j, k); - - block.a(this.world, i, j, k, l, this.player); - boolean flag = this.world.setAir(i, j, k); - - if (flag) { - block.postBreak(this.world, i, j, k, l); - } - - return flag; - } - - public boolean breakBlock(int i, int j, int k) { - // CraftBukkit start - fire BlockBreakEvent - BlockBreakEvent event = null; - - if (this.player instanceof EntityPlayer) { - org.bukkit.block.Block block = this.world.getWorld().getBlockAt(i, j, k); - - // Tell client the block is gone immediately then process events - if (world.getTileEntity(i, j, k) == null) { - PacketPlayOutBlockChange packet = new PacketPlayOutBlockChange(i, j, k, this.world); - packet.block = Blocks.AIR; - packet.data = 0; - ((EntityPlayer) this.player).playerConnection.sendPacket(packet); - } - - event = new BlockBreakEvent(block, this.player.getBukkitEntity()); - - // Adventure mode pre-cancel - event.setCancelled(this.gamemode.isAdventure() && !this.player.d(i, j, k)); - - // Sword + Creative mode pre-cancel - event.setCancelled(event.isCancelled() || (this.gamemode.d() && this.player.be() != null && this.player.be().getItem() instanceof ItemSword)); - - // Calculate default block experience - Block nmsBlock = this.world.getType(i, j, k); - - if (nmsBlock != null && !event.isCancelled() && !this.isCreative() && this.player.a(nmsBlock)) { - // Copied from block.a(world, entityhuman, int, int, int, int) - if (!(nmsBlock.E() && EnchantmentManager.hasSilkTouchEnchantment(this.player))) { - int data = block.getData(); - int bonusLevel = EnchantmentManager.getBonusBlockLootEnchantmentLevel(this.player); - - event.setExpToDrop(nmsBlock.getExpDrop(this.world, data, bonusLevel)); - } - } - - this.world.getServer().getPluginManager().callEvent(event); - - if (event.isCancelled()) { - // Let the client know the block still exists - ((EntityPlayer) this.player).playerConnection.sendPacket(new PacketPlayOutBlockChange(i, j, k, this.world)); - // Update any tile entity data for this block - TileEntity tileentity = this.world.getTileEntity(i, j, k); - if (tileentity != null) { - this.player.playerConnection.sendPacket(tileentity.getUpdatePacket()); - } - return false; - } - } - - if (false && this.gamemode.isAdventure() && !this.player.d(i, j, k)) { // Never trigger - // CraftBukkit end - return false; - } else if (false && this.gamemode.d() && this.player.be() != null && this.player.be().getItem() instanceof ItemSword) { // CraftBukkit - never trigger - return false; - } else { - Block block = this.world.getType(i, j, k); - if (block == Blocks.AIR) return false; // CraftBukkit - A plugin set block to air without cancelling - int l = this.world.getData(i, j, k); - - // CraftBukkit start - Special case skulls, their item data comes from a tile entity - if (block == Blocks.SKULL && !this.isCreative()) { - block.dropNaturally(world, i, j, k, l, 1.0F, 0); - return this.d(i, j, k); - } - // CraftBukkit end - - this.world.a(this.player, 2001, i, j, k, Block.getId(block) + (this.world.getData(i, j, k) << 12)); - boolean flag = this.d(i, j, k); - - if (this.isCreative()) { - this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(i, j, k, this.world)); - } else { - ItemStack itemstack = this.player.bF(); - boolean flag1 = this.player.a(block); - - if (itemstack != null) { - itemstack.a(this.world, block, i, j, k, this.player); - if (itemstack.count == 0) { - this.player.bG(); - } - } - - if (flag && flag1) { - block.a(this.world, this.player, i, j, k, l); - } - } - - // CraftBukkit start - Drop event experience - if (flag && event != null) { - block.dropExperience(this.world, i, j, k, event.getExpToDrop()); - } - // CraftBukkit end - - return flag; - } - } - - public boolean useItem(EntityHuman entityhuman, World world, ItemStack itemstack) { - int i = itemstack.count; - int j = itemstack.getData(); - ItemStack itemstack1 = itemstack.a(world, entityhuman); - - if (itemstack1 == itemstack && (itemstack1 == null || itemstack1.count == i && itemstack1.n() <= 0 && itemstack1.getData() == j)) { - return false; - } else { - entityhuman.inventory.items[entityhuman.inventory.itemInHandIndex] = itemstack1; - if (this.isCreative()) { - itemstack1.count = i; - if (itemstack1.g()) { - itemstack1.setData(j); - } - } - - if (itemstack1.count == 0) { - entityhuman.inventory.items[entityhuman.inventory.itemInHandIndex] = null; - } - - if (!entityhuman.by()) { - ((EntityPlayer) entityhuman).updateInventory(entityhuman.defaultContainer); - } - - return true; - } - } - - public boolean interact(EntityHuman entityhuman, World world, ItemStack itemstack, int i, int j, int k, int l, float f, float f1, float f2) { - /* CraftBukkit start - whole method - if ((!entityhuman.isSneaking() || entityhuman.be() == null) && world.getType(i, j, k).interact(world, i, j, k, entityhuman, l, f, f1, f2)) { - return true; - } else if (itemstack == null) { - return false; - } else if (this.isCreative()) { - int i1 = itemstack.getData(); - int j1 = itemstack.count; - boolean flag = itemstack.placeItem(entityhuman, world, i, j, k, l, f, f1, f2); - - itemstack.setData(i1); - itemstack.count = j1; - return flag; - } else { - return itemstack.placeItem(entityhuman, world, i, j, k, l, f, f1, f2); - } - // Interract event */ - Block block = world.getType(i, j, k); - boolean result = false; - if (block != Blocks.AIR) { - PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(entityhuman, Action.RIGHT_CLICK_BLOCK, i, j, k, l, itemstack); - if (event.useInteractedBlock() == Event.Result.DENY) { - // If we denied a door from opening, we need to send a correcting update to the client, as it already opened the door. - if (block == Blocks.WOODEN_DOOR) { - boolean bottom = (world.getData(i, j, k) & 8) == 0; - ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutBlockChange(i, j + (bottom ? 1 : -1), k, world)); - } - result = (event.useItemInHand() != Event.Result.ALLOW); - } else if (!entityhuman.isSneaking() || itemstack == null) { - result = block.interact(world, i, j, k, entityhuman, l, f, f1, f2); - } - - if (itemstack != null && !result) { - int j1 = itemstack.getData(); - int k1 = itemstack.count; - - result = itemstack.placeItem(entityhuman, world, i, j, k, l, f, f1, f2); - - // The item count should not decrement in Creative mode. - if (this.isCreative()) { - itemstack.setData(j1); - itemstack.count = k1; - } - } - - // If we have 'true' and no explicit deny *or* an explicit allow -- run the item part of the hook - if (itemstack != null && ((!result && event.useItemInHand() != Event.Result.DENY) || event.useItemInHand() == Event.Result.ALLOW)) { - this.useItem(entityhuman, world, itemstack); - } - } - return result; - // CraftBukkit end - } - - public void a(WorldServer worldserver) { - this.world = worldserver; - } -} diff --git a/src/main/java/net/minecraft/server/PlayerInventory.java b/src/main/java/net/minecraft/server/PlayerInventory.java deleted file mode 100644 index 5cd6e14f..00000000 --- a/src/main/java/net/minecraft/server/PlayerInventory.java +++ /dev/null @@ -1,539 +0,0 @@ -package net.minecraft.server; - -import java.util.concurrent.Callable; - -// CraftBukkit start -import java.util.List; - -import org.bukkit.craftbukkit.entity.CraftHumanEntity; -import org.bukkit.entity.HumanEntity; -// CraftBukkit end - -public class PlayerInventory implements IInventory { - - public ItemStack[] items = new ItemStack[36]; - public ItemStack[] armor = new ItemStack[4]; - public int itemInHandIndex; - public EntityHuman player; - private ItemStack g; - public boolean e; - - // CraftBukkit start - add fields and methods - public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>(); - private int maxStack = MAX_STACK; - - public ItemStack[] getContents() { - return this.items; - } - - public ItemStack[] getArmorContents() { - return this.armor; - } - - 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.getBukkitEntity(); - } - - public void setMaxStackSize(int size) { - maxStack = size; - } - // CraftBukkit end - - public PlayerInventory(EntityHuman entityhuman) { - this.player = entityhuman; - } - - public ItemStack getItemInHand() { - return this.itemInHandIndex < 9 && this.itemInHandIndex >= 0 ? this.items[this.itemInHandIndex] : null; - } - - public static int getHotbarSize() { - return 9; - } - - private int c(Item item) { - for (int i = 0; i < this.items.length; ++i) { - if (this.items[i] != null && this.items[i].getItem() == item) { - return i; - } - } - - return -1; - } - - private int firstPartial(ItemStack itemstack) { - for (int i = 0; i < this.items.length; ++i) { - if (this.items[i] != null && this.items[i].getItem() == itemstack.getItem() && this.items[i].isStackable() && this.items[i].count < this.items[i].getMaxStackSize() && this.items[i].count < this.getMaxStackSize() && (!this.items[i].usesData() || this.items[i].getData() == itemstack.getData()) && ItemStack.equals(this.items[i], itemstack)) { - return i; - } - } - - return -1; - } - - // CraftBukkit start - Watch method above! :D - public int canHold(ItemStack itemstack) { - int remains = itemstack.count; - for (int i = 0; i < this.items.length; ++i) { - if (this.items[i] == null) return itemstack.count; - - // Taken from firstPartial(ItemStack) - if (this.items[i] != null && this.items[i].getItem() == itemstack.getItem() && this.items[i].isStackable() && this.items[i].count < this.items[i].getMaxStackSize() && this.items[i].count < this.getMaxStackSize() && (!this.items[i].usesData() || this.items[i].getData() == itemstack.getData()) && ItemStack.equals(this.items[i], itemstack)) { - remains -= (this.items[i].getMaxStackSize() < this.getMaxStackSize() ? this.items[i].getMaxStackSize() : this.getMaxStackSize()) - this.items[i].count; - } - if (remains <= 0) return itemstack.count; - } - return itemstack.count - remains; - } - // CraftBukkit end - - public int getFirstEmptySlotIndex() { - for (int i = 0; i < this.items.length; ++i) { - if (this.items[i] == null) { - return i; - } - } - - return -1; - } - - public int a(Item item, int i) { - int j = 0; - - int k; - ItemStack itemstack; - - for (k = 0; k < this.items.length; ++k) { - itemstack = this.items[k]; - if (itemstack != null && (item == null || itemstack.getItem() == item) && (i <= -1 || itemstack.getData() == i)) { - j += itemstack.count; - this.items[k] = null; - } - } - - for (k = 0; k < this.armor.length; ++k) { - itemstack = this.armor[k]; - if (itemstack != null && (item == null || itemstack.getItem() == item) && (i <= -1 || itemstack.getData() == i)) { - j += itemstack.count; - this.armor[k] = null; - } - } - - if (this.g != null) { - if (item != null && this.g.getItem() != item) { - return j; - } - - if (i > -1 && this.g.getData() != i) { - return j; - } - - j += this.g.count; - this.setCarried((ItemStack) null); - } - - return j; - } - - private int e(ItemStack itemstack) { - Item item = itemstack.getItem(); - int i = itemstack.count; - int j; - - if (itemstack.getMaxStackSize() == 1) { - j = this.getFirstEmptySlotIndex(); - if (j < 0) { - return i; - } else { - if (this.items[j] == null) { - this.items[j] = ItemStack.b(itemstack); - } - - return 0; - } - } else { - j = this.firstPartial(itemstack); - if (j < 0) { - j = this.getFirstEmptySlotIndex(); - } - - if (j < 0) { - return i; - } else { - if (this.items[j] == null) { - this.items[j] = new ItemStack(item, 0, itemstack.getData()); - if (itemstack.hasTag()) { - this.items[j].setTag((NBTTagCompound) itemstack.getTag().clone()); - } - } - - int k = i; - - if (i > this.items[j].getMaxStackSize() - this.items[j].count) { - k = this.items[j].getMaxStackSize() - this.items[j].count; - } - - if (k > this.getMaxStackSize() - this.items[j].count) { - k = this.getMaxStackSize() - this.items[j].count; - } - - if (k == 0) { - return i; - } else { - i -= k; - this.items[j].count += k; - this.items[j].c = 5; - return i; - } - } - } - } - - public void k() { - 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); - } - } - } - - public boolean a(Item item) { - int i = this.c(item); - - if (i < 0) { - return false; - } else { - if (--this.items[i].count <= 0) { - this.items[i] = null; - } - - return true; - } - } - - public boolean b(Item item) { - int i = this.c(item); - - return i >= 0; - } - - public boolean pickup(ItemStack itemstack) { - if (itemstack != null && itemstack.count != 0 && itemstack.getItem() != null) { - try { - int i; - - if (itemstack.i()) { - i = this.getFirstEmptySlotIndex(); - if (i >= 0) { - this.items[i] = ItemStack.b(itemstack); - this.items[i].c = 5; - itemstack.count = 0; - return true; - } else if (this.player.abilities.canInstantlyBuild) { - itemstack.count = 0; - return true; - } else { - return false; - } - } else { - do { - i = itemstack.count; - itemstack.count = this.e(itemstack); - } while (itemstack.count > 0 && itemstack.count < i); - - if (itemstack.count == i && this.player.abilities.canInstantlyBuild) { - itemstack.count = 0; - return true; - } else { - return itemstack.count < i; - } - } - } catch (Throwable throwable) { - CrashReport crashreport = CrashReport.a(throwable, "Adding item to inventory"); - CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Item being added"); - - crashreportsystemdetails.a("Item ID", Integer.valueOf(Item.getId(itemstack.getItem()))); - crashreportsystemdetails.a("Item data", Integer.valueOf(itemstack.getData())); - crashreportsystemdetails.a("Item name", (Callable) (new CrashReportItemName(this, itemstack))); - throw new ReportedException(crashreport); - } - } else { - return false; - } - } - - public ItemStack splitStack(int i, int j) { - ItemStack[] aitemstack = this.items; - - if (i >= this.items.length) { - aitemstack = this.armor; - i -= this.items.length; - } - - if (aitemstack[i] != null) { - ItemStack itemstack; - - if (aitemstack[i].count <= j) { - itemstack = aitemstack[i]; - aitemstack[i] = null; - return itemstack; - } else { - itemstack = aitemstack[i].a(j); - if (aitemstack[i].count == 0) { - aitemstack[i] = null; - } - - return itemstack; - } - } else { - return null; - } - } - - public ItemStack splitWithoutUpdate(int i) { - ItemStack[] aitemstack = this.items; - - if (i >= this.items.length) { - aitemstack = this.armor; - i -= this.items.length; - } - - if (aitemstack[i] != null) { - ItemStack itemstack = aitemstack[i]; - - aitemstack[i] = null; - return itemstack; - } else { - return null; - } - } - - public void setItem(int i, ItemStack itemstack) { - ItemStack[] aitemstack = this.items; - - if (i >= aitemstack.length) { - i -= aitemstack.length; - aitemstack = this.armor; - } - - aitemstack[i] = itemstack; - } - - public float a(Block block) { - float f = 1.0F; - - if (this.items[this.itemInHandIndex] != null) { - f *= this.items[this.itemInHandIndex].a(block); - } - - return f; - } - - public NBTTagList a(NBTTagList nbttaglist) { - int i; - NBTTagCompound nbttagcompound; - - for (i = 0; i < this.items.length; ++i) { - if (this.items[i] != null) { - nbttagcompound = new NBTTagCompound(); - nbttagcompound.setByte("Slot", (byte) i); - this.items[i].save(nbttagcompound); - nbttaglist.add(nbttagcompound); - } - } - - for (i = 0; i < this.armor.length; ++i) { - if (this.armor[i] != null) { - nbttagcompound = new NBTTagCompound(); - nbttagcompound.setByte("Slot", (byte) (i + 100)); - this.armor[i].save(nbttagcompound); - nbttaglist.add(nbttagcompound); - } - } - - return nbttaglist; - } - - public void b(NBTTagList nbttaglist) { - this.items = new ItemStack[36]; - this.armor = new ItemStack[4]; - - for (int i = 0; i < nbttaglist.size(); ++i) { - NBTTagCompound nbttagcompound = nbttaglist.get(i); - int j = nbttagcompound.getByte("Slot") & 255; - ItemStack itemstack = ItemStack.createStack(nbttagcompound); - - if (itemstack != null) { - if (j >= 0 && j < this.items.length) { - this.items[j] = itemstack; - } - - if (j >= 100 && j < this.armor.length + 100) { - this.armor[j - 100] = itemstack; - } - } - } - } - - public int getSize() { - return this.items.length + 4; - } - - public ItemStack getItem(int i) { - ItemStack[] aitemstack = this.items; - - if (i >= aitemstack.length) { - i -= aitemstack.length; - aitemstack = this.armor; - } - - return aitemstack[i]; - } - - public String getInventoryName() { - return "container.inventory"; - } - - public boolean k_() { - return false; - } - - public int getMaxStackSize() { - return maxStack; // CraftBukkit - } - - public boolean b(Block block) { - if (block.getMaterial().isAlwaysDestroyable()) { - return true; - } else { - ItemStack itemstack = this.getItem(this.itemInHandIndex); - - return itemstack != null ? itemstack.b(block) : false; - } - } - - public ItemStack d(int i) { - return this.armor[i]; - } - - public int l() { - int i = 0; - - for (int j = 0; j < this.armor.length; ++j) { - if (this.armor[j] != null && this.armor[j].getItem() instanceof ItemArmor) { - int k = ((ItemArmor) this.armor[j].getItem()).c; - - i += k; - } - } - - return i; - } - - public void a(float f) { - f /= 4.0F; - if (f < 1.0F) { - f = 1.0F; - } - - for (int i = 0; i < this.armor.length; ++i) { - if (this.armor[i] != null && this.armor[i].getItem() instanceof ItemArmor) { - this.armor[i].damage((int) f, this.player); - if (this.armor[i].count == 0) { - this.armor[i] = null; - } - } - } - } - - public void m() { - int i; - - for (i = 0; i < this.items.length; ++i) { - if (this.items[i] != null) { - this.player.a(this.items[i], true, false); - this.items[i] = null; - } - } - - for (i = 0; i < this.armor.length; ++i) { - if (this.armor[i] != null) { - this.player.a(this.armor[i], true, false); - this.armor[i] = null; - } - } - } - - public void update() { - this.e = true; - } - - public void setCarried(ItemStack itemstack) { - this.g = itemstack; - } - - public ItemStack getCarried() { - // CraftBukkit start - if (this.g != null && this.g.count == 0) { - this.setCarried(null); - } - // CraftBukkit end - return this.g; - } - - public boolean a(EntityHuman entityhuman) { - return this.player.dead ? false : entityhuman.f(this.player) <= 64.0D; - } - - public boolean c(ItemStack itemstack) { - int i; - - for (i = 0; i < this.armor.length; ++i) { - if (this.armor[i] != null && this.armor[i].doMaterialsMatch(itemstack)) { - return true; - } - } - - for (i = 0; i < this.items.length; ++i) { - if (this.items[i] != null && this.items[i].doMaterialsMatch(itemstack)) { - return true; - } - } - - return false; - } - - public void startOpen() {} - - public void closeContainer() {} - - public boolean b(int i, ItemStack itemstack) { - return true; - } - - public void b(PlayerInventory playerinventory) { - int i; - - for (i = 0; i < this.items.length; ++i) { - this.items[i] = ItemStack.b(playerinventory.items[i]); - } - - for (i = 0; i < this.armor.length; ++i) { - this.armor[i] = ItemStack.b(playerinventory.armor[i]); - } - - this.itemInHandIndex = playerinventory.itemInHandIndex; - } -} diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java deleted file mode 100644 index e6012fba..00000000 --- a/src/main/java/net/minecraft/server/PlayerList.java +++ /dev/null @@ -1,1216 +0,0 @@ -package net.minecraft.server; - -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; -import java.util.Map; -import java.util.UUID; -import java.util.Map.Entry; - -import net.minecraft.util.com.google.common.base.Charsets; -import net.minecraft.util.com.google.common.collect.Lists; -import net.minecraft.util.com.google.common.collect.Maps; -import net.minecraft.util.com.mojang.authlib.GameProfile; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -// CraftBukkit start -import org.bukkit.craftbukkit.CraftServer; -import org.bukkit.craftbukkit.CraftWorld; -import org.bukkit.craftbukkit.chunkio.ChunkIOExecutor; - -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.TravelAgent; -import org.bukkit.entity.Player; -import org.bukkit.event.player.PlayerChangedWorldEvent; -import org.bukkit.event.player.PlayerPortalEvent; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerLoginEvent; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.event.player.PlayerRespawnEvent; -import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; -import org.bukkit.util.Vector; -// CraftBukkit end - -public abstract class PlayerList { - - public static final File a = new File("banned-players.json"); - public static final File b = new File("banned-ips.json"); - public static final File c = new File("ops.json"); - public static final File d = new File("whitelist.json"); - private static final Logger g = LogManager.getLogger(); - private static final SimpleDateFormat h = new SimpleDateFormat("yyyy-MM-dd \'at\' HH:mm:ss z"); - private final MinecraftServer server; - public final List players = new java.util.concurrent.CopyOnWriteArrayList(); // CraftBukkit - ArrayList -> CopyOnWriteArrayList: Iterator safety - private final GameProfileBanList j; - private final IpBanList k; - private final OpList operators; - private final WhiteList whitelist; - private final Map n; - public IPlayerFileData playerFileData; // CraftBukkit - private -> public - public boolean hasWhitelist; // CraftBukkit - private -> public - protected int maxPlayers; - private int q; - private EnumGamemode r; - private boolean s; - private int t; - - // CraftBukkit start - private CraftServer cserver; - - public PlayerList(MinecraftServer minecraftserver) { - minecraftserver.server = new CraftServer(minecraftserver, this); - minecraftserver.console = org.bukkit.craftbukkit.command.ColouredConsoleSender.getInstance(); - minecraftserver.reader.addCompleter(new org.bukkit.craftbukkit.command.ConsoleCommandCompleter(minecraftserver.server)); - this.cserver = minecraftserver.server; - // CraftBukkit end - - this.j = new GameProfileBanList(a); - this.k = new IpBanList(b); - this.operators = new OpList(c); - this.whitelist = new WhiteList(d); - this.n = Maps.newHashMap(); - this.server = minecraftserver; - this.j.a(false); - this.k.a(false); - this.maxPlayers = 8; - } - - public void a(NetworkManager networkmanager, EntityPlayer entityplayer) { - GameProfile gameprofile = entityplayer.getProfile(); - UserCache usercache = this.server.getUserCache(); - GameProfile gameprofile1 = usercache.a(gameprofile.getId()); - String s = gameprofile1 == null ? gameprofile.getName() : gameprofile1.getName(); - - usercache.a(gameprofile); - NBTTagCompound nbttagcompound = this.a(entityplayer); - - entityplayer.spawnIn(this.server.getWorldServer(entityplayer.dimension)); - entityplayer.playerInteractManager.a((WorldServer) entityplayer.world); - String s1 = "local"; - - if (networkmanager.getSocketAddress() != null) { - s1 = networkmanager.getSocketAddress().toString(); - } - - // CraftBukkit - Moved message to after join - // g.info(entityplayer.getName() + "[" + s1 + "] logged in with entity id " + entityplayer.getId() + " at (" + entityplayer.locX + ", " + entityplayer.locY + ", " + entityplayer.locZ + ")"); - WorldServer worldserver = this.server.getWorldServer(entityplayer.dimension); - ChunkCoordinates chunkcoordinates = worldserver.getSpawn(); - - this.a(entityplayer, (EntityPlayer) null, worldserver); - PlayerConnection playerconnection = new PlayerConnection(this.server, networkmanager, entityplayer); - - // CraftBukkit start - Don't send a higher than 60 MaxPlayer size, otherwise the PlayerInfo window won't render correctly. - int maxPlayers = this.getMaxPlayers(); - if (maxPlayers > 60) { - maxPlayers = 60; - } - playerconnection.sendPacket(new PacketPlayOutLogin(entityplayer.getId(), entityplayer.playerInteractManager.getGameMode(), worldserver.getWorldData().isHardcore(), worldserver.worldProvider.dimension, worldserver.difficulty, maxPlayers, worldserver.getWorldData().getType())); - entityplayer.getBukkitEntity().sendSupportedChannels(); - // CraftBukkit end - playerconnection.sendPacket(new PacketPlayOutCustomPayload("MC|Brand", this.getServer().getServerModName().getBytes(Charsets.UTF_8))); - playerconnection.sendPacket(new PacketPlayOutSpawnPosition(chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z)); - playerconnection.sendPacket(new PacketPlayOutAbilities(entityplayer.abilities)); - playerconnection.sendPacket(new PacketPlayOutHeldItemSlot(entityplayer.inventory.itemInHandIndex)); - entityplayer.getStatisticManager().d(); - entityplayer.getStatisticManager().updateStatistics(entityplayer); - this.sendScoreboard((ScoreboardServer) worldserver.getScoreboard(), entityplayer); - this.server.az(); - /* CraftBukkit start - login message is handled in the event - ChatMessage chatmessage; - - if (!entityplayer.getName().equalsIgnoreCase(s)) { - chatmessage = new ChatMessage("multiplayer.player.joined.renamed", new Object[] { entityplayer.getScoreboardDisplayName(), s}); - } else { - chatmessage = new ChatMessage("multiplayer.player.joined", new Object[] { entityplayer.getScoreboardDisplayName()}); - } - - chatmessage.getChatModifier().setColor(EnumChatFormat.YELLOW); - this.sendMessage(chatmessage); - // CraftBukkit end */ - this.c(entityplayer); - worldserver = this.server.getWorldServer(entityplayer.dimension); // CraftBukkit - Update in case join event changed it - playerconnection.a(entityplayer.locX, entityplayer.locY, entityplayer.locZ, entityplayer.yaw, entityplayer.pitch); - this.b(entityplayer, worldserver); - if (this.server.getResourcePack().length() > 0) { - entityplayer.setResourcePack(this.server.getResourcePack()); - } - - Iterator iterator = entityplayer.getEffects().iterator(); - - while (iterator.hasNext()) { - MobEffect mobeffect = (MobEffect) iterator.next(); - - playerconnection.sendPacket(new PacketPlayOutEntityEffect(entityplayer.getId(), mobeffect)); - } - - entityplayer.syncInventory(); - if (nbttagcompound != null && nbttagcompound.hasKeyOfType("Riding", 10)) { - Entity entity = EntityTypes.a(nbttagcompound.getCompound("Riding"), worldserver); - - if (entity != null) { - entity.attachedToPlayer = true; - worldserver.addEntity(entity); - entityplayer.mount(entity); - entity.attachedToPlayer = false; - } - } - - // CraftBukkit - Moved from above, added world - g.info(entityplayer.getName() + "[" + s1 + "] logged in with entity id " + entityplayer.getId() + " at ([" + entityplayer.world.worldData.getName() + "] " + entityplayer.locX + ", " + entityplayer.locY + ", " + entityplayer.locZ + ")"); - } - - public void sendScoreboard(ScoreboardServer scoreboardserver, EntityPlayer entityplayer) { // CraftBukkit - protected -> public - HashSet hashset = new HashSet(); - Iterator iterator = scoreboardserver.getTeams().iterator(); - - while (iterator.hasNext()) { - ScoreboardTeam scoreboardteam = (ScoreboardTeam) iterator.next(); - - entityplayer.playerConnection.sendPacket(new PacketPlayOutScoreboardTeam(scoreboardteam, 0)); - } - - for (int i = 0; i < 3; ++i) { - ScoreboardObjective scoreboardobjective = scoreboardserver.getObjectiveForSlot(i); - - if (scoreboardobjective != null && !hashset.contains(scoreboardobjective)) { - List list = scoreboardserver.getScoreboardScorePacketsForObjective(scoreboardobjective); - Iterator iterator1 = list.iterator(); - - while (iterator1.hasNext()) { - Packet packet = (Packet) iterator1.next(); - - entityplayer.playerConnection.sendPacket(packet); - } - - hashset.add(scoreboardobjective); - } - } - } - - public void setPlayerFileData(WorldServer[] aworldserver) { - if (this.playerFileData != null) return; // CraftBukkit - this.playerFileData = aworldserver[0].getDataManager().getPlayerFileData(); - } - - public void a(EntityPlayer entityplayer, WorldServer worldserver) { - WorldServer worldserver1 = entityplayer.r(); - - if (worldserver != null) { - worldserver.getPlayerChunkMap().removePlayer(entityplayer); - } - - worldserver1.getPlayerChunkMap().addPlayer(entityplayer); - worldserver1.chunkProviderServer.getChunkAt((int) entityplayer.locX >> 4, (int) entityplayer.locZ >> 4); - } - - public int d() { - return PlayerChunkMap.getFurthestViewableBlock(this.s()); - } - - public NBTTagCompound a(EntityPlayer entityplayer) { - // CraftBukkit - fix reference to worldserver array - NBTTagCompound nbttagcompound = this.server.worlds.get(0).getWorldData().i(); - NBTTagCompound nbttagcompound1; - - if (entityplayer.getName().equals(this.server.M()) && nbttagcompound != null) { - entityplayer.f(nbttagcompound); - nbttagcompound1 = nbttagcompound; - g.debug("loading single player"); - } else { - nbttagcompound1 = this.playerFileData.load(entityplayer); - } - - return nbttagcompound1; - } - - protected void b(EntityPlayer entityplayer) { - this.playerFileData.save(entityplayer); - ServerStatisticManager serverstatisticmanager = (ServerStatisticManager) this.n.get(entityplayer.getUniqueID()); - - if (serverstatisticmanager != null) { - serverstatisticmanager.b(); - } - } - - public void c(EntityPlayer entityplayer) { - cserver.detectListNameConflict(entityplayer); // CraftBukkit - // this.sendAll(new PacketPlayOutPlayerInfo(entityplayer.getName(), true, 1000)); // CraftBukkit - replaced with loop below - this.players.add(entityplayer); - WorldServer worldserver = this.server.getWorldServer(entityplayer.dimension); - - // CraftBukkit start - PlayerJoinEvent playerJoinEvent = new PlayerJoinEvent(this.cserver.getPlayer(entityplayer), "\u00A7e" + entityplayer.getName() + " joined the game."); - this.cserver.getPluginManager().callEvent(playerJoinEvent); - - String joinMessage = playerJoinEvent.getJoinMessage(); - - if ((joinMessage != null) && (joinMessage.length() > 0)) { - for (IChatBaseComponent line : org.bukkit.craftbukkit.util.CraftChatMessage.fromString(joinMessage)) { - this.server.getPlayerList().sendAll(new PacketPlayOutChat(line)); - } - } - this.cserver.onPlayerJoin(playerJoinEvent.getPlayer()); - - ChunkIOExecutor.adjustPoolSize(this.getPlayerCount()); - // CraftBukkit end - - // CraftBukkit start - Only add if the player wasn't moved in the event - if (entityplayer.world == worldserver && !worldserver.players.contains(entityplayer)) { - worldserver.addEntity(entityplayer); - this.a(entityplayer, (WorldServer) null); - } - // CraftBukkit end - - // CraftBukkit start - sendAll above replaced with this loop - PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo(entityplayer.listName, true, 1000); - for (int i = 0; i < this.players.size(); ++i) { - EntityPlayer entityplayer1 = (EntityPlayer) this.players.get(i); - - if (entityplayer1.getBukkitEntity().canSee(entityplayer.getBukkitEntity())) { - entityplayer1.playerConnection.sendPacket(packet); - } - } - // CraftBukkit end - - for (int i = 0; i < this.players.size(); ++i) { - EntityPlayer entityplayer1 = (EntityPlayer) this.players.get(i); - - // CraftBukkit start - if (!entityplayer.getBukkitEntity().canSee(entityplayer1.getBukkitEntity())) { - continue; - } - // .name -> .listName - entityplayer.playerConnection.sendPacket(new PacketPlayOutPlayerInfo(entityplayer1.listName, true, entityplayer1.ping)); - // CraftBukkit end - } - } - - public void d(EntityPlayer entityplayer) { - entityplayer.r().getPlayerChunkMap().movePlayer(entityplayer); - } - - public String disconnect(EntityPlayer entityplayer) { // CraftBukkit - return string - entityplayer.a(StatisticList.f); - - // CraftBukkit start - Quitting must be before we do final save of data, in case plugins need to modify it - org.bukkit.craftbukkit.event.CraftEventFactory.handleInventoryCloseEvent(entityplayer); - - PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(this.cserver.getPlayer(entityplayer), "\u00A7e" + entityplayer.getName() + " left the game."); - this.cserver.getPluginManager().callEvent(playerQuitEvent); - entityplayer.getBukkitEntity().disconnect(playerQuitEvent.getQuitMessage()); - // CraftBukkit end - - this.b(entityplayer); - WorldServer worldserver = entityplayer.r(); - - if (entityplayer.vehicle != null && !(entityplayer.vehicle instanceof EntityPlayer)) { // CraftBukkit - Don't remove players - worldserver.removeEntity(entityplayer.vehicle); - g.debug("removing player mount"); - } - - worldserver.kill(entityplayer); - worldserver.getPlayerChunkMap().removePlayer(entityplayer); - this.players.remove(entityplayer); - this.n.remove(entityplayer.getUniqueID()); - ChunkIOExecutor.adjustPoolSize(this.getPlayerCount()); // CraftBukkit - - // CraftBukkit start - .name -> .listName, replace sendAll with loop - // this.sendAll(new PacketPlayOutPlayerInfo(entityplayer.getName(), false, 9999)); - PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo(entityplayer.listName, false, 9999); - for (int i = 0; i < this.players.size(); ++i) { - EntityPlayer entityplayer1 = (EntityPlayer) this.players.get(i); - - if (entityplayer1.getBukkitEntity().canSee(entityplayer.getBukkitEntity())) { - entityplayer1.playerConnection.sendPacket(packet); - } else { - entityplayer1.getBukkitEntity().removeDisconnectingPlayer(entityplayer.getBukkitEntity()); - } - } - // This removes the scoreboard (and player reference) for the specific player in the manager - this.cserver.getScoreboardManager().removePlayer(entityplayer.getBukkitEntity()); - - return playerQuitEvent.getQuitMessage(); - // CraftBukkit end - } - - // CraftBukkit start - Whole method, SocketAddress to LoginListener, added hostname to signature, return EntityPlayer - public EntityPlayer attemptLogin(LoginListener loginlistener, GameProfile gameprofile, String hostname) { - // 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. - SocketAddress socketaddress = loginlistener.networkManager.getSocketAddress(); - - EntityPlayer entity = new EntityPlayer(this.server, this.server.getWorldServer(0), gameprofile, new PlayerInteractManager(this.server.getWorldServer(0))); - Player player = entity.getBukkitEntity(); - PlayerLoginEvent event = new PlayerLoginEvent(player, hostname, ((java.net.InetSocketAddress) socketaddress).getAddress()); - String s; - - if (this.j.isBanned(gameprofile) && !this.j.get(gameprofile).hasExpired()) { - GameProfileBanEntry gameprofilebanentry = (GameProfileBanEntry) this.j.get(gameprofile); - - s = "You are banned from this server!\nReason: " + gameprofilebanentry.getReason(); - if (gameprofilebanentry.getExpires() != null) { - s = s + "\nYour ban will be removed on " + h.format(gameprofilebanentry.getExpires()); - } - - // return s; - event.disallow(PlayerLoginEvent.Result.KICK_BANNED, s); - } else if (!this.isWhitelisted(gameprofile)) { - // return "You are not white-listed on this server!"; - event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, "You are not white-listed on this server!"); - } else if (this.k.isBanned(socketaddress) && !this.k.get(gameprofile).hasExpired()) { - IpBanEntry ipbanentry = this.k.get(socketaddress); - - s = "Your IP address is banned from this server!\nReason: " + ipbanentry.getReason(); - if (ipbanentry.getExpires() != null) { - s = s + "\nYour ban will be removed on " + h.format(ipbanentry.getExpires()); - } - - // return s; - event.disallow(PlayerLoginEvent.Result.KICK_BANNED, s); - } else { - // return this.players.size() >= this.maxPlayers ? "The server is full!" : null; - if (this.players.size() >= this.maxPlayers) { - event.disallow(PlayerLoginEvent.Result.KICK_FULL, "The server is full!"); - } - } - - this.cserver.getPluginManager().callEvent(event); - if (event.getResult() != PlayerLoginEvent.Result.ALLOWED) { - loginlistener.disconnect(event.getKickMessage()); - return null; - } - - return entity; - // CraftBukkit end - } - - public EntityPlayer processLogin(GameProfile gameprofile, EntityPlayer player) { // CraftBukkit - added EntityPlayer - UUID uuid = EntityHuman.a(gameprofile); - ArrayList arraylist = Lists.newArrayList(); - - EntityPlayer entityplayer; - - for (int i = 0; i < this.players.size(); ++i) { - entityplayer = (EntityPlayer) this.players.get(i); - if (entityplayer.getUniqueID().equals(uuid)) { - arraylist.add(entityplayer); - } - } - - Iterator iterator = arraylist.iterator(); - - while (iterator.hasNext()) { - entityplayer = (EntityPlayer) iterator.next(); - entityplayer.playerConnection.disconnect("You logged in from another location"); - } - - /* CraftBukkit start - Object object; - - if (this.server.R()) { - object = new DemoPlayerInteractManager(this.server.getWorldServer(0)); - } else { - object = new PlayerInteractManager(this.server.getWorldServer(0)); - } - - return new EntityPlayer(this.server, this.server.getWorldServer(0), gameprofile, (PlayerInteractManager) object); - // */ - return player; - // CraftBukkit end - } - - // CraftBukkit start - public EntityPlayer moveToWorld(EntityPlayer entityplayer, int i, boolean flag) { - return this.moveToWorld(entityplayer, i, flag, null, true); - } - - public EntityPlayer moveToWorld(EntityPlayer entityplayer, int i, boolean flag, Location location, boolean avoidSuffocation) { - // CraftBukkit end - entityplayer.r().getTracker().untrackPlayer(entityplayer); - // entityplayer.r().getTracker().untrackEntity(entityplayer); // CraftBukkit - entityplayer.r().getPlayerChunkMap().removePlayer(entityplayer); - this.players.remove(entityplayer); - this.server.getWorldServer(entityplayer.dimension).removeEntity(entityplayer); - ChunkCoordinates chunkcoordinates = entityplayer.getBed(); - boolean flag1 = entityplayer.isRespawnForced(); - - /* CraftBukkit start - entityplayer.dimension = i; - Object object; - - if (this.server.R()) { - object = new DemoPlayerInteractManager(this.server.getWorldServer(entityplayer.dimension)); - } else { - object = new PlayerInteractManager(this.server.getWorldServer(entityplayer.dimension)); - } - - EntityPlayer entityplayer1 = new EntityPlayer(this.server, this.server.getWorldServer(entityplayer.dimension), entityplayer.getProfile(), (PlayerInteractManager) object); - // */ - EntityPlayer entityplayer1 = entityplayer; - org.bukkit.World fromWorld = entityplayer1.getBukkitEntity().getWorld(); - entityplayer1.viewingCredits = false; - // CraftBukkit end - - entityplayer1.playerConnection = entityplayer.playerConnection; - entityplayer1.copyTo(entityplayer, flag); - entityplayer1.d(entityplayer.getId()); - // WorldServer worldserver = this.server.getWorldServer(entityplayer.dimension); // CraftBukkit - handled later - - // this.a(entityplayer1, entityplayer, worldserver); // CraftBukkit - removed - ChunkCoordinates chunkcoordinates1; - - // CraftBukkit start - fire PlayerRespawnEvent - if (location == null) { - boolean isBedSpawn = false; - CraftWorld cworld = (CraftWorld) this.server.server.getWorld(entityplayer.spawnWorld); - if (cworld != null && chunkcoordinates != null) { - chunkcoordinates1 = EntityHuman.getBed(cworld.getHandle(), chunkcoordinates, flag1); - if (chunkcoordinates1 != null) { - isBedSpawn = true; - location = new Location(cworld, chunkcoordinates1.x + 0.5, chunkcoordinates1.y, chunkcoordinates1.z + 0.5); - } else { - entityplayer1.setRespawnPosition(null, true); - entityplayer1.playerConnection.sendPacket(new PacketPlayOutGameStateChange(0, 0)); - } - } - - if (location == null) { - cworld = (CraftWorld) this.server.server.getWorlds().get(0); - chunkcoordinates = cworld.getHandle().getSpawn(); - location = new Location(cworld, chunkcoordinates.x + 0.5, chunkcoordinates.y, chunkcoordinates.z + 0.5); - } - - Player respawnPlayer = this.cserver.getPlayer(entityplayer1); - PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(respawnPlayer, location, isBedSpawn); - this.cserver.getPluginManager().callEvent(respawnEvent); - - location = respawnEvent.getRespawnLocation(); - entityplayer.reset(); - } else { - location.setWorld(this.server.getWorldServer(i).getWorld()); - } - WorldServer worldserver = ((CraftWorld) location.getWorld()).getHandle(); - entityplayer1.setLocation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); - // CraftBukkit end - - worldserver.chunkProviderServer.getChunkAt((int) entityplayer1.locX >> 4, (int) entityplayer1.locZ >> 4); - - while (avoidSuffocation && !worldserver.getCubes(entityplayer1, entityplayer1.boundingBox).isEmpty()) { // CraftBukkit - entityplayer1.setPosition(entityplayer1.locX, entityplayer1.locY + 1.0D, entityplayer1.locZ); - } - - // CraftBukkit start - byte actualDimension = (byte) (worldserver.getWorld().getEnvironment().getId()); - // Force the client to refresh their chunk cache. - entityplayer1.playerConnection.sendPacket(new PacketPlayOutRespawn((byte) (actualDimension >= 0 ? -1 : 0), worldserver.difficulty, worldserver.getWorldData().getType(), entityplayer.playerInteractManager.getGameMode())); - entityplayer1.playerConnection.sendPacket(new PacketPlayOutRespawn(actualDimension, worldserver.difficulty, worldserver.getWorldData().getType(), entityplayer1.playerInteractManager.getGameMode())); - entityplayer1.spawnIn(worldserver); - entityplayer1.dead = false; - entityplayer1.playerConnection.teleport(new Location(worldserver.getWorld(), entityplayer1.locX, entityplayer1.locY, entityplayer1.locZ, entityplayer1.yaw, entityplayer1.pitch)); - entityplayer1.setSneaking(false); - chunkcoordinates1 = worldserver.getSpawn(); - // entityplayer1.playerConnection.a(entityplayer1.locX, entityplayer1.locY, entityplayer1.locZ, entityplayer1.yaw, entityplayer1.pitch); - // CraftBukkit end - entityplayer1.playerConnection.sendPacket(new PacketPlayOutSpawnPosition(chunkcoordinates1.x, chunkcoordinates1.y, chunkcoordinates1.z)); - entityplayer1.playerConnection.sendPacket(new PacketPlayOutExperience(entityplayer1.exp, entityplayer1.expTotal, entityplayer1.expLevel)); - this.b(entityplayer1, worldserver); - // CraftBukkit start - // Don't re-add player to player list if disconnected - if (!entityplayer.playerConnection.isDisconnected()) { - worldserver.getPlayerChunkMap().addPlayer(entityplayer1); - worldserver.addEntity(entityplayer1); - this.players.add(entityplayer1); - } - // Added from changeDimension - this.updateClient(entityplayer1); // Update health, etc... - entityplayer1.updateAbilities(); - Iterator iterator = entityplayer1.getEffects().iterator(); - - while (iterator.hasNext()) { - MobEffect mobeffect = (MobEffect) iterator.next(); - - entityplayer1.playerConnection.sendPacket(new PacketPlayOutEntityEffect(entityplayer1.getId(), mobeffect)); - } - // entityplayer1.syncInventory(); - // CraftBukkit end - entityplayer1.setHealth(entityplayer1.getHealth()); - - // CraftBukkit start - // Don't fire on respawn - if (fromWorld != location.getWorld()) { - PlayerChangedWorldEvent event = new PlayerChangedWorldEvent((Player) entityplayer1.getBukkitEntity(), fromWorld); - Bukkit.getServer().getPluginManager().callEvent(event); - } - - // Save player file again if they were disconnected - if (entityplayer.playerConnection.isDisconnected()) { - this.b(entityplayer1); - } - // CraftBukkit end - - return entityplayer1; - } - - // CraftBukkit start - Replaced the standard handling of portals with a more customised method. - public void changeDimension(EntityPlayer entityplayer, int i, TeleportCause cause) { - WorldServer exitWorld = null; - if (entityplayer.dimension < CraftWorld.CUSTOM_DIMENSION_OFFSET) { // plugins must specify exit from custom Bukkit worlds - // only target existing worlds (compensate for allow-nether/allow-end as false) - for (WorldServer world : this.server.worlds) { - if (world.dimension == i) { - exitWorld = world; - } - } - } - - Location enter = entityplayer.getBukkitEntity().getLocation(); - Location exit = null; - boolean useTravelAgent = false; // don't use agent for custom worlds or return from THE_END - if (exitWorld != null) { - if ((cause == TeleportCause.END_PORTAL) && (i == 0)) { - // THE_END -> NORMAL; use bed if available, otherwise default spawn - exit = ((org.bukkit.craftbukkit.entity.CraftPlayer) entityplayer.getBukkitEntity()).getBedSpawnLocation(); - if (exit == null || ((CraftWorld) exit.getWorld()).getHandle().dimension != 0) { - exit = exitWorld.getWorld().getSpawnLocation(); - } - } else { - // NORMAL <-> NETHER or NORMAL -> THE_END - exit = this.calculateTarget(enter, exitWorld); - useTravelAgent = true; - } - } - - TravelAgent agent = exit != null ? (TravelAgent) ((CraftWorld) exit.getWorld()).getHandle().getTravelAgent() : org.bukkit.craftbukkit.CraftTravelAgent.DEFAULT; // return arbitrary TA to compensate for implementation dependent plugins - PlayerPortalEvent event = new PlayerPortalEvent(entityplayer.getBukkitEntity(), enter, exit, agent, cause); - event.useTravelAgent(useTravelAgent); - Bukkit.getServer().getPluginManager().callEvent(event); - if (event.isCancelled() || event.getTo() == null) { - return; - } - - exit = event.useTravelAgent() ? event.getPortalTravelAgent().findOrCreate(event.getTo()) : event.getTo(); - if (exit == null) { - return; - } - exitWorld = ((CraftWorld) exit.getWorld()).getHandle(); - - Vector velocity = entityplayer.getBukkitEntity().getVelocity(); - boolean before = exitWorld.chunkProviderServer.forceChunkLoad; - exitWorld.chunkProviderServer.forceChunkLoad = true; - exitWorld.getTravelAgent().adjustExit(entityplayer, exit, velocity); - exitWorld.chunkProviderServer.forceChunkLoad = before; - - this.moveToWorld(entityplayer, exitWorld.dimension, true, exit, false); // Vanilla doesn't check for suffocation when handling portals, so neither should we - if (entityplayer.motX != velocity.getX() || entityplayer.motY != velocity.getY() || entityplayer.motZ != velocity.getZ()) { - entityplayer.getBukkitEntity().setVelocity(velocity); - } - // CraftBukkit end - } - - public void a(Entity entity, int i, WorldServer worldserver, WorldServer worldserver1) { - // CraftBukkit start - Split into modular functions - Location exit = this.calculateTarget(entity.getBukkitEntity().getLocation(), worldserver1); - this.repositionEntity(entity, exit, true); - } - - // Copy of original a(Entity, int, WorldServer, WorldServer) method with only location calculation logic - public Location calculateTarget(Location enter, World target) { - WorldServer worldserver = ((CraftWorld) enter.getWorld()).getHandle(); - WorldServer worldserver1 = ((CraftWorld) target.getWorld()).getHandle(); - int i = worldserver.dimension; - - double y = enter.getY(); - float yaw = enter.getYaw(); - float pitch = enter.getPitch(); - double d0 = enter.getX(); - double d1 = enter.getZ(); - double d2 = 8.0D; - /* - double d3 = entity.locX; - double d4 = entity.locY; - double d5 = entity.locZ; - float f = entity.yaw; - - worldserver.methodProfiler.a("moving"); - */ - if (worldserver1.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 (worldserver1.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) { - // use default NORMAL world spawn instead of target - worldserver1 = this.server.worlds.get(0); - chunkcoordinates = worldserver1.getSpawn(); - } else { - chunkcoordinates = worldserver1.getDimensionSpawn(); - } - - d0 = (double) chunkcoordinates.x; - y = (double) chunkcoordinates.y; - d1 = (double) chunkcoordinates.z; - yaw = 90.0F; - pitch = 0.0F; - /* - entity.setPositionRotation(d0, entity.locY, d1, 90.0F, 0.0F); - if (entity.isAlive()) { - worldserver.entityJoinedWorld(entity, false); - } - */ - } - - // worldserver.methodProfiler.b(); - if (i != 1) { - // worldserver.methodProfiler.a("placing"); - 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); - worldserver1.getTravelAgent().a(entity, d3, d4, d5, f); - } - - worldserver.methodProfiler.b(); - */ - } - - // entity.spawnIn(worldserver1); - return new Location(worldserver1.getWorld(), d0, y, d1, yaw, pitch); - } - - // copy of original a(Entity, int, WorldServer, WorldServer) method with only entity repositioning logic - public void repositionEntity(Entity entity, Location exit, boolean portal) { - int i = entity.dimension; - WorldServer worldserver = (WorldServer) entity.world; - WorldServer worldserver1 = ((CraftWorld) exit.getWorld()).getHandle(); - /* - 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; - */ - - worldserver.methodProfiler.a("moving"); - entity.setPositionRotation(exit.getX(), exit.getY(), exit.getZ(), exit.getYaw(), exit.getPitch()); - if (entity.isAlive()) { - worldserver.entityJoinedWorld(entity, false); - } - /* - 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); - } - } - */ - - worldserver.methodProfiler.b(); - if (i != 1) { - worldserver.methodProfiler.a("placing"); - /* - d0 = (double) MathHelper.a((int) d0, -29999872, 29999872); - d1 = (double) MathHelper.a((int) d1, -29999872, 29999872); - */ - if (entity.isAlive()) { - // entity.setPositionRotation(d0, entity.locY, d1, entity.yaw, entity.pitch) - // worldserver1.getTravelAgent().a(entity, d3, d4, d5, f); - if (portal) { - Vector velocity = entity.getBukkitEntity().getVelocity(); - worldserver1.getTravelAgent().adjustExit(entity, exit, velocity); - entity.setPositionRotation(exit.getX(), exit.getY(), exit.getZ(), exit.getYaw(), exit.getPitch()); - if (entity.motX != velocity.getX() || entity.motY != velocity.getY() || entity.motZ != velocity.getZ()) { - entity.getBukkitEntity().setVelocity(velocity); - } - } - worldserver1.addEntity(entity); - worldserver1.entityJoinedWorld(entity, false); - } - - worldserver.methodProfiler.b(); - } - - entity.spawnIn(worldserver1); - // CraftBukkit end - } - - public void tick() { - if (++this.t > 600) { - this.t = 0; - } - - /* CraftBukkit start - Remove updating of lag to players -- it spams way to much on big servers. - if (this.t < this.players.size()) { - EntityPlayer entityplayer = (EntityPlayer) this.players.get(this.p); - - this.sendAll(new PacketPlayOutPlayerInfo(entityplayer.getName(), true, entityplayer.ping)); - } - // CraftBukkit end */ - } - - public void sendAll(Packet packet) { - for (int i = 0; i < this.players.size(); ++i) { - ((EntityPlayer) this.players.get(i)).playerConnection.sendPacket(packet); - } - } - - public void a(Packet packet, int i) { - for (int j = 0; j < this.players.size(); ++j) { - EntityPlayer entityplayer = (EntityPlayer) this.players.get(j); - - if (entityplayer.dimension == i) { - entityplayer.playerConnection.sendPacket(packet); - } - } - } - - public String b(boolean flag) { - String s = ""; - ArrayList arraylist = Lists.newArrayList(this.players); - - for (int i = 0; i < arraylist.size(); ++i) { - if (i > 0) { - s = s + ", "; - } - - s = s + ((EntityPlayer) arraylist.get(i)).getName(); - if (flag) { - s = s + " (" + ((EntityPlayer) arraylist.get(i)).getUniqueID().toString() + ")"; - } - } - - return s; - } - - public String[] f() { - String[] astring = new String[this.players.size()]; - - for (int i = 0; i < this.players.size(); ++i) { - astring[i] = ((EntityPlayer) this.players.get(i)).getName(); - } - - return astring; - } - - public GameProfile[] g() { - GameProfile[] agameprofile = new GameProfile[this.players.size()]; - - for (int i = 0; i < this.players.size(); ++i) { - agameprofile[i] = ((EntityPlayer) this.players.get(i)).getProfile(); - } - - return agameprofile; - } - - public GameProfileBanList getProfileBans() { - return this.j; - } - - public IpBanList getIPBans() { - return this.k; - } - - public void addOp(GameProfile gameprofile) { - this.operators.add(new OpListEntry(gameprofile, this.server.l())); - - // CraftBukkit start - Player player = server.server.getPlayer(gameprofile.getId()); - if (player != null) { - player.recalculatePermissions(); - } - // CraftBukkit end - } - - public void removeOp(GameProfile gameprofile) { - this.operators.remove(gameprofile); - - // CraftBukkit start - Player player = server.server.getPlayer(gameprofile.getId()); - if (player != null) { - player.recalculatePermissions(); - } - // CraftBukkit end - } - - public boolean isWhitelisted(GameProfile gameprofile) { - return !this.hasWhitelist || this.operators.d(gameprofile) || this.whitelist.d(gameprofile); - } - - public boolean isOp(GameProfile gameprofile) { - // CraftBukkit - fix reference to worldserver array - return this.operators.d(gameprofile) || this.server.N() && this.server.worlds.get(0).getWorldData().allowCommands() && this.server.M().equalsIgnoreCase(gameprofile.getName()) || this.s; - } - - public EntityPlayer getPlayer(String s) { - Iterator iterator = this.players.iterator(); - - EntityPlayer entityplayer; - - do { - if (!iterator.hasNext()) { - return null; - } - - entityplayer = (EntityPlayer) iterator.next(); - } while (!entityplayer.getName().equalsIgnoreCase(s)); - - return entityplayer; - } - - public List a(ChunkCoordinates chunkcoordinates, int i, int j, int k, int l, int i1, int j1, Map map, String s, String s1, World world) { - if (this.players.isEmpty()) { - return Collections.emptyList(); - } else { - Object object = new ArrayList(); - boolean flag = k < 0; - boolean flag1 = s != null && s.startsWith("!"); - boolean flag2 = s1 != null && s1.startsWith("!"); - int k1 = i * i; - int l1 = j * j; - - k = MathHelper.a(k); - if (flag1) { - s = s.substring(1); - } - - if (flag2) { - s1 = s1.substring(1); - } - - for (int i2 = 0; i2 < this.players.size(); ++i2) { - EntityPlayer entityplayer = (EntityPlayer) this.players.get(i2); - - if ((world == null || entityplayer.world == world) && (s == null || flag1 != s.equalsIgnoreCase(entityplayer.getName()))) { - if (s1 != null) { - ScoreboardTeamBase scoreboardteambase = entityplayer.getScoreboardTeam(); - String s2 = scoreboardteambase == null ? "" : scoreboardteambase.getName(); - - if (flag2 == s1.equalsIgnoreCase(s2)) { - continue; - } - } - - if (chunkcoordinates != null && (i > 0 || j > 0)) { - float f = chunkcoordinates.e(entityplayer.getChunkCoordinates()); - - if (i > 0 && f < (float) k1 || j > 0 && f > (float) l1) { - continue; - } - } - - if (this.a((EntityHuman) entityplayer, map) && (l == EnumGamemode.NONE.getId() || l == entityplayer.playerInteractManager.getGameMode().getId()) && (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; - } - } - - private boolean a(EntityHuman entityhuman, Map map) { - if (map != null && map.size() != 0) { - Iterator iterator = map.entrySet().iterator(); - - Entry entry; - boolean flag; - int i; - - do { - if (!iterator.hasNext()) { - return true; - } - - entry = (Entry) iterator.next(); - String s = (String) entry.getKey(); - - flag = false; - if (s.endsWith("_min") && s.length() > 4) { - flag = true; - s = s.substring(0, s.length() - 4); - } - - Scoreboard scoreboard = entityhuman.getScoreboard(); - ScoreboardObjective scoreboardobjective = scoreboard.getObjective(s); - - if (scoreboardobjective == null) { - return false; - } - - ScoreboardScore scoreboardscore = entityhuman.getScoreboard().getPlayerScoreForObjective(entityhuman.getName(), scoreboardobjective); - - i = scoreboardscore.getScore(); - if (i < ((Integer) entry.getValue()).intValue() && flag) { - return false; - } - } while (i <= ((Integer) entry.getValue()).intValue() || flag); - - return false; - } else { - return true; - } - } - - 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); - } - - public void sendPacketNearby(EntityHuman entityhuman, double d0, double d1, double d2, double d3, int i, Packet packet) { - for (int j = 0; j < this.players.size(); ++j) { - EntityPlayer entityplayer = (EntityPlayer) this.players.get(j); - - // CraftBukkit start - Test if player receiving packet can see the source of the packet - if (entityhuman != null && entityhuman instanceof EntityPlayer && !entityplayer.getBukkitEntity().canSee(((EntityPlayer) entityhuman).getBukkitEntity())) { - continue; - } - // CraftBukkit end - - if (entityplayer != entityhuman && entityplayer.dimension == i) { - double d4 = d0 - entityplayer.locX; - double d5 = d1 - entityplayer.locY; - double d6 = d2 - entityplayer.locZ; - - if (d4 * d4 + d5 * d5 + d6 * d6 < d3 * d3) { - entityplayer.playerConnection.sendPacket(packet); - } - } - } - } - - public void savePlayers() { - for (int i = 0; i < this.players.size(); ++i) { - this.b((EntityPlayer) this.players.get(i)); - } - } - - public void addWhitelist(GameProfile gameprofile) { - this.whitelist.add(new WhiteListEntry(gameprofile)); - } - - public void removeWhitelist(GameProfile gameprofile) { - this.whitelist.remove(gameprofile); - } - - public WhiteList getWhitelist() { - return this.whitelist; - } - - public String[] getWhitelisted() { - return this.whitelist.getEntries(); - } - - public OpList getOPs() { - return this.operators; - } - - public String[] n() { - return this.operators.getEntries(); - } - - public void reloadWhitelist() {} - - public void b(EntityPlayer entityplayer, WorldServer worldserver) { - entityplayer.playerConnection.sendPacket(new PacketPlayOutUpdateTime(worldserver.getTime(), worldserver.getDayTime(), worldserver.getGameRules().getBoolean("doDaylightCycle"))); - if (worldserver.Q()) { - // CraftBukkit start - handle player weather - // entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(1, 0.0F)); - // entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(7, worldserver.j(1.0F))); - // entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(8, worldserver.h(1.0F))); - entityplayer.setPlayerWeather(org.bukkit.WeatherType.DOWNFALL, false); - // CraftBukkit end - } - } - - public void updateClient(EntityPlayer entityplayer) { - entityplayer.updateInventory(entityplayer.defaultContainer); - entityplayer.getBukkitEntity().updateScaledHealth(); // CraftBukkit - Update scaled health on respawn and worldchange - entityplayer.playerConnection.sendPacket(new PacketPlayOutHeldItemSlot(entityplayer.inventory.itemInHandIndex)); - } - - public int getPlayerCount() { - return this.players.size(); - } - - public int getMaxPlayers() { - return this.maxPlayers; - } - - public String[] getSeenPlayers() { - // CraftBukkit - fix reference to worldserver array - return this.server.worlds.get(0).getDataManager().getPlayerFileData().getSeenPlayers(); - } - - public boolean getHasWhitelist() { - return this.hasWhitelist; - } - - public void setHasWhitelist(boolean flag) { - this.hasWhitelist = flag; - } - - public List b(String s) { - ArrayList arraylist = new ArrayList(); - Iterator iterator = this.players.iterator(); - - while (iterator.hasNext()) { - EntityPlayer entityplayer = (EntityPlayer) iterator.next(); - - if (entityplayer.s().equals(s)) { - arraylist.add(entityplayer); - } - } - - return arraylist; - } - - public int s() { - return this.q; - } - - public MinecraftServer getServer() { - return this.server; - } - - public NBTTagCompound t() { - return null; - } - - private void a(EntityPlayer entityplayer, EntityPlayer entityplayer1, World world) { - if (entityplayer1 != null) { - entityplayer.playerInteractManager.setGameMode(entityplayer1.playerInteractManager.getGameMode()); - } else if (this.r != null) { - entityplayer.playerInteractManager.setGameMode(this.r); - } - - entityplayer.playerInteractManager.b(world.getWorldData().getGameType()); - } - - public void u() { - for (int i = 0; i < this.players.size(); ++i) { - ((EntityPlayer) this.players.get(i)).playerConnection.disconnect(this.server.server.getShutdownMessage()); // CraftBukkit - add custom shutdown message - } - } - - // CraftBukkit start - Support multi-line messages - public void sendMessage(IChatBaseComponent[] ichatbasecomponent) { - for (IChatBaseComponent component : ichatbasecomponent) { - sendMessage(component, true); - } - } - // CraftBukkit end - - public void sendMessage(IChatBaseComponent ichatbasecomponent, boolean flag) { - this.server.sendMessage(ichatbasecomponent); - this.sendAll(new PacketPlayOutChat(ichatbasecomponent, flag)); - } - - public void sendMessage(IChatBaseComponent ichatbasecomponent) { - this.sendMessage(ichatbasecomponent, true); - } - - public ServerStatisticManager a(EntityHuman entityhuman) { - UUID uuid = entityhuman.getUniqueID(); - ServerStatisticManager serverstatisticmanager = uuid == null ? null : (ServerStatisticManager) this.n.get(uuid); - - if (serverstatisticmanager == null) { - File file1 = new File(this.server.getWorldServer(0).getDataManager().getDirectory(), "stats"); - File file2 = new File(file1, uuid.toString() + ".json"); - - if (!file2.exists()) { - File file3 = new File(file1, entityhuman.getName() + ".json"); - - if (file3.exists() && file3.isFile()) { - file3.renameTo(file2); - } - } - - serverstatisticmanager = new ServerStatisticManager(this.server, file2); - serverstatisticmanager.a(); - this.n.put(uuid, serverstatisticmanager); - } - - return serverstatisticmanager; - } - - public void a(int i) { - this.q = i; - if (this.server.worldServer != null) { - WorldServer[] aworldserver = this.server.worldServer; - int j = aworldserver.length; - - for (int k = 0; k < j; ++k) { - WorldServer worldserver = aworldserver[k]; - - if (worldserver != null) { - worldserver.getPlayerChunkMap().a(i); - } - } - } - } -} diff --git a/src/main/java/net/minecraft/server/PlayerSelector.java b/src/main/java/net/minecraft/server/PlayerSelector.java deleted file mode 100644 index 819a1333..00000000 --- a/src/main/java/net/minecraft/server/PlayerSelector.java +++ /dev/null @@ -1,247 +0,0 @@ -package net.minecraft.server; - -import java.util.*; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -public class PlayerSelector { - - private static final Pattern a = Pattern.compile("^@([parf])(?:\\[([\\w=,!-]*)\\])?$"); - private static final Pattern b = Pattern.compile("\\G([-!]?[\\w-]*)(?:$|,)"); - private static final Pattern c = Pattern.compile("\\G(\\w+)=([-!]?[\\w-]*)(?:$|,)"); - - public static EntityPlayer getPlayer(ICommandListener icommandlistener, String s) { - EntityPlayer[] aentityplayer = getPlayers(icommandlistener, s); - - return aentityplayer != null && aentityplayer.length == 1 ? aentityplayer[0] : null; - } - - public static IChatBaseComponent getPlayerNames(ICommandListener icommandlistener, String s) { - EntityPlayer[] aentityplayer = getPlayers(icommandlistener, s); - - if (aentityplayer != null && aentityplayer.length != 0) { - IChatBaseComponent[] aichatbasecomponent = new IChatBaseComponent[aentityplayer.length]; - - for (int i = 0; i < aichatbasecomponent.length; ++i) { - aichatbasecomponent[i] = aentityplayer[i].getScoreboardDisplayName(); - } - - return CommandAbstract.a(aichatbasecomponent); - } else { - return null; - } - } - - public static EntityPlayer[] getPlayers(ICommandListener icommandlistener, String s) { - // CraftBukkit start - disable playerselections for ICommandListeners other than command blocks - if (!(icommandlistener instanceof CommandBlockListenerAbstract)) { - return null; - } - // CraftBukkit end - - Matcher matcher = a.matcher(s); - - if (matcher.matches()) { - Map map = h(matcher.group(2)); - String s1 = matcher.group(1); - int i = c(s1); - int j = d(s1); - int k = f(s1); - int l = e(s1); - int i1 = g(s1); - int j1 = EnumGamemode.NONE.getId(); - ChunkCoordinates chunkcoordinates = icommandlistener.getChunkCoordinates(); - Map map1 = a(map); - String s2 = null; - String s3 = null; - boolean flag = false; - - if (map.containsKey("rm")) { - i = MathHelper.a((String) map.get("rm"), i); - flag = true; - } - - if (map.containsKey("r")) { - j = MathHelper.a((String) map.get("r"), j); - flag = true; - } - - if (map.containsKey("lm")) { - k = MathHelper.a((String) map.get("lm"), k); - } - - if (map.containsKey("l")) { - l = MathHelper.a((String) map.get("l"), l); - } - - if (map.containsKey("x")) { - chunkcoordinates.x = MathHelper.a((String) map.get("x"), chunkcoordinates.x); - flag = true; - } - - if (map.containsKey("y")) { - chunkcoordinates.y = MathHelper.a((String) map.get("y"), chunkcoordinates.y); - flag = true; - } - - if (map.containsKey("z")) { - chunkcoordinates.z = MathHelper.a((String) map.get("z"), chunkcoordinates.z); - flag = true; - } - - if (map.containsKey("m")) { - j1 = MathHelper.a((String) map.get("m"), j1); - } - - if (map.containsKey("c")) { - i1 = MathHelper.a((String) map.get("c"), i1); - } - - if (map.containsKey("team")) { - s3 = (String) map.get("team"); - } - - if (map.containsKey("name")) { - s2 = (String) map.get("name"); - } - - World world = flag ? icommandlistener.getWorld() : null; - List list; - - if (!s1.equals("p") && !s1.equals("a")) { - if (s1.equals("r")) { - list = MinecraftServer.getServer().getPlayerList().a(chunkcoordinates, i, j, 0, j1, k, l, map1, s2, s3, world); - Collections.shuffle(list); - list = list.subList(0, Math.min(i1, list.size())); - return list.isEmpty() ? new EntityPlayer[0] : (EntityPlayer[]) list.toArray(new EntityPlayer[list.size()]); - } else { - return null; - } - } else { - list = MinecraftServer.getServer().getPlayerList().a(chunkcoordinates, i, j, i1, j1, k, l, map1, s2, s3, world); - return list.isEmpty() ? new EntityPlayer[0] : (EntityPlayer[]) list.toArray(new EntityPlayer[list.size()]); - } - } else { - return null; - } - } - - public static Map a(Map map) { - HashMap hashmap = new HashMap(); - Iterator iterator = map.keySet().iterator(); - - while (iterator.hasNext()) { - String s = (String) iterator.next(); - - if (s.startsWith("score_") && s.length() > "score_".length()) { - String s1 = s.substring("score_".length()); - - hashmap.put(s1, Integer.valueOf(MathHelper.a((String) map.get(s), 1))); - } - } - - return hashmap; - } - - public static boolean isList(String s) { - Matcher matcher = a.matcher(s); - - if (matcher.matches()) { - Map map = h(matcher.group(2)); - String s1 = matcher.group(1); - int i = g(s1); - - if (map.containsKey("c")) { - i = MathHelper.a((String) map.get("c"), i); - } - - return i != 1; - } else { - return false; - } - } - - public static boolean isPattern(String s, String s1) { - Matcher matcher = a.matcher(s); - - if (matcher.matches()) { - String s2 = matcher.group(1); - - return s1 == null || s1.equals(s2); - } else { - return false; - } - } - - public static boolean isPattern(String s) { - return isPattern(s, (String) null); - } - - private static final int c(String s) { - return 0; - } - - private static final int d(String s) { - return 0; - } - - private static final int e(String s) { - return Integer.MAX_VALUE; - } - - private static final int f(String s) { - return 0; - } - - private static final int g(String s) { - return s.equals("a") ? 0 : 1; - } - - private static Map h(String s) { - HashMap hashmap = new HashMap(); - - if (s == null) { - return hashmap; - } else { - Matcher matcher = b.matcher(s); - int i = 0; - - int j; - - for (j = -1; matcher.find(); j = matcher.end()) { - String s1 = null; - - switch (i++) { - case 0: - s1 = "x"; - break; - - case 1: - s1 = "y"; - break; - - case 2: - s1 = "z"; - break; - - case 3: - s1 = "r"; - } - - if (s1 != null && matcher.group(1).length() > 0) { - hashmap.put(s1, matcher.group(1)); - } - } - - if (j < s.length()) { - matcher = c.matcher(j == -1 ? s : s.substring(j)); - - while (matcher.find()) { - hashmap.put(matcher.group(1), matcher.group(2)); - } - } - - return hashmap; - } - } -} diff --git a/src/main/java/net/minecraft/server/PortalCreator.java b/src/main/java/net/minecraft/server/PortalCreator.java deleted file mode 100644 index 309239de..00000000 --- a/src/main/java/net/minecraft/server/PortalCreator.java +++ /dev/null @@ -1,197 +0,0 @@ -package net.minecraft.server; - -import org.bukkit.event.world.PortalCreateEvent; // CraftBukkit - -public class PortalCreator { - - private final World a; - private final int b; - private final int c; - private final int d; - private int e = 0; - private ChunkCoordinates f; - private int g; - private int h; - java.util.Collection<org.bukkit.block.Block> blocks = new java.util.HashSet<org.bukkit.block.Block>(); // CraftBukkit - add field - - public PortalCreator(World world, int i, int j, int k, int l) { - this.a = world; - this.b = l; - this.d = BlockPortal.a[l][0]; - this.c = BlockPortal.a[l][1]; - - for (int i1 = j; j > i1 - 21 && j > 0 && this.a(world.getType(i, j - 1, k)); --j) { - ; - } - - int j1 = this.a(i, j, k, this.d) - 1; - - if (j1 >= 0) { - this.f = new ChunkCoordinates(i + j1 * Direction.a[this.d], j, k + j1 * Direction.b[this.d]); - this.h = this.a(this.f.x, this.f.y, this.f.z, this.c); - if (this.h < 2 || this.h > 21) { - this.f = null; - this.h = 0; - } - } - - if (this.f != null) { - this.g = this.a(); - } - } - - protected int a(int i, int j, int k, int l) { - int i1 = Direction.a[l]; - int j1 = Direction.b[l]; - - int k1; - Block block; - - for (k1 = 0; k1 < 22; ++k1) { - block = this.a.getType(i + i1 * k1, j, k + j1 * k1); - if (!this.a(block)) { - break; - } - - Block block1 = this.a.getType(i + i1 * k1, j - 1, k + j1 * k1); - - if (block1 != Blocks.OBSIDIAN) { - break; - } - } - - block = this.a.getType(i + i1 * k1, j, k + j1 * k1); - return block == Blocks.OBSIDIAN ? k1 : 0; - } - - protected int a() { - // CraftBukkit start - this.blocks.clear(); - org.bukkit.World bworld = this.a.getWorld(); - // CraftBukkit end - int i; - int j; - int k; - int l; - - label56: - for (this.g = 0; this.g < 21; ++this.g) { - i = this.f.y + this.g; - - for (j = 0; j < this.h; ++j) { - k = this.f.x + j * Direction.a[BlockPortal.a[this.b][1]]; - l = this.f.z + j * Direction.b[BlockPortal.a[this.b][1]]; - Block block = this.a.getType(k, i, l); - - if (!this.a(block)) { - break label56; - } - - if (block == Blocks.PORTAL) { - ++this.e; - } - - if (j == 0) { - block = this.a.getType(k + Direction.a[BlockPortal.a[this.b][0]], i, l + Direction.b[BlockPortal.a[this.b][0]]); - if (block != Blocks.OBSIDIAN) { - break label56; - // CraftBukkit start - add the block to our list - } else { - blocks.add(bworld.getBlockAt(k + Direction.a[BlockPortal.a[this.b][0]], i, l + Direction.b[BlockPortal.a[this.b][0]])); - // CraftBukkit end - } - } else if (j == this.h - 1) { - block = this.a.getType(k + Direction.a[BlockPortal.a[this.b][1]], i, l + Direction.b[BlockPortal.a[this.b][1]]); - if (block != Blocks.OBSIDIAN) { - break label56; - // CraftBukkit start - add the block to our list - } else { - blocks.add(bworld.getBlockAt(k + Direction.a[BlockPortal.a[this.b][1]], i, l + Direction.b[BlockPortal.a[this.b][1]])); - // CraftBukkit end - } - } - } - } - - for (i = 0; i < this.h; ++i) { - j = this.f.x + i * Direction.a[BlockPortal.a[this.b][1]]; - k = this.f.y + this.g; - l = this.f.z + i * Direction.b[BlockPortal.a[this.b][1]]; - if (this.a.getType(j, k, l) != Blocks.OBSIDIAN) { - this.g = 0; - break; - // CraftBukkit start - add the block to our list - } else { - blocks.add(bworld.getBlockAt(j, k, l)); - // CraftBukkit end - } - } - - if (this.g <= 21 && this.g >= 3) { - return this.g; - } else { - this.f = null; - this.h = 0; - this.g = 0; - return 0; - } - } - - protected boolean a(Block block) { - return block.material == Material.AIR || block == Blocks.FIRE || block == Blocks.PORTAL; - } - - public boolean b() { - return this.f != null && this.h >= 2 && this.h <= 21 && this.g >= 3 && this.g <= 21; - } - - // CraftBukkit start - return boolean - public boolean c() { - org.bukkit.World bworld = this.a.getWorld(); - - // Copy below for loop - for (int i = 0; i < this.h; ++i) { - int j = this.f.x + Direction.a[this.c] * i; - int k = this.f.z + Direction.b[this.c] * i; - - for (int l = 0; l < this.g; ++l) { - int i1 = this.f.y + l; - - blocks.add(bworld.getBlockAt(j, i1, k)); - } - } - - PortalCreateEvent event = new PortalCreateEvent(blocks, bworld, PortalCreateEvent.CreateReason.FIRE); - this.a.getServer().getPluginManager().callEvent(event); - - if (event.isCancelled()) { - return false; - } - // CraftBukkit end - - for (int i = 0; i < this.h; ++i) { - int j = this.f.x + Direction.a[this.c] * i; - int k = this.f.z + Direction.b[this.c] * i; - - for (int l = 0; l < this.g; ++l) { - int i1 = this.f.y + l; - - this.a.setTypeAndData(j, i1, k, Blocks.PORTAL, this.b, 2); - } - } - - return true; // CraftBukkit - } - - static int a(PortalCreator portalcreator) { - return portalcreator.e; - } - - static int b(PortalCreator portalcreator) { - return portalcreator.h; - } - - static int c(PortalCreator portalcreator) { - return portalcreator.g; - } -} diff --git a/src/main/java/net/minecraft/server/PortalTravelAgent.java b/src/main/java/net/minecraft/server/PortalTravelAgent.java deleted file mode 100644 index 70e6e81d..00000000 --- a/src/main/java/net/minecraft/server/PortalTravelAgent.java +++ /dev/null @@ -1,533 +0,0 @@ -package net.minecraft.server; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Random; - -// CraftBukkit start -import org.bukkit.Location; -import org.bukkit.event.entity.EntityPortalExitEvent; -import org.bukkit.util.Vector; -// CraftBukkit end - -public class PortalTravelAgent { - - private final WorldServer a; - private final Random b; - private final LongHashMap c = new LongHashMap(); - private final List d = new ArrayList(); - - public PortalTravelAgent(WorldServer worldserver) { - this.a = worldserver; - this.b = new Random(worldserver.getSeed()); - } - - public void a(Entity entity, double d0, double d1, double d2, float f) { - if (this.a.worldProvider.dimension != 1) { - if (!this.b(entity, d0, d1, d2, f)) { - this.a(entity); - this.b(entity, d0, d1, d2, f); - } - } else { - // CraftBukkit start - Modularize end portal creation - ChunkCoordinates created = this.createEndPortal(d0, d1, d2); - entity.setPositionRotation((double) created.x, (double) created.y, (double) created.z, entity.yaw, 0.0F); - entity.motX = entity.motY = entity.motZ = 0.0D; - } - } - - // Split out from original a(Entity, double, double, double, float) method in order to enable being called from createPortal - private ChunkCoordinates createEndPortal(double x, double y, double z) { - int i = MathHelper.floor(x); - int j = MathHelper.floor(y) - 1; - int k = MathHelper.floor(z); - // CraftBukkit end - byte b0 = 1; - byte b1 = 0; - - for (int l = -2; l <= 2; ++l) { - for (int i1 = -2; i1 <= 2; ++i1) { - for (int j1 = -1; j1 < 3; ++j1) { - int k1 = i + i1 * b0 + l * b1; - int l1 = j + j1; - int i2 = k + i1 * b1 - l * b0; - boolean flag = j1 < 0; - - this.a.setTypeUpdate(k1, l1, i2, flag ? Blocks.OBSIDIAN : Blocks.AIR); - } - } - } - - // CraftBukkit start - return new ChunkCoordinates(i, j, k); - } - - // use logic based on creation to verify end portal - private ChunkCoordinates findEndPortal(ChunkCoordinates portal) { - int i = portal.x; - int j = portal.y - 1; - int k = portal.z; - byte b0 = 1; - byte b1 = 0; - - for (int l = -2; l <= 2; ++l) { - for (int i1 = -2; i1 <= 2; ++i1) { - for (int j1 = -1; j1 < 3; ++j1) { - int k1 = i + i1 * b0 + l * b1; - int l1 = j + j1; - int i2 = k + i1 * b1 - l * b0; - boolean flag = j1 < 0; - - if (this.a.getType(k1, l1, i2) != (flag ? Blocks.OBSIDIAN : Blocks.AIR)) { - return null; - } - } - } - } - return new ChunkCoordinates(i, j, k); - } - // CraftBukkit end - - public boolean b(Entity entity, double d0, double d1, double d2, float f) { - // CraftBukkit start - Modularize portal search process and entity teleportation - ChunkCoordinates found = this.findPortal(entity.locX, entity.locY, entity.locZ, 128); - if (found == null) { - return false; - } - - Location exit = new Location(this.a.getWorld(), found.x, found.y, found.z, f, entity.pitch); - Vector velocity = entity.getBukkitEntity().getVelocity(); - this.adjustExit(entity, exit, velocity); - entity.setPositionRotation(exit.getX(), exit.getY(), exit.getZ(), exit.getYaw(), exit.getPitch()); - if (entity.motX != velocity.getX() || entity.motY != velocity.getY() || entity.motZ != velocity.getZ()) { - entity.getBukkitEntity().setVelocity(velocity); - } - return true; - } - - public ChunkCoordinates findPortal(double x, double y, double z, int short1) { - if (this.a.getWorld().getEnvironment() == org.bukkit.World.Environment.THE_END) { - return this.findEndPortal(this.a.worldProvider.h()); - } - // CraftBukkit end - double d3 = -1.0D; - int i = 0; - int j = 0; - int k = 0; - // CraftBukkit start - int l = MathHelper.floor(x); - int i1 = MathHelper.floor(z); - // CraftBukkit end - long j1 = ChunkCoordIntPair.a(l, i1); - boolean flag = true; - double d4; - int k1; - - if (this.c.contains(j1)) { - ChunkCoordinatesPortal chunkcoordinatesportal = (ChunkCoordinatesPortal) this.c.getEntry(j1); - - d3 = 0.0D; - i = chunkcoordinatesportal.x; - j = chunkcoordinatesportal.y; - k = chunkcoordinatesportal.z; - chunkcoordinatesportal.d = this.a.getTime(); - flag = false; - } else { - for (k1 = l - short1; k1 <= l + short1; ++k1) { - double d5 = (double) k1 + 0.5D - x; // CraftBukkit - - for (int l1 = i1 - short1; l1 <= i1 + short1; ++l1) { - double d6 = (double) l1 + 0.5D - z; // CraftBukkit - - for (int i2 = this.a.S() - 1; i2 >= 0; --i2) { - if (this.a.getType(k1, i2, l1) == Blocks.PORTAL) { - while (this.a.getType(k1, i2 - 1, l1) == Blocks.PORTAL) { - --i2; - } - - d4 = (double) i2 + 0.5D - y; // CraftBukkit - double d7 = d5 * d5 + d4 * d4 + d6 * d6; - - if (d3 < 0.0D || d7 < d3) { - d3 = d7; - i = k1; - j = i2; - k = l1; - } - } - } - } - } - } - - if (d3 >= 0.0D) { - if (flag) { - this.c.put(j1, new ChunkCoordinatesPortal(this, i, j, k, this.a.getTime())); - this.d.add(Long.valueOf(j1)); - } - // CraftBukkit start - Moved entity teleportation logic into exit - return new ChunkCoordinates(i, j, k); - } else { - return null; - } - } - // Entity repositioning logic split out from original b method and combined with repositioning logic for The End from original a method - public void adjustExit(Entity entity, Location position, Vector velocity) { - Location from = position.clone(); - Vector before = velocity.clone(); - int i = position.getBlockX(); - int j = position.getBlockY(); - int k = position.getBlockZ(); - float f = position.getYaw(); - - if (this.a.getWorld().getEnvironment() == org.bukkit.World.Environment.THE_END) { - // entity.setPositionRotation((double) i, (double) j, (double) k, entity.yaw, 0.0F); - // entity.motX = entity.motY = entity.motZ = 0.0D; - position.setPitch(0.0F); - velocity.setX(0); - velocity.setY(0); - velocity.setZ(0); - } else { - double d4; - int k1; - // CraftBukkit end - - double d8 = (double) i + 0.5D; - double d9 = (double) j + 0.5D; - - d4 = (double) k + 0.5D; - int j2 = -1; - - if (this.a.getType(i - 1, j, k) == Blocks.PORTAL) { - j2 = 2; - } - - if (this.a.getType(i + 1, j, k) == Blocks.PORTAL) { - j2 = 0; - } - - if (this.a.getType(i, j, k - 1) == Blocks.PORTAL) { - j2 = 3; - } - - if (this.a.getType(i, j, k + 1) == Blocks.PORTAL) { - j2 = 1; - } - - int k2 = entity.ay(); - - if (j2 > -1) { - int l2 = Direction.h[j2]; - int i3 = Direction.a[j2]; - int j3 = Direction.b[j2]; - int k3 = Direction.a[l2]; - int l3 = Direction.b[l2]; - boolean flag1 = !this.a.isEmpty(i + i3 + k3, j, k + j3 + l3) || !this.a.isEmpty(i + i3 + k3, j + 1, k + j3 + l3); - boolean flag2 = !this.a.isEmpty(i + i3, j, k + j3) || !this.a.isEmpty(i + i3, j + 1, k + j3); - - if (flag1 && flag2) { - j2 = Direction.f[j2]; - l2 = Direction.f[l2]; - i3 = Direction.a[j2]; - j3 = Direction.b[j2]; - k3 = Direction.a[l2]; - l3 = Direction.b[l2]; - k1 = i - k3; - d8 -= (double) k3; - int i4 = k - l3; - - d4 -= (double) l3; - flag1 = !this.a.isEmpty(k1 + i3 + k3, j, i4 + j3 + l3) || !this.a.isEmpty(k1 + i3 + k3, j + 1, i4 + j3 + l3); - flag2 = !this.a.isEmpty(k1 + i3, j, i4 + j3) || !this.a.isEmpty(k1 + i3, j + 1, i4 + j3); - } - - float f1 = 0.5F; - float f2 = 0.5F; - - if (!flag1 && flag2) { - f1 = 1.0F; - } else if (flag1 && !flag2) { - f1 = 0.0F; - } else if (flag1 && flag2) { - f2 = 0.0F; - } - - d8 += (double) ((float) k3 * f1 + f2 * (float) i3); - d4 += (double) ((float) l3 * f1 + f2 * (float) j3); - float f3 = 0.0F; - float f4 = 0.0F; - float f5 = 0.0F; - float f6 = 0.0F; - - if (j2 == k2) { - f3 = 1.0F; - f4 = 1.0F; - } else if (j2 == Direction.f[k2]) { - f3 = -1.0F; - f4 = -1.0F; - } else if (j2 == Direction.g[k2]) { - f5 = 1.0F; - f6 = -1.0F; - } else { - f5 = -1.0F; - f6 = 1.0F; - } - - // CraftBukkit start - double d10 = velocity.getX(); - double d11 = velocity.getZ(); - // CraftBukkit end - - // CraftBukkit start - Adjust position and velocity instances instead of entity - velocity.setX(d10 * (double) f3 + d11 * (double) f6); - velocity.setZ(d10 * (double) f5 + d11 * (double) f4); - f = f - (float) (k2 * 90) + (float) (j2 * 90); - } else { - // entity.motX = entity.motY = entity.motZ = 0.0D; - velocity.setX(0); - velocity.setY(0); - velocity.setZ(0); - } - - // entity.setPositionRotation(d8, d9, d4, entity.yaw, entity.pitch); - position.setX(d8); - position.setY(d9); - position.setZ(d4); - position.setYaw(f); - } - - EntityPortalExitEvent event = new EntityPortalExitEvent(entity.getBukkitEntity(), from, position, before, velocity); - this.a.getServer().getPluginManager().callEvent(event); - Location to = event.getTo(); - if (event.isCancelled() || to == null || !entity.isAlive()) { - position.setX(from.getX()); - position.setY(from.getY()); - position.setZ(from.getZ()); - position.setYaw(from.getYaw()); - position.setPitch(from.getPitch()); - velocity.copy(before); - } else { - position.setX(to.getX()); - position.setY(to.getY()); - position.setZ(to.getZ()); - position.setYaw(to.getYaw()); - position.setPitch(to.getPitch()); - velocity.copy(event.getAfter()); // event.getAfter() will never be null, as setAfter() will cause an NPE if null is passed in - } - // CraftBukkit end - } - - public boolean a(Entity entity) { - // CraftBukkit start - Allow for portal creation to be based on coordinates instead of entity - return this.createPortal(entity.locX, entity.locY, entity.locZ, 16); - } - - public boolean createPortal(double x, double y, double z, int b0) { - if (this.a.getWorld().getEnvironment() == org.bukkit.World.Environment.THE_END) { - this.createEndPortal(x, y, z); - return true; - } - // CraftBukkit end - double d0 = -1.0D; - // CraftBukkit start - int i = MathHelper.floor(x); - int j = MathHelper.floor(y); - int k = MathHelper.floor(z); - // CraftBukkit end - int l = i; - int i1 = j; - int j1 = k; - int k1 = 0; - int l1 = this.b.nextInt(4); - - int i2; - double d1; - double d2; - int j2; - int k2; - int l2; - int i3; - int j3; - int k3; - int l3; - int i4; - int j4; - int k4; - double d3; - double d4; - - for (i2 = i - b0; i2 <= i + b0; ++i2) { - d1 = (double) i2 + 0.5D - x; // CraftBukkit - - for (j2 = k - b0; j2 <= k + b0; ++j2) { - d2 = (double) j2 + 0.5D - z; // CraftBukkit - - label274: - for (k2 = this.a.S() - 1; k2 >= 0; --k2) { - if (this.a.isEmpty(i2, k2, j2)) { - while (k2 > 0 && this.a.isEmpty(i2, k2 - 1, j2)) { - --k2; - } - - for (i3 = l1; i3 < l1 + 4; ++i3) { - l2 = i3 % 2; - k3 = 1 - l2; - if (i3 % 4 >= 2) { - l2 = -l2; - k3 = -k3; - } - - for (j3 = 0; j3 < 3; ++j3) { - for (i4 = 0; i4 < 4; ++i4) { - for (l3 = -1; l3 < 4; ++l3) { - k4 = i2 + (i4 - 1) * l2 + j3 * k3; - j4 = k2 + l3; - int l4 = j2 + (i4 - 1) * k3 - j3 * l2; - - if (l3 < 0 && !this.a.getType(k4, j4, l4).getMaterial().isBuildable() || l3 >= 0 && !this.a.isEmpty(k4, j4, l4)) { - continue label274; - } - } - } - } - - d3 = (double) k2 + 0.5D - y; // CraftBukkit - d4 = d1 * d1 + d3 * d3 + d2 * d2; - if (d0 < 0.0D || d4 < d0) { - d0 = d4; - l = i2; - i1 = k2; - j1 = j2; - k1 = i3 % 4; - } - } - } - } - } - } - - if (d0 < 0.0D) { - for (i2 = i - b0; i2 <= i + b0; ++i2) { - d1 = (double) i2 + 0.5D - x; // CraftBukkit - - for (j2 = k - b0; j2 <= k + b0; ++j2) { - d2 = (double) j2 + 0.5D - z; // CraftBukkit - - label222: - for (k2 = this.a.S() - 1; k2 >= 0; --k2) { - if (this.a.isEmpty(i2, k2, j2)) { - while (k2 > 0 && this.a.isEmpty(i2, k2 - 1, j2)) { - --k2; - } - - for (i3 = l1; i3 < l1 + 2; ++i3) { - l2 = i3 % 2; - k3 = 1 - l2; - - for (j3 = 0; j3 < 4; ++j3) { - for (i4 = -1; i4 < 4; ++i4) { - l3 = i2 + (j3 - 1) * l2; - k4 = k2 + i4; - j4 = j2 + (j3 - 1) * k3; - if (i4 < 0 && !this.a.getType(l3, k4, j4).getMaterial().isBuildable() || i4 >= 0 && !this.a.isEmpty(l3, k4, j4)) { - continue label222; - } - } - } - - d3 = (double) k2 + 0.5D - y; // CraftBukkit - d4 = d1 * d1 + d3 * d3 + d2 * d2; - if (d0 < 0.0D || d4 < d0) { - d0 = d4; - l = i2; - i1 = k2; - j1 = j2; - k1 = i3 % 2; - } - } - } - } - } - } - } - - int i5 = l; - int j5 = i1; - - j2 = j1; - int k5 = k1 % 2; - int l5 = 1 - k5; - - if (k1 % 4 >= 2) { - k5 = -k5; - l5 = -l5; - } - - boolean flag; - - if (d0 < 0.0D) { - if (i1 < 70) { - i1 = 70; - } - - if (i1 > this.a.S() - 10) { - i1 = this.a.S() - 10; - } - - j5 = i1; - - for (k2 = -1; k2 <= 1; ++k2) { - for (i3 = 1; i3 < 3; ++i3) { - for (l2 = -1; l2 < 3; ++l2) { - k3 = i5 + (i3 - 1) * k5 + k2 * l5; - j3 = j5 + l2; - i4 = j2 + (i3 - 1) * l5 - k2 * k5; - flag = l2 < 0; - this.a.setTypeUpdate(k3, j3, i4, flag ? Blocks.OBSIDIAN : Blocks.AIR); - } - } - } - } - - for (k2 = 0; k2 < 4; ++k2) { - for (i3 = 0; i3 < 4; ++i3) { - for (l2 = -1; l2 < 4; ++l2) { - k3 = i5 + (i3 - 1) * k5; - j3 = j5 + l2; - i4 = j2 + (i3 - 1) * l5; - flag = i3 == 0 || i3 == 3 || l2 == -1 || l2 == 3; - this.a.setTypeAndData(k3, j3, i4, flag ? Blocks.OBSIDIAN : Blocks.PORTAL, 0, 2); - } - } - - for (i3 = 0; i3 < 4; ++i3) { - for (l2 = -1; l2 < 4; ++l2) { - k3 = i5 + (i3 - 1) * k5; - j3 = j5 + l2; - i4 = j2 + (i3 - 1) * l5; - this.a.applyPhysics(k3, j3, i4, this.a.getType(k3, j3, i4)); - } - } - } - - return true; - } - - public void a(long i) { - if (i % 100L == 0L) { - Iterator iterator = this.d.iterator(); - long j = i - 600L; - - while (iterator.hasNext()) { - Long olong = (Long) iterator.next(); - ChunkCoordinatesPortal chunkcoordinatesportal = (ChunkCoordinatesPortal) this.c.getEntry(olong.longValue()); - - if (chunkcoordinatesportal == null || chunkcoordinatesportal.d < j) { - iterator.remove(); - this.c.remove(olong.longValue()); - } - } - } - } -} diff --git a/src/main/java/net/minecraft/server/PropertyManager.java b/src/main/java/net/minecraft/server/PropertyManager.java deleted file mode 100644 index c6cd6fb6..00000000 --- a/src/main/java/net/minecraft/server/PropertyManager.java +++ /dev/null @@ -1,130 +0,0 @@ -package net.minecraft.server; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.Properties; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import joptsimple.OptionSet; // CraftBukkit - -public class PropertyManager { - - private static final Logger loggingAgent = LogManager.getLogger(); - public final Properties properties = new Properties(); // CraftBukkit - private -> public - private final File c; - - public PropertyManager(File file1) { - this.c = file1; - if (file1.exists()) { - FileInputStream fileinputstream = null; - - try { - fileinputstream = new FileInputStream(file1); - this.properties.load(fileinputstream); - } catch (Exception exception) { - loggingAgent.warn("Failed to load " + file1, exception); - this.a(); - } finally { - if (fileinputstream != null) { - try { - fileinputstream.close(); - } catch (IOException ioexception) { - ; - } - } - } - } else { - loggingAgent.warn(file1 + " does not exist"); - this.a(); - } - } - - // CraftBukkit start - private OptionSet options = null; - - public PropertyManager(final OptionSet options) { - this((File) options.valueOf("config")); - - this.options = options; - } - - private <T> T getOverride(String name, T value) { - if ((this.options != null) && (this.options.has(name))) { - return (T) this.options.valueOf(name); - } - - return value; - } - // CraftBukkit end - - public void a() { - loggingAgent.info("Generating new properties file"); - this.savePropertiesFile(); - } - - public void savePropertiesFile() { - FileOutputStream fileoutputstream = null; - - try { - // CraftBukkit start - Don't attempt writing to file if it's read only - if (this.c.exists() && !this.c.canWrite()) { - return; - } - // CraftBukkit end - fileoutputstream = new FileOutputStream(this.c); - this.properties.store(fileoutputstream, "Minecraft server properties"); - } catch (Exception exception) { - loggingAgent.warn("Failed to save " + this.c, exception); - this.a(); - } finally { - if (fileoutputstream != null) { - try { - fileoutputstream.close(); - } catch (IOException ioexception) { - ; - } - } - } - } - - public File c() { - return this.c; - } - - public String getString(String s, String s1) { - if (!this.properties.containsKey(s)) { - this.properties.setProperty(s, s1); - this.savePropertiesFile(); - this.savePropertiesFile(); - } - - return this.getOverride(s, this.properties.getProperty(s, s1)); // CraftBukkit - } - - public int getInt(String s, int i) { - try { - return this.getOverride(s, Integer.parseInt(this.getString(s, "" + i))); // CraftBukkit - } catch (Exception exception) { - this.properties.setProperty(s, "" + i); - this.savePropertiesFile(); - return this.getOverride(s, i); // CraftBukkit - } - } - - public boolean getBoolean(String s, boolean flag) { - try { - return this.getOverride(s, Boolean.parseBoolean(this.getString(s, "" + flag))); // CraftBukkit - } catch (Exception exception) { - this.properties.setProperty(s, "" + flag); - this.savePropertiesFile(); - return this.getOverride(s, flag); // CraftBukkit - } - } - - public void setProperty(String s, Object object) { - this.properties.setProperty(s, "" + object); - } -} diff --git a/src/main/java/net/minecraft/server/ProtocolOrdinalWrapper.java b/src/main/java/net/minecraft/server/ProtocolOrdinalWrapper.java deleted file mode 100644 index d6e7f362..00000000 --- a/src/main/java/net/minecraft/server/ProtocolOrdinalWrapper.java +++ /dev/null @@ -1,21 +0,0 @@ -package net.minecraft.server; - -// CraftBukkit - import package private class -class ProtocolOrdinalWrapper { - - static final int[] a = new int[EnumProtocol.values().length]; - - static { - try { - a[EnumProtocol.LOGIN.ordinal()] = 1; - } catch (NoSuchFieldError nosuchfielderror) { - ; - } - - try { - a[EnumProtocol.STATUS.ordinal()] = 2; - } catch (NoSuchFieldError nosuchfielderror1) { - ; - } - } -} diff --git a/src/main/java/net/minecraft/server/QueuedPacket.java b/src/main/java/net/minecraft/server/QueuedPacket.java deleted file mode 100644 index fdebf9dd..00000000 --- a/src/main/java/net/minecraft/server/QueuedPacket.java +++ /dev/null @@ -1,23 +0,0 @@ -package net.minecraft.server; - -import net.minecraft.util.io.netty.util.concurrent.GenericFutureListener; - -// CraftBukkit - imported class because the methods are package private -class QueuedPacket { - - private final Packet a; - private final GenericFutureListener[] b; - - public QueuedPacket(Packet packet, GenericFutureListener... agenericfuturelistener) { - this.a = packet; - this.b = agenericfuturelistener; - } - - static Packet a(QueuedPacket queuedpacket) { - return queuedpacket.a; - } - - static GenericFutureListener[] b(QueuedPacket queuedpacket) { - return queuedpacket.b; - } -} diff --git a/src/main/java/net/minecraft/server/RecipeArmorDye.java b/src/main/java/net/minecraft/server/RecipeArmorDye.java deleted file mode 100644 index 13bb7082..00000000 --- a/src/main/java/net/minecraft/server/RecipeArmorDye.java +++ /dev/null @@ -1,124 +0,0 @@ -package net.minecraft.server; - -import java.util.ArrayList; - -public class RecipeArmorDye extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends - - // CraftBukkit start - Delegate to new parent class with bogus info - public RecipeArmorDye() { - super(new ItemStack(Items.LEATHER_HELMET, 0, 0), java.util.Arrays.asList(new ItemStack(Items.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.m_() != EnumArmorMaterial.CLOTH || itemstack != null) { - return false; - } - - itemstack = itemstack1; - } else { - if (itemstack1.getItem() != Items.INK_SACK) { - 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.m_() != EnumArmorMaterial.CLOTH || itemstack != null) { - return null; - } - - itemstack = itemstack1.cloneItemStack(); - itemstack.count = 1; - if (itemarmor.c_(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.getItem() != Items.INK_SACK) { - return null; - } - - float[] afloat = EntitySheep.bp[BlockCloth.b(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/RecipeBookClone.java b/src/main/java/net/minecraft/server/RecipeBookClone.java deleted file mode 100644 index 8182a5fd..00000000 --- a/src/main/java/net/minecraft/server/RecipeBookClone.java +++ /dev/null @@ -1,68 +0,0 @@ -package net.minecraft.server; - -public class RecipeBookClone extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends - - // CraftBukkit start - Delegate to new parent class - public RecipeBookClone() { - super(new ItemStack(Items.WRITTEN_BOOK, 0, -1), java.util.Arrays.asList(new ItemStack(Items.BOOK_AND_QUILL, 0, 0))); - } - // CraftBukkit end - - public boolean a(InventoryCrafting inventoryCrafting, World paramWorld) { - int i = 0; - ItemStack itemStack = null; - for (int j = 0; j < inventoryCrafting.getSize(); j++) { - ItemStack itemStack1 = inventoryCrafting.getItem(j); - if (itemStack1 != null) { - if (itemStack1.getItem() == Items.WRITTEN_BOOK) { - if (itemStack != null) { - return false; - } - itemStack = itemStack1; - } else if (itemStack1.getItem() == Items.BOOK_AND_QUILL) { - i++; - } else { - return false; - } - } - } - 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 itemStack2 = inventoryCrafting.getItem(j); - if (itemStack2 != null) { - if (itemStack2.getItem() == Items.WRITTEN_BOOK) { - if (itemStack != null) { - return null; - } - itemStack = itemStack2; - } else if (itemStack2.getItem() == Items.BOOK_AND_QUILL) { - i++; - } else { - return null; - } - } - } - if ((itemStack == null) || (i < 1)) { - return null; - } - ItemStack itemStack1 = new ItemStack(Items.WRITTEN_BOOK, i + 1); - itemStack1.setTag((NBTTagCompound) itemStack.getTag().clone()); - if (itemStack.hasName()) { - itemStack1.c(itemStack.getName()); - } - return itemStack1; - } - - public int a() { - return 9; - } - - public ItemStack b() { - return null; - } -} diff --git a/src/main/java/net/minecraft/server/RecipeFireworks.java b/src/main/java/net/minecraft/server/RecipeFireworks.java deleted file mode 100644 index 816df8c1..00000000 --- a/src/main/java/net/minecraft/server/RecipeFireworks.java +++ /dev/null @@ -1,176 +0,0 @@ -package net.minecraft.server; - -import java.util.ArrayList; - -public class RecipeFireworks extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends - - private ItemStack a; - - // CraftBukkit start - Delegate to new parent class with bogus info - public RecipeFireworks() { - super(new ItemStack(Items.FIREWORKS, 0, 0), java.util.Arrays.asList(new ItemStack(Items.SULPHUR, 0, 5))); - } - // CraftBukkit end - - public boolean a(InventoryCrafting inventorycrafting, World world) { - this.a = null; - int i = 0; - int j = 0; - int k = 0; - int l = 0; - int i1 = 0; - int j1 = 0; - - for (int k1 = 0; k1 < inventorycrafting.getSize(); ++k1) { - ItemStack itemstack = inventorycrafting.getItem(k1); - - if (itemstack != null) { - if (itemstack.getItem() == Items.SULPHUR) { - ++j; - } else if (itemstack.getItem() == Items.FIREWORKS_CHARGE) { - ++l; - } else if (itemstack.getItem() == Items.INK_SACK) { - ++k; - } else if (itemstack.getItem() == Items.PAPER) { - ++i; - } else if (itemstack.getItem() == Items.GLOWSTONE_DUST) { - ++i1; - } else if (itemstack.getItem() == Items.DIAMOND) { - ++i1; - } else if (itemstack.getItem() == Items.FIREBALL) { - ++j1; - } else if (itemstack.getItem() == Items.FEATHER) { - ++j1; - } else if (itemstack.getItem() == Items.GOLD_NUGGET) { - ++j1; - } else { - if (itemstack.getItem() != Items.SKULL) { - return false; - } - - ++j1; - } - } - } - - i1 += k + j1; - if (j <= 3 && i <= 1) { - NBTTagCompound nbttagcompound; - NBTTagCompound nbttagcompound1; - - if (j >= 1 && i == 1 && i1 == 0) { - this.a = new ItemStack(Items.FIREWORKS); - if (l > 0) { - nbttagcompound = new NBTTagCompound(); - nbttagcompound1 = new NBTTagCompound(); - NBTTagList nbttaglist = new NBTTagList(); - - for (int l1 = 0; l1 < inventorycrafting.getSize(); ++l1) { - ItemStack itemstack1 = inventorycrafting.getItem(l1); - - if (itemstack1 != null && itemstack1.getItem() == Items.FIREWORKS_CHARGE && itemstack1.hasTag() && itemstack1.getTag().hasKeyOfType("Explosion", 10)) { - nbttaglist.add(itemstack1.getTag().getCompound("Explosion")); - } - } - - nbttagcompound1.set("Explosions", nbttaglist); - nbttagcompound1.setByte("Flight", (byte) j); - nbttagcompound.set("Fireworks", nbttagcompound1); - this.a.setTag(nbttagcompound); - } - - return true; - } else if (j == 1 && i == 0 && l == 0 && k > 0 && j1 <= 1) { - this.a = new ItemStack(Items.FIREWORKS_CHARGE); - nbttagcompound = new NBTTagCompound(); - nbttagcompound1 = new NBTTagCompound(); - byte b0 = 0; - ArrayList arraylist = new ArrayList(); - - for (int i2 = 0; i2 < inventorycrafting.getSize(); ++i2) { - ItemStack itemstack2 = inventorycrafting.getItem(i2); - - if (itemstack2 != null) { - if (itemstack2.getItem() == Items.INK_SACK) { - arraylist.add(Integer.valueOf(ItemDye.c[itemstack2.getData()])); - } else if (itemstack2.getItem() == Items.GLOWSTONE_DUST) { - nbttagcompound1.setBoolean("Flicker", true); - } else if (itemstack2.getItem() == Items.DIAMOND) { - nbttagcompound1.setBoolean("Trail", true); - } else if (itemstack2.getItem() == Items.FIREBALL) { - b0 = 1; - } else if (itemstack2.getItem() == Items.FEATHER) { - b0 = 4; - } else if (itemstack2.getItem() == Items.GOLD_NUGGET) { - b0 = 2; - } else if (itemstack2.getItem() == Items.SKULL) { - b0 = 3; - } - } - } - - int[] aint = new int[arraylist.size()]; - - for (int j2 = 0; j2 < aint.length; ++j2) { - aint[j2] = ((Integer) arraylist.get(j2)).intValue(); - } - - nbttagcompound1.setIntArray("Colors", aint); - nbttagcompound1.setByte("Type", b0); - nbttagcompound.set("Explosion", nbttagcompound1); - this.a.setTag(nbttagcompound); - return true; - } else if (j == 0 && i == 0 && l == 1 && k > 0 && k == i1) { - ArrayList arraylist1 = new ArrayList(); - - for (int k2 = 0; k2 < inventorycrafting.getSize(); ++k2) { - ItemStack itemstack3 = inventorycrafting.getItem(k2); - - if (itemstack3 != null) { - if (itemstack3.getItem() == Items.INK_SACK) { - arraylist1.add(Integer.valueOf(ItemDye.c[itemstack3.getData()])); - } else if (itemstack3.getItem() == Items.FIREWORKS_CHARGE) { - this.a = itemstack3.cloneItemStack(); - this.a.count = 1; - } - } - } - - int[] aint1 = new int[arraylist1.size()]; - - for (int l2 = 0; l2 < aint1.length; ++l2) { - aint1[l2] = ((Integer) arraylist1.get(l2)).intValue(); - } - - if (this.a != null && this.a.hasTag()) { - NBTTagCompound nbttagcompound2 = this.a.getTag().getCompound("Explosion"); - - if (nbttagcompound2 == null) { - return false; - } else { - nbttagcompound2.setIntArray("FadeColors", aint1); - return true; - } - } else { - return false; - } - } else { - return false; - } - } else { - return false; - } - } - - public ItemStack a(InventoryCrafting inventorycrafting) { - return this.a.cloneItemStack(); - } - - public int a() { - return 10; - } - - public ItemStack b() { - return this.a; - } -} diff --git a/src/main/java/net/minecraft/server/RecipeMapClone.java b/src/main/java/net/minecraft/server/RecipeMapClone.java deleted file mode 100644 index 793883fe..00000000 --- a/src/main/java/net/minecraft/server/RecipeMapClone.java +++ /dev/null @@ -1,82 +0,0 @@ -package net.minecraft.server; - -public class RecipeMapClone extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends - - // CraftBukkit start - Delegate to new parent class - public RecipeMapClone() { - super(new ItemStack(Items.MAP, 0, -1), java.util.Arrays.asList(new ItemStack(Items.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.getItem() == Items.MAP) { - if (itemstack != null) { - return false; - } - - itemstack = itemstack1; - } else { - if (itemstack1.getItem() != Items.MAP_EMPTY) { - 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.getItem() == Items.MAP) { - if (itemstack != null) { - return null; - } - - itemstack = itemstack1; - } else { - if (itemstack1.getItem() != Items.MAP_EMPTY) { - return null; - } - - ++i; - } - } - } - - if (itemstack != null && i >= 1) { - ItemStack itemstack2 = new ItemStack(Items.MAP, i + 1, itemstack.getData()); - - if (itemstack.hasName()) { - itemstack2.c(itemstack.getName()); - } - - return itemstack2; - } else { - return null; - } - } - - public int a() { - return 9; - } - - 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 deleted file mode 100644 index c474d548..00000000 --- a/src/main/java/net/minecraft/server/RecipesFurnace.java +++ /dev/null @@ -1,121 +0,0 @@ -package net.minecraft.server; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Map.Entry; - -public class RecipesFurnace { - - private static final RecipesFurnace a = new RecipesFurnace(); - public Map recipes = new HashMap(); // CraftBukkit - private -> public - private Map c = new HashMap(); - public Map customRecipes = new HashMap(); // CraftBukkit - add field - - public static RecipesFurnace getInstance() { - return a; - } - - public RecipesFurnace() { // CraftBukkit - private -> public - this.registerRecipe(Blocks.IRON_ORE, new ItemStack(Items.IRON_INGOT), 0.7F); - this.registerRecipe(Blocks.GOLD_ORE, new ItemStack(Items.GOLD_INGOT), 1.0F); - this.registerRecipe(Blocks.DIAMOND_ORE, new ItemStack(Items.DIAMOND), 1.0F); - this.registerRecipe(Blocks.SAND, new ItemStack(Blocks.GLASS), 0.1F); - this.a(Items.PORK, new ItemStack(Items.GRILLED_PORK), 0.35F); - this.a(Items.RAW_BEEF, new ItemStack(Items.COOKED_BEEF), 0.35F); - this.a(Items.RAW_CHICKEN, new ItemStack(Items.COOKED_CHICKEN), 0.35F); - this.registerRecipe(Blocks.COBBLESTONE, new ItemStack(Blocks.STONE), 0.1F); - this.a(Items.CLAY_BALL, new ItemStack(Items.CLAY_BRICK), 0.3F); - this.registerRecipe(Blocks.CLAY, new ItemStack(Blocks.HARDENED_CLAY), 0.35F); - this.registerRecipe(Blocks.CACTUS, new ItemStack(Items.INK_SACK, 1, 2), 0.2F); - this.registerRecipe(Blocks.LOG, new ItemStack(Items.COAL, 1, 1), 0.15F); - this.registerRecipe(Blocks.LOG2, new ItemStack(Items.COAL, 1, 1), 0.15F); - this.registerRecipe(Blocks.EMERALD_ORE, new ItemStack(Items.EMERALD), 1.0F); - this.a(Items.POTATO, new ItemStack(Items.POTATO_BAKED), 0.35F); - this.registerRecipe(Blocks.NETHERRACK, new ItemStack(Items.NETHER_BRICK), 0.1F); - EnumFish[] aenumfish = EnumFish.values(); - int i = aenumfish.length; - - for (int j = 0; j < i; ++j) { - EnumFish enumfish = aenumfish[j]; - - if (enumfish.i()) { - this.a(new ItemStack(Items.RAW_FISH, 1, enumfish.a()), new ItemStack(Items.COOKED_FISH, 1, enumfish.a()), 0.35F); - } - } - - this.registerRecipe(Blocks.COAL_ORE, new ItemStack(Items.COAL), 0.1F); - this.registerRecipe(Blocks.REDSTONE_ORE, new ItemStack(Items.REDSTONE), 0.7F); - this.registerRecipe(Blocks.LAPIS_ORE, new ItemStack(Items.INK_SACK, 1, 4), 0.2F); - this.registerRecipe(Blocks.QUARTZ_ORE, new ItemStack(Items.QUARTZ), 0.2F); - } - - public void registerRecipe(Block block, ItemStack itemstack, float f) { - this.a(Item.getItemOf(block), itemstack, f); - } - - public void a(Item item, ItemStack itemstack, float f) { - this.a(new ItemStack(item, 1, 32767), itemstack, f); - } - - public void a(ItemStack itemstack, ItemStack itemstack1, float f) { - this.recipes.put(itemstack, itemstack1); - this.c.put(itemstack1, Float.valueOf(f)); - } - - // CraftBukkit start - add method - public void registerRecipe(ItemStack itemstack, ItemStack itemstack1) { - this.customRecipes.put(itemstack, itemstack1); - } - // CraftBukkit end - - public ItemStack getResult(ItemStack itemstack) { - // CraftBukkit start - initialize to customRecipes - boolean vanilla = false; - Iterator iterator = this.customRecipes.entrySet().iterator(); - // CraftBukkit end - - Entry entry; - - do { - if (!iterator.hasNext()) { - // CraftBukkit start - fall back to vanilla recipes - if (!vanilla && recipes.size() != 0) { - iterator = this.recipes.entrySet().iterator(); - vanilla = true; - } else { - return null; - } - // CraftBukkit end - } - - entry = (Entry) iterator.next(); - } while (!this.a(itemstack, (ItemStack) entry.getKey())); - - return (ItemStack) entry.getValue(); - } - - private boolean a(ItemStack itemstack, ItemStack itemstack1) { - return itemstack1.getItem() == itemstack.getItem() && (itemstack1.getData() == 32767 || itemstack1.getData() == itemstack.getData()); - } - - public Map getRecipes() { - return this.recipes; - } - - public float b(ItemStack itemstack) { - Iterator iterator = this.c.entrySet().iterator(); - - Entry entry; - - do { - if (!iterator.hasNext()) { - return 0.0F; - } - - entry = (Entry) iterator.next(); - } while (!this.a(itemstack, (ItemStack) entry.getKey())); - - return ((Float) entry.getValue()).floatValue(); - } -} diff --git a/src/main/java/net/minecraft/server/RegionFile.java b/src/main/java/net/minecraft/server/RegionFile.java deleted file mode 100644 index 9cd34a44..00000000 --- a/src/main/java/net/minecraft/server/RegionFile.java +++ /dev/null @@ -1,289 +0,0 @@ -package net.minecraft.server; - -import java.io.BufferedInputStream; -import java.io.ByteArrayInputStream; -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.File; -import java.io.IOException; -import java.io.RandomAccessFile; -import java.util.ArrayList; -import java.util.zip.DeflaterOutputStream; -import java.util.zip.GZIPInputStream; -import java.util.zip.InflaterInputStream; - -public class RegionFile { - - private static final byte[] a = new byte[4096]; - private final File b; - private RandomAccessFile c; - private final int[] d = new int[1024]; - private final int[] e = new int[1024]; - private ArrayList f; - private int g; - private long h; - - public RegionFile(File file1) { - this.b = file1; - this.g = 0; - - try { - if (file1.exists()) { - this.h = file1.lastModified(); - } - - this.c = new RandomAccessFile(file1, "rw"); - int i; - - if (this.c.length() < 4096L) { - for (i = 0; i < 1024; ++i) { - this.c.writeInt(0); - } - - for (i = 0; i < 1024; ++i) { - this.c.writeInt(0); - } - - this.g += 8192; - } - - if ((this.c.length() & 4095L) != 0L) { - for (i = 0; (long) i < (this.c.length() & 4095L); ++i) { - this.c.write(0); - } - } - - i = (int) this.c.length() / 4096; - this.f = new ArrayList(i); - - int j; - - for (j = 0; j < i; ++j) { - this.f.add(Boolean.valueOf(true)); - } - - this.f.set(0, Boolean.valueOf(false)); - this.f.set(1, Boolean.valueOf(false)); - this.c.seek(0L); - - int k; - - for (j = 0; j < 1024; ++j) { - k = this.c.readInt(); - this.d[j] = k; - if (k != 0 && (k >> 8) + (k & 255) <= this.f.size()) { - for (int l = 0; l < (k & 255); ++l) { - this.f.set((k >> 8) + l, Boolean.valueOf(false)); - } - } - } - - for (j = 0; j < 1024; ++j) { - k = this.c.readInt(); - this.e[j] = k; - } - } catch (IOException ioexception) { - ioexception.printStackTrace(); - } - } - - // CraftBukkit start - This is a copy (sort of) of the method below it, make sure they stay in sync - public synchronized boolean chunkExists(int i, int j) { - if (this.d(i, j)) { - return false; - } else { - try { - int k = this.e(i, j); - - if (k == 0) { - return false; - } else { - int l = k >> 8; - int i1 = k & 255; - - if (l + i1 > this.f.size()) { - return false; - } - - this.c.seek((long) (l * 4096)); - int j1 = this.c.readInt(); - - if (j1 > 4096 * i1 || j1 <= 0) { - return false; - } - - byte b0 = this.c.readByte(); - if (b0 == 1 || b0 == 2) { - return true; - } - } - } catch (IOException ioexception) { - return false; - } - } - - return false; - } - // CraftBukkit end - - public synchronized DataInputStream a(int i, int j) { - if (this.d(i, j)) { - return null; - } else { - try { - int k = this.e(i, j); - - if (k == 0) { - return null; - } else { - int l = k >> 8; - int i1 = k & 255; - - if (l + i1 > this.f.size()) { - return null; - } else { - this.c.seek((long) (l * 4096)); - int j1 = this.c.readInt(); - - if (j1 > 4096 * i1) { - return null; - } else if (j1 <= 0) { - return null; - } else { - byte b0 = this.c.readByte(); - byte[] abyte; - - if (b0 == 1) { - abyte = new byte[j1 - 1]; - this.c.read(abyte); - return new DataInputStream(new BufferedInputStream(new GZIPInputStream(new ByteArrayInputStream(abyte)))); - } else if (b0 == 2) { - abyte = new byte[j1 - 1]; - this.c.read(abyte); - return new DataInputStream(new BufferedInputStream(new InflaterInputStream(new ByteArrayInputStream(abyte)))); - } else { - return null; - } - } - } - } - } catch (IOException ioexception) { - return null; - } - } - } - - public DataOutputStream b(int i, int j) { - return this.d(i, j) ? null : new DataOutputStream(new DeflaterOutputStream(new ChunkBuffer(this, i, j))); - } - - protected synchronized void a(int i, int j, byte[] abyte, int k) { - try { - int l = this.e(i, j); - int i1 = l >> 8; - int j1 = l & 255; - int k1 = (k + 5) / 4096 + 1; - - if (k1 >= 256) { - return; - } - - if (i1 != 0 && j1 == k1) { - this.a(i1, abyte, k); - } else { - int l1; - - for (l1 = 0; l1 < j1; ++l1) { - this.f.set(i1 + l1, Boolean.valueOf(true)); - } - - l1 = this.f.indexOf(Boolean.valueOf(true)); - int i2 = 0; - int j2; - - if (l1 != -1) { - for (j2 = l1; j2 < this.f.size(); ++j2) { - if (i2 != 0) { - if (((Boolean) this.f.get(j2)).booleanValue()) { - ++i2; - } else { - i2 = 0; - } - } else if (((Boolean) this.f.get(j2)).booleanValue()) { - l1 = j2; - i2 = 1; - } - - if (i2 >= k1) { - break; - } - } - } - - if (i2 >= k1) { - i1 = l1; - this.a(i, j, l1 << 8 | k1); - - for (j2 = 0; j2 < k1; ++j2) { - this.f.set(i1 + j2, Boolean.valueOf(false)); - } - - this.a(i1, abyte, k); - } else { - this.c.seek(this.c.length()); - i1 = this.f.size(); - - for (j2 = 0; j2 < k1; ++j2) { - this.c.write(a); - this.f.add(Boolean.valueOf(false)); - } - - this.g += 4096 * k1; - this.a(i1, abyte, k); - this.a(i, j, i1 << 8 | k1); - } - } - - this.b(i, j, (int) (MinecraftServer.ar() / 1000L)); - } catch (IOException ioexception) { - ioexception.printStackTrace(); - } - } - - private void a(int i, byte[] abyte, int j) throws IOException { // CraftBukkit - added throws - this.c.seek((long) (i * 4096)); - this.c.writeInt(j + 1); - this.c.writeByte(2); - this.c.write(abyte, 0, j); - } - - private boolean d(int i, int j) { - return i < 0 || i >= 32 || j < 0 || j >= 32; - } - - private int e(int i, int j) { - return this.d[i + j * 32]; - } - - public boolean c(int i, int j) { - return this.e(i, j) != 0; - } - - private void a(int i, int j, int k) throws IOException { // CraftBukkit - added throws - this.d[i + j * 32] = k; - this.c.seek((long) ((i + j * 32) * 4)); - this.c.writeInt(k); - } - - private void b(int i, int j, int k) throws IOException { // CraftBukkit - added throws - this.e[i + j * 32] = k; - this.c.seek((long) (4096 + (i + j * 32) * 4)); - this.c.writeInt(k); - } - - public void c() throws IOException { // CraftBukkit - added throws - if (this.c != null) { - this.c.close(); - } - } -} diff --git a/src/main/java/net/minecraft/server/RemoteControlCommandListener.java b/src/main/java/net/minecraft/server/RemoteControlCommandListener.java deleted file mode 100644 index fd967c12..00000000 --- a/src/main/java/net/minecraft/server/RemoteControlCommandListener.java +++ /dev/null @@ -1,47 +0,0 @@ -package net.minecraft.server; - -public class RemoteControlCommandListener implements ICommandListener { - - public static final RemoteControlCommandListener instance = new RemoteControlCommandListener(); - private StringBuffer b = new StringBuffer(); - - public RemoteControlCommandListener() {} - - public void e() { - this.b.setLength(0); - } - - public String f() { - return this.b.toString(); - } - - public String getName() { - return "Rcon"; - } - - public IChatBaseComponent getScoreboardDisplayName() { - return new ChatComponentText(this.getName()); - } - - // CraftBukkit start - Send a String - public void sendMessage(String message) { - this.b.append(message); - } - // CraftBukkit end - - public void sendMessage(IChatBaseComponent ichatbasecomponent) { - this.b.append(ichatbasecomponent.c()); - } - - public boolean a(int i, String s) { - return true; - } - - public ChunkCoordinates getChunkCoordinates() { - return new ChunkCoordinates(0, 0, 0); - } - - public World getWorld() { - return MinecraftServer.getServer().getWorld(); - } -} diff --git a/src/main/java/net/minecraft/server/ScoreboardServer.java b/src/main/java/net/minecraft/server/ScoreboardServer.java deleted file mode 100644 index 15910585..00000000 --- a/src/main/java/net/minecraft/server/ScoreboardServer.java +++ /dev/null @@ -1,222 +0,0 @@ -package net.minecraft.server; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -public class ScoreboardServer extends Scoreboard { - - private final MinecraftServer a; - private final Set b = new HashSet(); - private PersistentScoreboard c; - - public ScoreboardServer(MinecraftServer minecraftserver) { - this.a = minecraftserver; - } - - public void handleScoreChanged(ScoreboardScore scoreboardscore) { - super.handleScoreChanged(scoreboardscore); - if (this.b.contains(scoreboardscore.getObjective())) { - this.sendAll(new PacketPlayOutScoreboardScore(scoreboardscore, 0)); // CraftBukkit - Internal packet method - } - - this.b(); - } - - public void handlePlayerRemoved(String s) { - super.handlePlayerRemoved(s); - this.sendAll(new PacketPlayOutScoreboardScore(s)); // CraftBukkit - Internal packet method - this.b(); - } - - public void setDisplaySlot(int i, ScoreboardObjective scoreboardobjective) { - ScoreboardObjective scoreboardobjective1 = this.getObjectiveForSlot(i); - - super.setDisplaySlot(i, scoreboardobjective); - if (scoreboardobjective1 != scoreboardobjective && scoreboardobjective1 != null) { - if (this.h(scoreboardobjective1) > 0) { - this.sendAll(new PacketPlayOutScoreboardDisplayObjective(i, scoreboardobjective)); // CraftBukkit - Internal packet method - } else { - this.g(scoreboardobjective1); - } - } - - if (scoreboardobjective != null) { - if (this.b.contains(scoreboardobjective)) { - this.sendAll(new PacketPlayOutScoreboardDisplayObjective(i, scoreboardobjective)); // CraftBukkit - Internal packet method - } else { - this.e(scoreboardobjective); - } - } - - this.b(); - } - - public boolean addPlayerToTeam(String s, String s1) { - if (super.addPlayerToTeam(s, s1)) { - ScoreboardTeam scoreboardteam = this.getTeam(s1); - - this.sendAll(new PacketPlayOutScoreboardTeam(scoreboardteam, Arrays.asList(new String[] { s}), 3)); // CraftBukkit - Internal packet method - this.b(); - return true; - } else { - return false; - } - } - - public void removePlayerFromTeam(String s, ScoreboardTeam scoreboardteam) { - super.removePlayerFromTeam(s, scoreboardteam); - this.sendAll(new PacketPlayOutScoreboardTeam(scoreboardteam, Arrays.asList(new String[] { s}), 4)); // CraftBukkit - Internal packet method - this.b(); - } - - public void handleObjectiveAdded(ScoreboardObjective scoreboardobjective) { - super.handleObjectiveAdded(scoreboardobjective); - this.b(); - } - - public void handleObjectiveChanged(ScoreboardObjective scoreboardobjective) { - super.handleObjectiveChanged(scoreboardobjective); - if (this.b.contains(scoreboardobjective)) { - this.sendAll(new PacketPlayOutScoreboardObjective(scoreboardobjective, 2)); // CraftBukkit - Internal packet method - } - - this.b(); - } - - public void handleObjectiveRemoved(ScoreboardObjective scoreboardobjective) { - super.handleObjectiveRemoved(scoreboardobjective); - if (this.b.contains(scoreboardobjective)) { - this.g(scoreboardobjective); - } - - this.b(); - } - - public void handleTeamAdded(ScoreboardTeam scoreboardteam) { - super.handleTeamAdded(scoreboardteam); - this.sendAll(new PacketPlayOutScoreboardTeam(scoreboardteam, 0)); // CraftBukkit - Internal packet method - this.b(); - } - - public void handleTeamChanged(ScoreboardTeam scoreboardteam) { - super.handleTeamChanged(scoreboardteam); - this.sendAll(new PacketPlayOutScoreboardTeam(scoreboardteam, 2)); // CraftBukkit - Internal packet method - this.b(); - } - - public void handleTeamRemoved(ScoreboardTeam scoreboardteam) { - super.handleTeamRemoved(scoreboardteam); - this.sendAll(new PacketPlayOutScoreboardTeam(scoreboardteam, 1)); // CraftBukkit - Internal packet method - this.b(); - } - - public void a(PersistentScoreboard persistentscoreboard) { - this.c = persistentscoreboard; - } - - protected void b() { - if (this.c != null) { - this.c.c(); - } - } - - public List getScoreboardScorePacketsForObjective(ScoreboardObjective scoreboardobjective) { - ArrayList arraylist = new ArrayList(); - - arraylist.add(new PacketPlayOutScoreboardObjective(scoreboardobjective, 0)); - - for (int i = 0; i < 3; ++i) { - if (this.getObjectiveForSlot(i) == scoreboardobjective) { - arraylist.add(new PacketPlayOutScoreboardDisplayObjective(i, scoreboardobjective)); - } - } - - Iterator iterator = this.getScoresForObjective(scoreboardobjective).iterator(); - - while (iterator.hasNext()) { - ScoreboardScore scoreboardscore = (ScoreboardScore) iterator.next(); - - arraylist.add(new PacketPlayOutScoreboardScore(scoreboardscore, 0)); - } - - return arraylist; - } - - public void e(ScoreboardObjective scoreboardobjective) { - List list = this.getScoreboardScorePacketsForObjective(scoreboardobjective); - Iterator iterator = this.a.getPlayerList().players.iterator(); - - while (iterator.hasNext()) { - EntityPlayer entityplayer = (EntityPlayer) iterator.next(); - if (entityplayer.getBukkitEntity().getScoreboard().getHandle() != this) continue; // CraftBukkit - Only players on this board - Iterator iterator1 = list.iterator(); - - while (iterator1.hasNext()) { - Packet packet = (Packet) iterator1.next(); - - entityplayer.playerConnection.sendPacket(packet); - } - } - - this.b.add(scoreboardobjective); - } - - public List f(ScoreboardObjective scoreboardobjective) { - ArrayList arraylist = new ArrayList(); - - arraylist.add(new PacketPlayOutScoreboardObjective(scoreboardobjective, 1)); - - for (int i = 0; i < 3; ++i) { - if (this.getObjectiveForSlot(i) == scoreboardobjective) { - arraylist.add(new PacketPlayOutScoreboardDisplayObjective(i, scoreboardobjective)); - } - } - - return arraylist; - } - - public void g(ScoreboardObjective scoreboardobjective) { - List list = this.f(scoreboardobjective); - Iterator iterator = this.a.getPlayerList().players.iterator(); - - while (iterator.hasNext()) { - EntityPlayer entityplayer = (EntityPlayer) iterator.next(); - if (entityplayer.getBukkitEntity().getScoreboard().getHandle() != this) continue; // CraftBukkit - Only players on this board - Iterator iterator1 = list.iterator(); - - while (iterator1.hasNext()) { - Packet packet = (Packet) iterator1.next(); - - entityplayer.playerConnection.sendPacket(packet); - } - } - - this.b.remove(scoreboardobjective); - } - - public int h(ScoreboardObjective scoreboardobjective) { - int i = 0; - - for (int j = 0; j < 3; ++j) { - if (this.getObjectiveForSlot(j) == scoreboardobjective) { - ++i; - } - } - - return i; - } - - // CraftBukkit start - Send to players - private void sendAll(Packet packet) { - for (EntityPlayer entityplayer : (List<EntityPlayer>) this.a.getPlayerList().players) { - if (entityplayer.getBukkitEntity().getScoreboard().getHandle() == this) { - entityplayer.playerConnection.sendPacket(packet); - } - } - } - // CraftBukkit end -} diff --git a/src/main/java/net/minecraft/server/SecondaryWorldServer.java b/src/main/java/net/minecraft/server/SecondaryWorldServer.java deleted file mode 100644 index 5236f81e..00000000 --- a/src/main/java/net/minecraft/server/SecondaryWorldServer.java +++ /dev/null @@ -1,14 +0,0 @@ -package net.minecraft.server; - -public class SecondaryWorldServer extends WorldServer { - // CraftBukkit start - Add Environment and ChunkGenerator arguments - public SecondaryWorldServer(MinecraftServer minecraftserver, IDataManager idatamanager, String s, int i, WorldSettings worldsettings, WorldServer worldserver, MethodProfiler methodprofiler, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen) { - super(minecraftserver, idatamanager, s, i, worldsettings, methodprofiler, env, gen); - // CraftBukkit end - this.worldMaps = worldserver.worldMaps; - this.scoreboard = worldserver.getScoreboard(); - // this.worldData = new SecondaryWorldData(worldserver.getWorldData()); // CraftBukkit - use unique worlddata - } - - // protected void a() {} // CraftBukkit - save world data! -} diff --git a/src/main/java/net/minecraft/server/ShapedRecipes.java b/src/main/java/net/minecraft/server/ShapedRecipes.java deleted file mode 100644 index cc444db8..00000000 --- a/src/main/java/net/minecraft/server/ShapedRecipes.java +++ /dev/null @@ -1,159 +0,0 @@ -package net.minecraft.server; - -// CraftBukkit start -import org.bukkit.craftbukkit.inventory.CraftItemStack; -import org.bukkit.craftbukkit.inventory.CraftShapedRecipe; -// CraftBukkit end - -public class ShapedRecipes implements IRecipe { - - private int width; - private int height; - private ItemStack[] items; - private ItemStack result; - private boolean e; - - public ShapedRecipes(int i, int j, ItemStack[] aitemstack, ItemStack itemstack) { - this.width = i; - this.height = j; - this.items = aitemstack; - this.result = itemstack; - } - - // CraftBukkit start - public org.bukkit.inventory.ShapedRecipe toBukkitRecipe() { - CraftItemStack result = CraftItemStack.asCraftMirror(this.result); - CraftShapedRecipe recipe = new CraftShapedRecipe(result, this); - switch (this.height) { - case 1: - switch (this.width) { - case 1: - recipe.shape("a"); - break; - case 2: - recipe.shape("ab"); - break; - case 3: - recipe.shape("abc"); - break; - } - break; - case 2: - switch (this.width) { - case 1: - recipe.shape("a","b"); - break; - case 2: - recipe.shape("ab","cd"); - break; - case 3: - recipe.shape("abc","def"); - break; - } - break; - case 3: - switch (this.width) { - case 1: - recipe.shape("a","b","c"); - break; - case 2: - recipe.shape("ab","cd","ef"); - break; - case 3: - recipe.shape("abc","def","ghi"); - break; - } - break; - } - char c = 'a'; - for (ItemStack stack : this.items) { - if (stack != null) { - recipe.setIngredient(c, org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(stack.getItem()), stack.getData()); - } - c++; - } - return recipe; - } - // CraftBukkit end - - public ItemStack b() { - return this.result; - } - - 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)) { - return true; - } - - if (this.a(inventorycrafting, i, j, false)) { - return true; - } - } - } - - return false; - } - - private boolean a(InventoryCrafting inventorycrafting, int i, int j, boolean flag) { - for (int k = 0; k < 3; ++k) { - for (int l = 0; l < 3; ++l) { - int i1 = k - i; - int j1 = l - j; - ItemStack itemstack = null; - - if (i1 >= 0 && j1 >= 0 && i1 < this.width && j1 < this.height) { - if (flag) { - itemstack = this.items[this.width - i1 - 1 + j1 * this.width]; - } else { - itemstack = this.items[i1 + j1 * this.width]; - } - } - - ItemStack itemstack1 = inventorycrafting.b(k, l); - - if (itemstack1 != null || itemstack != null) { - if (itemstack1 == null && itemstack != null || itemstack1 != null && itemstack == null) { - return false; - } - - if (itemstack.getItem() != itemstack1.getItem()) { - return false; - } - - if (itemstack.getData() != 32767 && itemstack.getData() != itemstack1.getData()) { - return false; - } - } - } - } - - return true; - } - - public ItemStack a(InventoryCrafting inventorycrafting) { - ItemStack itemstack = this.b().cloneItemStack(); - - if (this.e) { - for (int i = 0; i < inventorycrafting.getSize(); ++i) { - ItemStack itemstack1 = inventorycrafting.getItem(i); - - if (itemstack1 != null && itemstack1.hasTag()) { - itemstack.setTag((NBTTagCompound) itemstack1.tag.clone()); - } - } - } - - return itemstack; - } - - public int a() { - return this.width * this.height; - } - - public ShapedRecipes c() { - this.e = true; - return this; - } -} diff --git a/src/main/java/net/minecraft/server/ShapelessRecipes.java b/src/main/java/net/minecraft/server/ShapelessRecipes.java deleted file mode 100644 index 0fab83c6..00000000 --- a/src/main/java/net/minecraft/server/ShapelessRecipes.java +++ /dev/null @@ -1,78 +0,0 @@ -package net.minecraft.server; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -// CraftBukkit start -import org.bukkit.craftbukkit.inventory.CraftItemStack; -import org.bukkit.craftbukkit.inventory.CraftShapelessRecipe; -// CraftBukkit end - -public class ShapelessRecipes implements IRecipe { - - private final ItemStack result; - private final List ingredients; - - public ShapelessRecipes(ItemStack itemstack, List list) { - this.result = itemstack; - this.ingredients = list; - } - - // CraftBukkit start - @SuppressWarnings("unchecked") - public org.bukkit.inventory.ShapelessRecipe toBukkitRecipe() { - CraftItemStack result = CraftItemStack.asCraftMirror(this.result); - CraftShapelessRecipe recipe = new CraftShapelessRecipe(result, this); - for (ItemStack stack : (List<ItemStack>) this.ingredients) { - if (stack != null) { - recipe.addIngredient(org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(stack.getItem()), stack.getData()); - } - } - return recipe; - } - // CraftBukkit end - - public ItemStack b() { - return this.result; - } - - public boolean a(InventoryCrafting inventorycrafting, World world) { - ArrayList arraylist = new ArrayList(this.ingredients); - - for (int i = 0; i < 3; ++i) { - for (int j = 0; j < 3; ++j) { - ItemStack itemstack = inventorycrafting.b(j, i); - - if (itemstack != null) { - boolean flag = false; - Iterator iterator = arraylist.iterator(); - - while (iterator.hasNext()) { - ItemStack itemstack1 = (ItemStack) iterator.next(); - - if (itemstack.getItem() == itemstack1.getItem() && (itemstack1.getData() == 32767 || itemstack.getData() == itemstack1.getData())) { - flag = true; - arraylist.remove(itemstack1); - break; - } - } - - if (!flag) { - return false; - } - } - } - } - - return arraylist.isEmpty(); - } - - public ItemStack a(InventoryCrafting inventorycrafting) { - return this.result.cloneItemStack(); - } - - public int a() { - return this.ingredients.size(); - } -} diff --git a/src/main/java/net/minecraft/server/Slot.java b/src/main/java/net/minecraft/server/Slot.java deleted file mode 100644 index ac9e04cf..00000000 --- a/src/main/java/net/minecraft/server/Slot.java +++ /dev/null @@ -1,74 +0,0 @@ -package net.minecraft.server; - -public class Slot { - - public final int index; // CraftBukkit - private -> public - public final IInventory inventory; - public int rawSlotIndex; - public int h; - public int i; - - public Slot(IInventory iinventory, int i, int j, int k) { - this.inventory = iinventory; - this.index = i; - this.h = j; - this.i = k; - } - - public void a(ItemStack itemstack, ItemStack itemstack1) { - if (itemstack != null && itemstack1 != null) { - if (itemstack.getItem() == itemstack1.getItem()) { - int i = itemstack1.count - itemstack.count; - - if (i > 0) { - this.a(itemstack, i); - } - } - } - } - - protected void a(ItemStack itemstack, int i) {} - - protected void b(ItemStack itemstack) {} - - public void a(EntityHuman entityhuman, ItemStack itemstack) { - this.f(); - } - - public boolean isAllowed(ItemStack itemstack) { - return true; - } - - public ItemStack getItem() { - return this.inventory.getItem(this.index); - } - - public boolean hasItem() { - return this.getItem() != null; - } - - public void set(ItemStack itemstack) { - this.inventory.setItem(this.index, itemstack); - this.f(); - } - - public void f() { - this.inventory.update(); - } - - public int getMaxStackSize() { - return this.inventory.getMaxStackSize(); - } - - public ItemStack a(int i) { - return this.inventory.splitStack(this.index, i); - } - - public boolean a(IInventory iinventory, int i) { - return iinventory == this.inventory && i == this.index; - } - - public boolean isAllowed(EntityHuman entityhuman) { - return true; - } -} diff --git a/src/main/java/net/minecraft/server/SlotFurnaceResult.java b/src/main/java/net/minecraft/server/SlotFurnaceResult.java deleted file mode 100644 index 9b8e39bc..00000000 --- a/src/main/java/net/minecraft/server/SlotFurnaceResult.java +++ /dev/null @@ -1,85 +0,0 @@ -package net.minecraft.server; - -// CraftBukkit start -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.FurnaceExtractEvent; -// CraftBukkit end - -public class SlotFurnaceResult extends Slot { - - private EntityHuman a; - private int b; - - public SlotFurnaceResult(EntityHuman entityhuman, IInventory iinventory, int i, int j, int k) { - super(iinventory, i, j, k); - this.a = entityhuman; - } - - public boolean isAllowed(ItemStack itemstack) { - return false; - } - - public ItemStack a(int i) { - if (this.hasItem()) { - this.b += Math.min(i, this.getItem().count); - } - - return super.a(i); - } - - public void a(EntityHuman entityhuman, ItemStack itemstack) { - this.b(itemstack); - super.a(entityhuman, itemstack); - } - - protected void a(ItemStack itemstack, int i) { - this.b += i; - this.b(itemstack); - } - - protected void b(ItemStack itemstack) { - itemstack.a(this.a.world, this.a, this.b); - if (!this.a.world.isStatic) { - int i = this.b; - float f = RecipesFurnace.getInstance().b(itemstack); - int j; - - if (f == 0.0F) { - i = 0; - } else if (f < 1.0F) { - j = MathHelper.d((float) i * f); - if (j < MathHelper.f((float) i * f) && (float) Math.random() < (float) i * f - (float) j) { - ++j; - } - - i = j; - } - - // CraftBukkit start - fire FurnaceExtractEvent - Player player = (Player) a.getBukkitEntity(); - TileEntityFurnace furnace = ((TileEntityFurnace) this.inventory); - org.bukkit.block.Block block = a.world.getWorld().getBlockAt(furnace.x, furnace.y, furnace.z); - - FurnaceExtractEvent event = new FurnaceExtractEvent(player, block, org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(itemstack.getItem()), itemstack.count, i); - a.world.getServer().getPluginManager().callEvent(event); - - i = event.getExpToDrop(); - // CraftBukkit end - - while (i > 0) { - j = EntityExperienceOrb.getOrbValue(i); - i -= j; - this.a.world.addEntity(new EntityExperienceOrb(this.a.world, this.a.locX, this.a.locY + 0.5D, this.a.locZ + 0.5D, j)); - } - } - - this.b = 0; - if (itemstack.getItem() == Items.IRON_INGOT) { - this.a.a((Statistic) AchievementList.k, 1); - } - - if (itemstack.getItem() == Items.COOKED_FISH) { - this.a.a((Statistic) AchievementList.p, 1); - } - } -} diff --git a/src/main/java/net/minecraft/server/SpawnerCreature.java b/src/main/java/net/minecraft/server/SpawnerCreature.java deleted file mode 100644 index 1dfc3460..00000000 --- a/src/main/java/net/minecraft/server/SpawnerCreature.java +++ /dev/null @@ -1,255 +0,0 @@ -package net.minecraft.server; - -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Random; - -// CraftBukkit start -import org.bukkit.craftbukkit.util.LongHash; -import org.bukkit.craftbukkit.util.LongObjectHashMap; -import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; -// CraftBukkit end - -public final class SpawnerCreature { - - private LongObjectHashMap<Boolean> a = new LongObjectHashMap<Boolean>(); // CraftBukkit - HashMap -> LongObjectHashMap - - public SpawnerCreature() {} - - protected static ChunkPosition getRandomPosition(World world, int i, int j) { - 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.S() : chunk.h() + 16 - 1); - - return new ChunkPosition(k, i1, l); - } - - public int spawnEntities(WorldServer worldserver, boolean flag, boolean flag1, boolean flag2) { - if (!flag && !flag1) { - return 0; - } else { - this.a.clear(); - - int i; - int j; - - for (i = 0; i < worldserver.players.size(); ++i) { - EntityHuman entityhuman = (EntityHuman) worldserver.players.get(i); - int k = MathHelper.floor(entityhuman.locX / 16.0D); - - j = MathHelper.floor(entityhuman.locZ / 16.0D); - byte b0 = 8; - - for (int l = -b0; l <= b0; ++l) { - for (int i1 = -b0; i1 <= b0; ++i1) { - boolean flag3 = l == -b0 || l == b0 || i1 == -b0 || i1 == b0; - - // CraftBukkit start - use LongHash and LongObjectHashMap - long chunkCoords = LongHash.toLong(l + k, i1 + j); - - if (!flag3) { - this.a.put(chunkCoords, false); - } else if (!this.a.containsKey(chunkCoords)) { - this.a.put(chunkCoords, true); - } - // CraftBukkit end - } - } - } - - i = 0; - ChunkCoordinates chunkcoordinates = worldserver.getSpawn(); - EnumCreatureType[] aenumcreaturetype = EnumCreatureType.values(); - - j = aenumcreaturetype.length; - - for (int j1 = 0; j1 < j; ++j1) { - EnumCreatureType enumcreaturetype = aenumcreaturetype[j1]; - - // CraftBukkit start - Use per-world spawn limits - int limit = enumcreaturetype.b(); - switch (enumcreaturetype) { - case MONSTER: - limit = worldserver.getWorld().getMonsterSpawnLimit(); - break; - case CREATURE: - limit = worldserver.getWorld().getAnimalSpawnLimit(); - break; - case WATER_CREATURE: - limit = worldserver.getWorld().getWaterAnimalSpawnLimit(); - break; - case AMBIENT: - limit = worldserver.getWorld().getAmbientSpawnLimit(); - break; - } - - if (limit == 0) { - continue; - } - // CraftBukkit end - - if ((!enumcreaturetype.d() || flag1) && (enumcreaturetype.d() || flag) && (!enumcreaturetype.e() || flag2) && worldserver.a(enumcreaturetype.a()) <= limit * this.a.size() / 256) { // CraftBukkit - use per-world limits - Iterator iterator = this.a.keySet().iterator(); - - label110: - while (iterator.hasNext()) { - // CraftBukkit start = use LongHash and LongObjectHashMap - long key = ((Long) iterator.next()).longValue(); - - if (!this.a.get(key)) { - ChunkPosition chunkposition = getRandomPosition(worldserver, LongHash.msw(key), LongHash.lsw(key)); - // CraftBukkit end - int k1 = chunkposition.x; - int l1 = chunkposition.y; - int i2 = chunkposition.z; - - if (!worldserver.getType(k1, l1, i2).r() && worldserver.getType(k1, l1, i2).getMaterial() == enumcreaturetype.c()) { - int j2 = 0; - int k2 = 0; - - while (k2 < 3) { - int l2 = k1; - int i3 = l1; - int j3 = i2; - byte b1 = 6; - BiomeMeta biomemeta = null; - GroupDataEntity groupdataentity = null; - int k3 = 0; - - while (true) { - if (k3 < 4) { - 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); - if (a(enumcreaturetype, worldserver, l2, i3, j3)) { - float f = (float) l2 + 0.5F; - float f1 = (float) i3; - float f2 = (float) j3 + 0.5F; - - if (worldserver.findNearbyPlayer((double) f, (double) f1, (double) f2, 24.0D) == null) { - float f3 = f - (float) chunkcoordinates.x; - float f4 = f1 - (float) chunkcoordinates.y; - float f5 = f2 - (float) chunkcoordinates.z; - float f6 = f3 * f3 + f4 * f4 + f5 * f5; - - if (f6 >= 576.0F) { - if (biomemeta == null) { - biomemeta = worldserver.a(enumcreaturetype, l2, i3, j3); - if (biomemeta == null) { - break label103; - } - } - - EntityInsentient entityinsentient; - - try { - entityinsentient = (EntityInsentient) biomemeta.b.getConstructor(new Class[] { World.class}).newInstance(new Object[] { worldserver}); - } catch (Exception exception) { - exception.printStackTrace(); - return i; - } - - entityinsentient.setPositionRotation((double) f, (double) f1, (double) f2, worldserver.random.nextFloat() * 360.0F, 0.0F); - if (entityinsentient.canSpawn()) { - ++j2; - // CraftBukkit start - Added a reason for spawning this creature, moved entityinsentient.a(groupdataentity) up - groupdataentity = entityinsentient.prepare(groupdataentity); - worldserver.addEntity(entityinsentient, SpawnReason.NATURAL); - // CraftBukkit end - if (j2 >= entityinsentient.bB()) { - continue label110; - } - } - - i += j2; - } - } - } - - ++k3; - continue; - } - } - - ++k2; - break; - } - } - } - } - } - } - } - - return i; - } - } - - public static boolean a(EnumCreatureType enumcreaturetype, World world, int i, int j, int k) { - if (enumcreaturetype.c() == Material.WATER) { - return world.getType(i, j, k).getMaterial().isLiquid() && world.getType(i, j - 1, k).getMaterial().isLiquid() && !world.getType(i, j + 1, k).r(); - } else if (!World.a((IBlockAccess) world, i, j - 1, k)) { - return false; - } else { - Block block = world.getType(i, j - 1, k); - - return block != Blocks.BEDROCK && !world.getType(i, j, k).r() && !world.getType(i, j, k).getMaterial().isLiquid() && !world.getType(i, j + 1, k).r(); - } - } - - public static void a(World world, BiomeBase biomebase, int i, int j, int k, int l, Random random) { - List list = biomebase.getMobs(EnumCreatureType.CREATURE); - - if (!list.isEmpty()) { - while (random.nextFloat() < biomebase.g()) { - BiomeMeta biomemeta = (BiomeMeta) WeightedRandom.a(world.random, (Collection) list); - GroupDataEntity groupdataentity = null; - int i1 = biomemeta.c + random.nextInt(1 + biomemeta.d - biomemeta.c); - int j1 = i + random.nextInt(k); - int k1 = j + random.nextInt(l); - int l1 = j1; - int i2 = k1; - - for (int j2 = 0; j2 < i1; ++j2) { - boolean flag = false; - - for (int k2 = 0; !flag && k2 < 4; ++k2) { - int l2 = world.i(j1, k1); - - if (a(EnumCreatureType.CREATURE, world, j1, l2, k1)) { - float f = (float) j1 + 0.5F; - float f1 = (float) l2; - float f2 = (float) k1 + 0.5F; - - EntityInsentient entityinsentient; - - try { - entityinsentient = (EntityInsentient) biomemeta.b.getConstructor(new Class[] { World.class}).newInstance(new Object[] { world}); - } catch (Exception exception) { - exception.printStackTrace(); - continue; - } - - entityinsentient.setPositionRotation((double) f, (double) f1, (double) f2, random.nextFloat() * 360.0F, 0.0F); - // CraftBukkit start - Added a reason for spawning this creature, moved entityinsentient.a(groupdataentity) up - groupdataentity = entityinsentient.prepare(groupdataentity); - world.addEntity(entityinsentient, SpawnReason.CHUNK_GEN); - // CraftBukkit end - flag = true; - } - - j1 += random.nextInt(5) - random.nextInt(5); - - for (k1 += random.nextInt(5) - random.nextInt(5); j1 < i || j1 >= i + k || k1 < j || k1 >= j + k; k1 = i2 + random.nextInt(5) - random.nextInt(5)) { - j1 = l1 + random.nextInt(5) - random.nextInt(5); - } - } - } - } - } - } -} diff --git a/src/main/java/net/minecraft/server/StatisticManager.java b/src/main/java/net/minecraft/server/StatisticManager.java deleted file mode 100644 index d41dc4dd..00000000 --- a/src/main/java/net/minecraft/server/StatisticManager.java +++ /dev/null @@ -1,68 +0,0 @@ -package net.minecraft.server; - -import java.util.Map; - -import net.minecraft.util.com.google.common.collect.Maps; - -public class StatisticManager { - - protected final Map a = Maps.newConcurrentMap(); - - public StatisticManager() { - } - - public boolean hasAchievement(Achievement achievement) { - return this.getStatisticValue((Statistic) achievement) > 0; - } - - public boolean b(Achievement achievement) { - return achievement.c == null || this.hasAchievement(achievement.c); - } - - public void b(EntityHuman entityhuman, Statistic statistic, int i) { - if (!statistic.d() || this.b((Achievement) statistic)) { - // CraftBukkit start - fire Statistic events - org.bukkit.event.Cancellable cancellable = org.bukkit.craftbukkit.event.CraftEventFactory.handleStatisticsIncrease(entityhuman, statistic, this.getStatisticValue(statistic), i); - if (cancellable != null && cancellable.isCancelled()) { - return; - } - // CraftBukkit end - this.setStatistic(entityhuman, statistic, this.getStatisticValue(statistic) + i); - } - } - - public void setStatistic(EntityHuman entityhuman, Statistic statistic, int i) { - StatisticWrapper statisticwrapper = (StatisticWrapper) this.a.get(statistic); - - if (statisticwrapper == null) { - statisticwrapper = new StatisticWrapper(); - this.a.put(statistic, statisticwrapper); - } - - statisticwrapper.a(i); - } - - public int getStatisticValue(Statistic statistic) { - StatisticWrapper statisticwrapper = (StatisticWrapper) this.a.get(statistic); - - return statisticwrapper == null ? 0 : statisticwrapper.a(); - } - - public IJsonStatistic b(Statistic statistic) { - StatisticWrapper statisticwrapper = (StatisticWrapper) this.a.get(statistic); - - return statisticwrapper != null ? statisticwrapper.b() : null; - } - - public IJsonStatistic a(Statistic statistic, IJsonStatistic ijsonstatistic) { - StatisticWrapper statisticwrapper = (StatisticWrapper) this.a.get(statistic); - - if (statisticwrapper == null) { - statisticwrapper = new StatisticWrapper(); - this.a.put(statistic, statisticwrapper); - } - - statisticwrapper.a(ijsonstatistic); - return ijsonstatistic; - } -} diff --git a/src/main/java/net/minecraft/server/ThreadCommandReader.java b/src/main/java/net/minecraft/server/ThreadCommandReader.java deleted file mode 100644 index a5e8a45e..00000000 --- a/src/main/java/net/minecraft/server/ThreadCommandReader.java +++ /dev/null @@ -1,45 +0,0 @@ -package net.minecraft.server; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; - -import static org.bukkit.craftbukkit.Main.*; // CraftBukkit - -class ThreadCommandReader extends Thread { - - final DedicatedServer server; - - ThreadCommandReader(DedicatedServer dedicatedserver, String s) { - super(s); - this.server = dedicatedserver; - } - - public void run() { - // CraftBukkit start - if (!useConsole) { - return; - } - // CraftBukkit end - - jline.console.ConsoleReader bufferedreader = this.server.reader; // CraftBukkit - String s; - - try { - // CraftBukkit start - JLine disabling compatibility - while (!this.server.isStopped() && this.server.isRunning()) { - if (useJline) { - s = bufferedreader.readLine(">", null); - } else { - s = bufferedreader.readLine(); - } - if (s != null) { - this.server.issueCommand(s, this.server); - } - // CraftBukkit end - } - } catch (IOException ioexception) { - DedicatedServer.aF().error("Exception handling console input", ioexception); - } - } -} diff --git a/src/main/java/net/minecraft/server/ThreadPlayerLookupUUID.java b/src/main/java/net/minecraft/server/ThreadPlayerLookupUUID.java deleted file mode 100644 index 6b91be70..00000000 --- a/src/main/java/net/minecraft/server/ThreadPlayerLookupUUID.java +++ /dev/null @@ -1,96 +0,0 @@ -package net.minecraft.server; - -import java.math.BigInteger; -import java.util.UUID; - -import net.minecraft.util.com.mojang.authlib.GameProfile; -import net.minecraft.util.com.mojang.authlib.exceptions.AuthenticationUnavailableException; - -// CraftBukkit start -import org.bukkit.craftbukkit.util.Waitable; -import org.bukkit.event.player.AsyncPlayerPreLoginEvent; -import org.bukkit.event.player.PlayerPreLoginEvent; -// CraftBukkit end - -class ThreadPlayerLookupUUID extends Thread { - - final LoginListener a; - - ThreadPlayerLookupUUID(LoginListener loginlistener, String s) { - super(s); - this.a = loginlistener; - } - - public void run() { - GameProfile gameprofile = LoginListener.a(this.a); - - try { - String s = (new BigInteger(MinecraftEncryption.a(LoginListener.b(this.a), LoginListener.c(this.a).K().getPublic(), LoginListener.d(this.a)))).toString(16); - - LoginListener.a(this.a, LoginListener.c(this.a).av().hasJoinedServer(new GameProfile((UUID) null, gameprofile.getName()), s)); - if (LoginListener.a(this.a) != null) { - // CraftBukkit start - fire PlayerPreLoginEvent - if (!this.a.networkManager.isConnected()) { - return; - } - - String playerName = LoginListener.a(this.a).getName(); - java.net.InetAddress address = ((java.net.InetSocketAddress) a.networkManager.getSocketAddress()).getAddress(); - java.util.UUID uniqueId = LoginListener.a(this.a).getId(); - final org.bukkit.craftbukkit.CraftServer server = LoginListener.c(this.a).server; - - AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(playerName, address, uniqueId); - server.getPluginManager().callEvent(asyncEvent); - - if (PlayerPreLoginEvent.getHandlerList().getRegisteredListeners().length != 0) { - final PlayerPreLoginEvent event = new PlayerPreLoginEvent(playerName, address, uniqueId); - if (asyncEvent.getResult() != PlayerPreLoginEvent.Result.ALLOWED) { - event.disallow(asyncEvent.getResult(), asyncEvent.getKickMessage()); - } - Waitable<PlayerPreLoginEvent.Result> waitable = new Waitable<PlayerPreLoginEvent.Result>() { - @Override - protected PlayerPreLoginEvent.Result evaluate() { - server.getPluginManager().callEvent(event); - return event.getResult(); - }}; - - LoginListener.c(this.a).processQueue.add(waitable); - if (waitable.get() != PlayerPreLoginEvent.Result.ALLOWED) { - this.a.disconnect(event.getKickMessage()); - return; - } - } else { - if (asyncEvent.getLoginResult() != AsyncPlayerPreLoginEvent.Result.ALLOWED) { - this.a.disconnect(asyncEvent.getKickMessage()); - return; - } - } - // CraftBukkit end - - LoginListener.e().info("UUID of player " + LoginListener.a(this.a).getName() + " is " + LoginListener.a(this.a).getId()); - LoginListener.a(this.a, EnumProtocolState.READY_TO_ACCEPT); - } else if (LoginListener.c(this.a).N()) { - LoginListener.e().warn("Failed to verify username but will let them in anyway!"); - LoginListener.a(this.a, this.a.a(gameprofile)); - LoginListener.a(this.a, EnumProtocolState.READY_TO_ACCEPT); - } else { - this.a.disconnect("Failed to verify username!"); - LoginListener.e().error("Username \'" + LoginListener.a(this.a).getName() + "\' tried to join with an invalid session"); - } - } catch (AuthenticationUnavailableException authenticationunavailableexception) { - if (LoginListener.c(this.a).N()) { - LoginListener.e().warn("Authentication servers are down but will let them in anyway!"); - LoginListener.a(this.a, this.a.a(gameprofile)); - LoginListener.a(this.a, EnumProtocolState.READY_TO_ACCEPT); - } else { - this.a.disconnect("Authentication servers are down. Please try again later, sorry!"); - LoginListener.e().error("Couldn\'t verify username because servers are unavailable"); - } - // CraftBukkit start - catch all exceptions - } catch (Exception exception) { - this.a.disconnect("Failed to verify username!"); - LoginListener.c(this.a).server.getLogger().log(java.util.logging.Level.WARNING, "Exception verifying " + LoginListener.a(this.a).getName(), exception); - // CraftBukkit end - } - } -} diff --git a/src/main/java/net/minecraft/server/TileEntity.java b/src/main/java/net/minecraft/server/TileEntity.java deleted file mode 100644 index b2de58b5..00000000 --- a/src/main/java/net/minecraft/server/TileEntity.java +++ /dev/null @@ -1,183 +0,0 @@ -package net.minecraft.server; - -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.Callable; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import org.bukkit.inventory.InventoryHolder; // CraftBukkit - -public class TileEntity { - - private static final Logger a = LogManager.getLogger(); - private static Map i = new HashMap(); - private static Map j = new HashMap(); - protected World world; - public int x; - public int y; - public int z; - protected boolean f; - public int g = -1; - public Block h; - - public TileEntity() {} - - private static void a(Class oclass, String s) { - if (i.containsKey(s)) { - throw new IllegalArgumentException("Duplicate id: " + s); - } else { - i.put(s, oclass); - j.put(oclass, s); - } - } - - public World getWorld() { - return this.world; - } - - public void a(World world) { - this.world = world; - } - - public boolean o() { - return this.world != null; - } - - public void a(NBTTagCompound nbttagcompound) { - this.x = nbttagcompound.getInt("x"); - this.y = nbttagcompound.getInt("y"); - this.z = nbttagcompound.getInt("z"); - } - - public void b(NBTTagCompound nbttagcompound) { - String s = (String) j.get(this.getClass()); - - if (s == null) { - throw new RuntimeException(this.getClass() + " is missing a mapping! This is a bug!"); - } else { - nbttagcompound.setString("id", s); - nbttagcompound.setInt("x", this.x); - nbttagcompound.setInt("y", this.y); - nbttagcompound.setInt("z", this.z); - } - } - - public void h() {} - - public static TileEntity c(NBTTagCompound nbttagcompound) { - TileEntity tileentity = null; - - try { - Class oclass = (Class) i.get(nbttagcompound.getString("id")); - - if (oclass != null) { - tileentity = (TileEntity) oclass.newInstance(); - } - } catch (Exception exception) { - exception.printStackTrace(); - } - - if (tileentity != null) { - tileentity.a(nbttagcompound); - } else { - a.warn("Skipping BlockEntity with id " + nbttagcompound.getString("id")); - } - - return tileentity; - } - - public int p() { - if (this.g == -1) { - this.g = this.world.getData(this.x, this.y, this.z); - } - - return this.g; - } - - public void update() { - if (this.world != null) { - this.g = this.world.getData(this.x, this.y, this.z); - this.world.b(this.x, this.y, this.z, this); - if (this.q() != Blocks.AIR) { - this.world.updateAdjacentComparators(this.x, this.y, this.z, this.q()); - } - } - } - - public Block q() { - if (this.h == null) { - this.h = this.world.getType(this.x, this.y, this.z); - } - - return this.h; - } - - public Packet getUpdatePacket() { - return null; - } - - public boolean r() { - return this.f; - } - - public void s() { - this.f = true; - } - - public void t() { - this.f = false; - } - - public boolean c(int i, int j) { - return false; - } - - public void u() { - this.h = null; - this.g = -1; - } - - public void a(CrashReportSystemDetails crashreportsystemdetails) { - crashreportsystemdetails.a("Name", (Callable) (new CrashReportTileEntityName(this))); - CrashReportSystemDetails.a(crashreportsystemdetails, this.x, this.y, this.z, this.q(), this.p()); - crashreportsystemdetails.a("Actual block type", (Callable) (new CrashReportTileEntityType(this))); - crashreportsystemdetails.a("Actual block data value", (Callable) (new CrashReportTileEntityData(this))); - } - - static Map v() { - return j; - } - - static { - a(TileEntityFurnace.class, "Furnace"); - a(TileEntityChest.class, "Chest"); - a(TileEntityEnderChest.class, "EnderChest"); - a(TileEntityRecordPlayer.class, "RecordPlayer"); - a(TileEntityDispenser.class, "Trap"); - a(TileEntityDropper.class, "Dropper"); - a(TileEntitySign.class, "Sign"); - a(TileEntityMobSpawner.class, "MobSpawner"); - a(TileEntityNote.class, "Music"); - a(TileEntityPiston.class, "Piston"); - a(TileEntityBrewingStand.class, "Cauldron"); - a(TileEntityEnchantTable.class, "EnchantTable"); - a(TileEntityEnderPortal.class, "Airportal"); - a(TileEntityCommand.class, "Control"); - a(TileEntityBeacon.class, "Beacon"); - a(TileEntitySkull.class, "Skull"); - a(TileEntityLightDetector.class, "DLDetector"); - a(TileEntityHopper.class, "Hopper"); - a(TileEntityComparator.class, "Comparator"); - a(TileEntityFlowerPot.class, "FlowerPot"); - } - - // CraftBukkit start - add method - public InventoryHolder getOwner() { - org.bukkit.block.BlockState state = world.getWorld().getBlockAt(x, y, z).getState(); - if (state instanceof InventoryHolder) return (InventoryHolder) state; - return null; - } - // CraftBukkit end -} diff --git a/src/main/java/net/minecraft/server/TileEntityBeacon.java b/src/main/java/net/minecraft/server/TileEntityBeacon.java deleted file mode 100644 index 09313eae..00000000 --- a/src/main/java/net/minecraft/server/TileEntityBeacon.java +++ /dev/null @@ -1,276 +0,0 @@ -package net.minecraft.server; - -import java.util.Iterator; -import java.util.List; - -// CraftBukkit start -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 k; - private int l = -1; - private int m; - private int n; - private ItemStack inventorySlot; - private String p; - // CraftBukkit start - add fields and methods - public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>(); - private int maxStack = MAX_STACK; - - public ItemStack[] getContents() { - return new ItemStack[] { this.inventorySlot }; - } - - 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 h() { - if (this.world.getTime() % 80L == 0L) { - this.y(); - this.x(); - } - } - - private void x() { - if (this.k && this.l > 0 && !this.world.isStatic && this.m > 0) { - double d0 = (double) (this.l * 10 + 10); - byte b0 = 0; - - if (this.l >= 4 && this.m == this.n) { - b0 = 1; - } - - AxisAlignedBB axisalignedbb = AxisAlignedBB.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); - - axisalignedbb.e = (double) this.world.getHeight(); - 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.m, 180, b0, true)); - } - - if (this.l >= 4 && this.m != this.n && this.n > 0) { - iterator = list.iterator(); - - while (iterator.hasNext()) { - entityhuman = (EntityHuman) iterator.next(); - entityhuman.addEffect(new MobEffect(this.n, 180, 0, true)); - } - } - } - } - - private void y() { - int i = this.l; - - if (!this.world.i(this.x, this.y + 1, this.z)) { - this.k = false; - this.l = 0; - } else { - this.k = true; - this.l = 0; - - for (int j = 1; j <= 4; this.l = j++) { - int k = this.y - j; - - if (k < 0) { - break; - } - - boolean flag = true; - - for (int l = this.x - j; l <= this.x + j && flag; ++l) { - for (int i1 = this.z - j; i1 <= this.z + j; ++i1) { - Block block = this.world.getType(l, k, i1); - - if (block != Blocks.EMERALD_BLOCK && block != Blocks.GOLD_BLOCK && block != Blocks.DIAMOND_BLOCK && block != Blocks.IRON_BLOCK) { - flag = false; - break; - } - } - } - - if (!flag) { - break; - } - } - - if (this.l == 0) { - this.k = false; - } - } - - if (!this.world.isStatic && this.l == 4 && i < this.l) { - Iterator iterator = this.world.a(EntityHuman.class, AxisAlignedBB.a((double) this.x, (double) this.y, (double) this.z, (double) this.x, (double) (this.y - 4), (double) this.z).grow(10.0D, 5.0D, 10.0D)).iterator(); - - while (iterator.hasNext()) { - EntityHuman entityhuman = (EntityHuman) iterator.next(); - - entityhuman.a((Statistic) AchievementList.K); - } - } - } - - public int j() { - return this.m; - } - - public int k() { - return this.n; - } - - public int l() { - return this.l; - } - - public void d(int i) { - this.m = 0; - - for (int j = 0; j < this.l && 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.m = i; - return; - } - } - } - } - - public void e(int i) { - this.n = 0; - if (this.l >= 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.n = i; - return; - } - } - } - } - } - - public Packet getUpdatePacket() { - NBTTagCompound nbttagcompound = new NBTTagCompound(); - - this.b(nbttagcompound); - return new PacketPlayOutTileEntityData(this.x, this.y, this.z, 3, nbttagcompound); - } - - public void a(NBTTagCompound nbttagcompound) { - super.a(nbttagcompound); - this.m = nbttagcompound.getInt("Primary"); - this.n = nbttagcompound.getInt("Secondary"); - this.l = nbttagcompound.getInt("Levels"); - } - - public void b(NBTTagCompound nbttagcompound) { - super.b(nbttagcompound); - nbttagcompound.setInt("Primary", this.m); - nbttagcompound.setInt("Secondary", this.n); - nbttagcompound.setInt("Levels", this.l); - } - - public int getSize() { - return 1; - } - - public ItemStack getItem(int i) { - return i == 0 ? this.inventorySlot : null; - } - - public ItemStack splitStack(int i, int j) { - if (i == 0 && this.inventorySlot != null) { - if (j >= this.inventorySlot.count) { - ItemStack itemstack = this.inventorySlot; - - this.inventorySlot = null; - return itemstack; - } else { - this.inventorySlot.count -= j; - return new ItemStack(this.inventorySlot.getItem(), j, this.inventorySlot.getData()); - } - } else { - return null; - } - } - - public ItemStack splitWithoutUpdate(int i) { - if (i == 0 && this.inventorySlot != null) { - ItemStack itemstack = this.inventorySlot; - - this.inventorySlot = null; - return itemstack; - } else { - return null; - } - } - - public void setItem(int i, ItemStack itemstack) { - if (i == 0) { - this.inventorySlot = itemstack; - } - } - - public String getInventoryName() { - return this.k_() ? this.p : "container.beacon"; - } - - public boolean k_() { - return this.p != null && this.p.length() > 0; - } - - public void a(String s) { - this.p = s; - } - - 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 closeContainer() {} - - public boolean b(int i, ItemStack itemstack) { - return itemstack.getItem() == Items.EMERALD || itemstack.getItem() == Items.DIAMOND || itemstack.getItem() == Items.GOLD_INGOT || itemstack.getItem() == Items.IRON_INGOT; - } -} diff --git a/src/main/java/net/minecraft/server/TileEntityBrewingStand.java b/src/main/java/net/minecraft/server/TileEntityBrewingStand.java deleted file mode 100644 index c0ca4a49..00000000 --- a/src/main/java/net/minecraft/server/TileEntityBrewingStand.java +++ /dev/null @@ -1,297 +0,0 @@ -package net.minecraft.server; - -import java.util.List; - -// CraftBukkit start -import org.bukkit.craftbukkit.entity.CraftHumanEntity; -import org.bukkit.entity.HumanEntity; -import org.bukkit.event.inventory.BrewEvent; -// CraftBukkit end - -public class TileEntityBrewingStand extends TileEntity implements IWorldInventory { - - private static final int[] a = new int[] { 3}; - private static final int[] i = new int[] { 0, 1, 2}; - public ItemStack[] items = new ItemStack[4]; // CraftBukkit - private -> public - public int brewTime; // CraftBukkit - private -> public - private int l; - private Item m; - private String n; - private int lastTick = MinecraftServer.currentTick; // CraftBukkit - add field - - public TileEntityBrewingStand() {} - - // CraftBukkit start - add fields and methods - public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>(); - private int maxStack = 64; - - public void onOpen(CraftHumanEntity who) { - transaction.add(who); - } - - public void onClose(CraftHumanEntity who) { - transaction.remove(who); - } - - public List<HumanEntity> getViewers() { - return transaction; - } - - public ItemStack[] getContents() { - return this.items; - } - - public void setMaxStackSize(int size) { - maxStack = size; - } - // CraftBukkit end - - public String getInventoryName() { - return this.k_() ? this.n : "container.brewing"; - } - - public boolean k_() { - return this.n != null && this.n.length() > 0; - } - - public void a(String s) { - this.n = s; - } - - public int getSize() { - return this.items.length; - } - - public void h() { - // CraftBukkit start - Use wall time instead of ticks for brewing - int elapsedTicks = MinecraftServer.currentTick - this.lastTick; - this.lastTick = MinecraftServer.currentTick; - - if (this.brewTime > 0) { - this.brewTime -= elapsedTicks; - if (this.brewTime <= 0) { // == -> <= - // CraftBukkit end - this.l(); - this.update(); - } else if (!this.k()) { - this.brewTime = 0; - this.update(); - } else if (this.m != this.items[3].getItem()) { - this.brewTime = 0; - this.update(); - } - } else if (this.k()) { - this.brewTime = 400; - this.m = this.items[3].getItem(); - } - - int i = this.j(); - - if (i != this.l) { - this.l = i; - this.world.setData(this.x, this.y, this.z, i, 2); - } - - super.h(); - } - - public int i() { - return this.brewTime; - } - - private boolean k() { - if (this.items[3] != null && this.items[3].count > 0) { - ItemStack itemstack = this.items[3]; - - if (!itemstack.getItem().m(itemstack)) { - return false; - } else { - boolean flag = false; - - for (int i = 0; i < 3; ++i) { - if (this.items[i] != null && this.items[i].getItem() == Items.POTION) { - int j = this.items[i].getData(); - int k = this.c(j, itemstack); - - if (!ItemPotion.g(j) && ItemPotion.g(k)) { - flag = true; - break; - } - - List list = Items.POTION.c(j); - List list1 = Items.POTION.c(k); - - if ((j <= 0 || list != list1) && (list == null || !list.equals(list1) && list1 != null) && j != k) { - flag = true; - break; - } - } - } - - return flag; - } - } else { - return false; - } - } - - private void l() { - if (this.k()) { - ItemStack itemstack = this.items[3]; - - // CraftBukkit start - if (getOwner() != null) { - BrewEvent event = new BrewEvent(world.getWorld().getBlockAt(x, y, z), (org.bukkit.inventory.BrewerInventory) this.getOwner().getInventory()); - org.bukkit.Bukkit.getPluginManager().callEvent(event); - if (event.isCancelled()) { - return; - } - } - // CraftBukkit end - - for (int i = 0; i < 3; ++i) { - if (this.items[i] != null && this.items[i].getItem() == Items.POTION) { - int j = this.items[i].getData(); - int k = this.c(j, itemstack); - List list = Items.POTION.c(j); - List list1 = Items.POTION.c(k); - - if ((j <= 0 || list != list1) && (list == null || !list.equals(list1) && list1 != null)) { - if (j != k) { - this.items[i].setData(k); - } - } else if (!ItemPotion.g(j) && ItemPotion.g(k)) { - this.items[i].setData(k); - } - } - } - - if (itemstack.getItem().u()) { - this.items[3] = new ItemStack(itemstack.getItem().t()); - } else { - --this.items[3].count; - if (this.items[3].count <= 0) { - this.items[3] = null; - } - } - } - } - - private int c(int i, ItemStack itemstack) { - return itemstack == null ? i : (itemstack.getItem().m(itemstack) ? PotionBrewer.a(i, itemstack.getItem().i(itemstack)) : i); - } - - public void a(NBTTagCompound nbttagcompound) { - super.a(nbttagcompound); - NBTTagList nbttaglist = nbttagcompound.getList("Items", 10); - - this.items = new ItemStack[this.getSize()]; - - for (int i = 0; i < nbttaglist.size(); ++i) { - NBTTagCompound nbttagcompound1 = nbttaglist.get(i); - byte b0 = nbttagcompound1.getByte("Slot"); - - if (b0 >= 0 && b0 < this.items.length) { - this.items[b0] = ItemStack.createStack(nbttagcompound1); - } - } - - this.brewTime = nbttagcompound.getShort("BrewTime"); - if (nbttagcompound.hasKeyOfType("CustomName", 8)) { - this.n = nbttagcompound.getString("CustomName"); - } - } - - public void b(NBTTagCompound nbttagcompound) { - super.b(nbttagcompound); - nbttagcompound.setShort("BrewTime", (short) this.brewTime); - NBTTagList nbttaglist = new NBTTagList(); - - for (int i = 0; i < this.items.length; ++i) { - if (this.items[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - - nbttagcompound1.setByte("Slot", (byte) i); - this.items[i].save(nbttagcompound1); - nbttaglist.add(nbttagcompound1); - } - } - - nbttagcompound.set("Items", nbttaglist); - if (this.k_()) { - nbttagcompound.setString("CustomName", this.n); - } - } - - public ItemStack getItem(int i) { - return i >= 0 && i < this.items.length ? this.items[i] : null; - } - - public ItemStack splitStack(int i, int j) { - if (i >= 0 && i < this.items.length) { - ItemStack itemstack = this.items[i]; - - this.items[i] = null; - return itemstack; - } else { - return null; - } - } - - public ItemStack splitWithoutUpdate(int i) { - if (i >= 0 && i < this.items.length) { - ItemStack itemstack = this.items[i]; - - this.items[i] = null; - return itemstack; - } else { - return null; - } - } - - public void setItem(int i, ItemStack itemstack) { - if (i >= 0 && i < this.items.length) { - this.items[i] = itemstack; - } - } - - public int getMaxStackSize() { - return this.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 closeContainer() {} - - public boolean b(int i, ItemStack itemstack) { - return i == 3 ? itemstack.getItem().m(itemstack) : itemstack.getItem() == Items.POTION || itemstack.getItem() == Items.GLASS_BOTTLE; - } - - public int j() { - int i = 0; - - for (int j = 0; j < 3; ++j) { - if (this.items[j] != null) { - i |= 1 << j; - } - } - - return i; - } - - public int[] getSlotsForFace(int i) { - return i == 1 ? a : TileEntityBrewingStand.i; // CraftBukkit - decompilation error - } - - public boolean canPlaceItemThroughFace(int i, ItemStack itemstack, int j) { - return this.b(i, itemstack); - } - - public boolean canTakeItemThroughFace(int i, ItemStack itemstack, int j) { - return true; - } -} diff --git a/src/main/java/net/minecraft/server/TileEntityChest.java b/src/main/java/net/minecraft/server/TileEntityChest.java deleted file mode 100644 index c900cafb..00000000 --- a/src/main/java/net/minecraft/server/TileEntityChest.java +++ /dev/null @@ -1,410 +0,0 @@ -package net.minecraft.server; - -import java.util.Iterator; -import java.util.List; - -// CraftBukkit start -import org.bukkit.craftbukkit.entity.CraftHumanEntity; -import org.bukkit.entity.HumanEntity; -// CraftBukkit end - -public class TileEntityChest extends TileEntity implements IInventory { - - private ItemStack[] items = new ItemStack[27]; // CraftBukkit - 36 -> 27 - public boolean a; - public TileEntityChest i; - public TileEntityChest j; - public TileEntityChest k; - public TileEntityChest l; - public float m; - public float n; - public int o; - private int ticks; - private int r = -1; - private String s; - - public TileEntityChest() {} - - // CraftBukkit start - add fields and methods - public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>(); - 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 void setMaxStackSize(int size) { - maxStack = size; - } - // CraftBukkit end - - public int getSize() { - return 27; - } - - public ItemStack getItem(int i) { - return this.items[i]; - } - - public ItemStack splitStack(int i, int j) { - if (this.items[i] != null) { - ItemStack itemstack; - - if (this.items[i].count <= j) { - itemstack = this.items[i]; - this.items[i] = null; - this.update(); - return itemstack; - } else { - itemstack = this.items[i].a(j); - if (this.items[i].count == 0) { - this.items[i] = null; - } - - this.update(); - return itemstack; - } - } else { - return null; - } - } - - public ItemStack splitWithoutUpdate(int i) { - if (this.items[i] != null) { - ItemStack itemstack = this.items[i]; - - this.items[i] = null; - return itemstack; - } else { - return null; - } - } - - public void setItem(int i, ItemStack itemstack) { - this.items[i] = itemstack; - if (itemstack != null && itemstack.count > this.getMaxStackSize()) { - itemstack.count = this.getMaxStackSize(); - } - - this.update(); - } - - public String getInventoryName() { - return this.k_() ? this.s : "container.chest"; - } - - public boolean k_() { - return this.s != null && this.s.length() > 0; - } - - public void a(String s) { - this.s = s; - } - - public void a(NBTTagCompound nbttagcompound) { - super.a(nbttagcompound); - NBTTagList nbttaglist = nbttagcompound.getList("Items", 10); - - this.items = new ItemStack[this.getSize()]; - if (nbttagcompound.hasKeyOfType("CustomName", 8)) { - this.s = nbttagcompound.getString("CustomName"); - } - - for (int i = 0; i < nbttaglist.size(); ++i) { - NBTTagCompound nbttagcompound1 = nbttaglist.get(i); - int j = nbttagcompound1.getByte("Slot") & 255; - - if (j >= 0 && j < this.items.length) { - this.items[j] = ItemStack.createStack(nbttagcompound1); - } - } - } - - public void b(NBTTagCompound nbttagcompound) { - super.b(nbttagcompound); - NBTTagList nbttaglist = new NBTTagList(); - - for (int i = 0; i < this.items.length; ++i) { - if (this.items[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - - nbttagcompound1.setByte("Slot", (byte) i); - this.items[i].save(nbttagcompound1); - nbttaglist.add(nbttagcompound1); - } - } - - nbttagcompound.set("Items", nbttaglist); - if (this.k_()) { - nbttagcompound.setString("CustomName", this.s); - } - } - - public int getMaxStackSize() { - return maxStack; // CraftBukkit - } - - public boolean a(EntityHuman entityhuman) { - if (this.world == null) return true; // CraftBukkit - 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 u() { - super.u(); - this.a = false; - } - - private void a(TileEntityChest tileentitychest, int i) { - if (tileentitychest.r()) { - this.a = false; - } else if (this.a) { - switch (i) { - case 0: - if (this.l != tileentitychest) { - this.a = false; - } - break; - - case 1: - if (this.k != tileentitychest) { - this.a = false; - } - break; - - case 2: - if (this.i != tileentitychest) { - this.a = false; - } - break; - - case 3: - if (this.j != tileentitychest) { - this.a = false; - } - } - } - } - - public void i() { - if (!this.a) { - this.a = true; - this.i = null; - this.j = null; - this.k = null; - this.l = null; - if (this.a(this.x - 1, this.y, this.z)) { - this.k = (TileEntityChest) this.world.getTileEntity(this.x - 1, this.y, this.z); - } - - if (this.a(this.x + 1, this.y, this.z)) { - this.j = (TileEntityChest) this.world.getTileEntity(this.x + 1, this.y, this.z); - } - - if (this.a(this.x, this.y, this.z - 1)) { - this.i = (TileEntityChest) this.world.getTileEntity(this.x, this.y, this.z - 1); - } - - if (this.a(this.x, this.y, this.z + 1)) { - this.l = (TileEntityChest) this.world.getTileEntity(this.x, this.y, this.z + 1); - } - - if (this.i != null) { - this.i.a(this, 0); - } - - if (this.l != null) { - this.l.a(this, 2); - } - - if (this.j != null) { - this.j.a(this, 1); - } - - if (this.k != null) { - this.k.a(this, 3); - } - } - } - - private boolean a(int i, int j, int k) { - if (this.world == null) { - return false; - } else { - Block block = this.world.getType(i, j, k); - - return block instanceof BlockChest && ((BlockChest) block).a == this.j(); - } - } - - public void h() { - super.h(); - if (this.world == null) return; // CraftBukkit - this.i(); - ++this.ticks; - float f; - - if (!this.world.isStatic && this.o != 0 && (this.ticks + this.x + this.y + this.z) % 200 == 0) { - this.o = 0; - f = 5.0F; - List list = this.world.a(EntityHuman.class, AxisAlignedBB.a((double) ((float) this.x - f), (double) ((float) this.y - f), (double) ((float) this.z - f), (double) ((float) (this.x + 1) + f), (double) ((float) (this.y + 1) + f), (double) ((float) (this.z + 1) + f))); - Iterator iterator = list.iterator(); - - while (iterator.hasNext()) { - EntityHuman entityhuman = (EntityHuman) iterator.next(); - - if (entityhuman.activeContainer instanceof ContainerChest) { - IInventory iinventory = ((ContainerChest) entityhuman.activeContainer).e(); - - if (iinventory == this || iinventory instanceof InventoryLargeChest && ((InventoryLargeChest) iinventory).a((IInventory) this)) { - ++this.o; - } - } - } - } - - this.n = this.m; - f = 0.1F; - double d0; - - if (this.o > 0 && this.m == 0.0F && this.i == null && this.k == null) { - double d1 = (double) this.x + 0.5D; - - d0 = (double) this.z + 0.5D; - if (this.l != null) { - d0 += 0.5D; - } - - if (this.j != null) { - d1 += 0.5D; - } - - this.world.makeSound(d1, (double) this.y + 0.5D, d0, "random.chestopen", 0.5F, this.world.random.nextFloat() * 0.1F + 0.9F); - } - - if (this.o == 0 && this.m > 0.0F || this.o > 0 && this.m < 1.0F) { - float f1 = this.m; - - if (this.o > 0) { - this.m += f; - } else { - this.m -= f; - } - - if (this.m > 1.0F) { - this.m = 1.0F; - } - - float f2 = 0.5F; - - if (this.m < f2 && f1 >= f2 && this.i == null && this.k == null) { - d0 = (double) this.x + 0.5D; - double d2 = (double) this.z + 0.5D; - - if (this.l != null) { - d2 += 0.5D; - } - - if (this.j != null) { - d0 += 0.5D; - } - - this.world.makeSound(d0, (double) this.y + 0.5D, d2, "random.chestclosed", 0.5F, this.world.random.nextFloat() * 0.1F + 0.9F); - } - - if (this.m < 0.0F) { - this.m = 0.0F; - } - } - } - - public boolean c(int i, int j) { - if (i == 1) { - this.o = j; - return true; - } else { - return super.c(i, j); - } - } - - public void startOpen() { - if (this.o < 0) { - this.o = 0; - } - - int oldPower = Math.max(0, Math.min(15, this.o)); // CraftBukkit - Get power before new viewer is added - - ++this.o; - if (this.world == null) return; // CraftBukkit - this.world.playBlockAction(this.x, this.y, this.z, this.q(), 1, this.o); - - // CraftBukkit start - Call redstone event - if (this.q() == Blocks.TRAPPED_CHEST) { - int newPower = Math.max(0, Math.min(15, this.o)); - - if (oldPower != newPower) { - org.bukkit.craftbukkit.event.CraftEventFactory.callRedstoneChange(world, this.x, this.y, this.z, oldPower, newPower); - } - } - // CraftBukkit end - - this.world.applyPhysics(this.x, this.y, this.z, this.q()); - this.world.applyPhysics(this.x, this.y - 1, this.z, this.q()); - } - - public void closeContainer() { - if (this.q() instanceof BlockChest) { - int oldPower = Math.max(0, Math.min(15, this.o)); // CraftBukkit - Get power before new viewer is added - - --this.o; - if (this.world == null) return; // CraftBukkit - this.world.playBlockAction(this.x, this.y, this.z, this.q(), 1, this.o); - - // CraftBukkit start - Call redstone event - if (this.q() == Blocks.TRAPPED_CHEST) { - int newPower = Math.max(0, Math.min(15, this.o)); - - if (oldPower != newPower) { - org.bukkit.craftbukkit.event.CraftEventFactory.callRedstoneChange(world, this.x, this.y, this.z, oldPower, newPower); - } - } - // CraftBukkit end - - this.world.applyPhysics(this.x, this.y, this.z, this.q()); - this.world.applyPhysics(this.x, this.y - 1, this.z, this.q()); - } - } - - public boolean b(int i, ItemStack itemstack) { - return true; - } - - public void s() { - super.s(); - this.u(); - this.i(); - } - - public int j() { - if (this.r == -1) { - if (this.world == null || !(this.q() instanceof BlockChest)) { - return 0; - } - - this.r = ((BlockChest) this.q()).a; - } - - return this.r; - } -} diff --git a/src/main/java/net/minecraft/server/TileEntityCommandListener.java b/src/main/java/net/minecraft/server/TileEntityCommandListener.java deleted file mode 100644 index 45cefdac..00000000 --- a/src/main/java/net/minecraft/server/TileEntityCommandListener.java +++ /dev/null @@ -1,29 +0,0 @@ -package net.minecraft.server; - -// CraftBukkit - package-private -> public -public class TileEntityCommandListener extends CommandBlockListenerAbstract { - - final TileEntityCommand a; - - TileEntityCommandListener(TileEntityCommand tileentitycommand) { - this.a = tileentitycommand; - sender = new org.bukkit.craftbukkit.command.CraftBlockCommandSender(this); // CraftBukkit - add sender - } - - public ChunkCoordinates getChunkCoordinates() { - return new ChunkCoordinates(this.a.x, this.a.y, this.a.z); - } - - public World getWorld() { - return this.a.getWorld(); - } - - public void setCommand(String s) { - super.setCommand(s); - this.a.update(); - } - - public void e() { - this.a.getWorld().notify(this.a.x, this.a.y, this.a.z); - } -} diff --git a/src/main/java/net/minecraft/server/TileEntityDispenser.java b/src/main/java/net/minecraft/server/TileEntityDispenser.java deleted file mode 100644 index 7900b37e..00000000 --- a/src/main/java/net/minecraft/server/TileEntityDispenser.java +++ /dev/null @@ -1,188 +0,0 @@ -package net.minecraft.server; - -import java.util.Random; - -// CraftBukkit start -import java.util.List; - -import org.bukkit.craftbukkit.entity.CraftHumanEntity; -import org.bukkit.entity.HumanEntity; -// CraftBukkit end - -public class TileEntityDispenser extends TileEntity implements IInventory { - - private ItemStack[] items = new ItemStack[9]; - private Random j = new Random(); - protected String a; - - // CraftBukkit start - add fields and methods - public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>(); - 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 void setMaxStackSize(int size) { - maxStack = size; - } - // CraftBukkit end - - public TileEntityDispenser() {} - - public int getSize() { - return 9; - } - - public ItemStack getItem(int i) { - return this.items[i]; - } - - public ItemStack splitStack(int i, int j) { - if (this.items[i] != null) { - ItemStack itemstack; - - if (this.items[i].count <= j) { - itemstack = this.items[i]; - this.items[i] = null; - this.update(); - return itemstack; - } else { - itemstack = this.items[i].a(j); - if (this.items[i].count == 0) { - this.items[i] = null; - } - - this.update(); - return itemstack; - } - } else { - return null; - } - } - - public ItemStack splitWithoutUpdate(int i) { - if (this.items[i] != null) { - ItemStack itemstack = this.items[i]; - - this.items[i] = null; - return itemstack; - } else { - return null; - } - } - - public int i() { - int i = -1; - int j = 1; - - for (int k = 0; k < this.items.length; ++k) { - if (this.items[k] != null && this.j.nextInt(j++) == 0) { - if (this.items[k].count == 0) continue; // CraftBukkit - i = k; - } - } - - return i; - } - - public void setItem(int i, ItemStack itemstack) { - this.items[i] = itemstack; - if (itemstack != null && itemstack.count > this.getMaxStackSize()) { - itemstack.count = this.getMaxStackSize(); - } - - this.update(); - } - - public int addItem(ItemStack itemstack) { - for (int i = 0; i < this.items.length; ++i) { - if (this.items[i] == null || this.items[i].getItem() == null) { - this.setItem(i, itemstack); - return i; - } - } - - return -1; - } - - public String getInventoryName() { - return this.k_() ? this.a : "container.dispenser"; - } - - public void a(String s) { - this.a = s; - } - - public boolean k_() { - return this.a != null; - } - - public void a(NBTTagCompound nbttagcompound) { - super.a(nbttagcompound); - NBTTagList nbttaglist = nbttagcompound.getList("Items", 10); - - this.items = new ItemStack[this.getSize()]; - - for (int i = 0; i < nbttaglist.size(); ++i) { - NBTTagCompound nbttagcompound1 = nbttaglist.get(i); - int j = nbttagcompound1.getByte("Slot") & 255; - - if (j >= 0 && j < this.items.length) { - this.items[j] = ItemStack.createStack(nbttagcompound1); - } - } - - if (nbttagcompound.hasKeyOfType("CustomName", 8)) { - this.a = nbttagcompound.getString("CustomName"); - } - } - - public void b(NBTTagCompound nbttagcompound) { - super.b(nbttagcompound); - NBTTagList nbttaglist = new NBTTagList(); - - for (int i = 0; i < this.items.length; ++i) { - if (this.items[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - - nbttagcompound1.setByte("Slot", (byte) i); - this.items[i].save(nbttagcompound1); - nbttaglist.add(nbttagcompound1); - } - } - - nbttagcompound.set("Items", nbttaglist); - if (this.k_()) { - nbttagcompound.setString("CustomName", this.a); - } - } - - 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 closeContainer() {} - - public boolean b(int i, ItemStack itemstack) { - return true; - } -} diff --git a/src/main/java/net/minecraft/server/TileEntityFurnace.java b/src/main/java/net/minecraft/server/TileEntityFurnace.java deleted file mode 100644 index 430fc69c..00000000 --- a/src/main/java/net/minecraft/server/TileEntityFurnace.java +++ /dev/null @@ -1,343 +0,0 @@ -package net.minecraft.server; - -// CraftBukkit start -import java.util.List; - -import org.bukkit.craftbukkit.inventory.CraftItemStack; -import org.bukkit.entity.HumanEntity; -import org.bukkit.event.inventory.FurnaceBurnEvent; -import org.bukkit.event.inventory.FurnaceSmeltEvent; -import org.bukkit.craftbukkit.entity.CraftHumanEntity; -// CraftBukkit end - -public class TileEntityFurnace extends TileEntity implements IWorldInventory { - - private static final int[] k = new int[] { 0}; - private static final int[] l = new int[] { 2, 1}; - private static final int[] m = new int[] { 1}; - private ItemStack[] items = new ItemStack[3]; - public int burnTime; - public int ticksForCurrentFuel; - public int cookTime; - private String o; - - // CraftBukkit start - add fields and methods - private int lastTick = MinecraftServer.currentTick; - private int maxStack = MAX_STACK; - public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>(); - - 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 void setMaxStackSize(int size) { - maxStack = size; - } - // CraftBukkit end - - public TileEntityFurnace() {} - - public int getSize() { - return this.items.length; - } - - public ItemStack getItem(int i) { - return this.items[i]; - } - - public ItemStack splitStack(int i, int j) { - if (this.items[i] != null) { - ItemStack itemstack; - - if (this.items[i].count <= j) { - itemstack = this.items[i]; - this.items[i] = null; - return itemstack; - } else { - itemstack = this.items[i].a(j); - if (this.items[i].count == 0) { - this.items[i] = null; - } - - return itemstack; - } - } else { - return null; - } - } - - public ItemStack splitWithoutUpdate(int i) { - if (this.items[i] != null) { - ItemStack itemstack = this.items[i]; - - this.items[i] = null; - return itemstack; - } else { - return null; - } - } - - public void setItem(int i, ItemStack itemstack) { - this.items[i] = itemstack; - if (itemstack != null && itemstack.count > this.getMaxStackSize()) { - itemstack.count = this.getMaxStackSize(); - } - } - - public String getInventoryName() { - return this.k_() ? this.o : "container.furnace"; - } - - public boolean k_() { - return this.o != null && this.o.length() > 0; - } - - public void a(String s) { - this.o = s; - } - - public void a(NBTTagCompound nbttagcompound) { - super.a(nbttagcompound); - NBTTagList nbttaglist = nbttagcompound.getList("Items", 10); - - this.items = new ItemStack[this.getSize()]; - - for (int i = 0; i < nbttaglist.size(); ++i) { - NBTTagCompound nbttagcompound1 = nbttaglist.get(i); - byte b0 = nbttagcompound1.getByte("Slot"); - - if (b0 >= 0 && b0 < this.items.length) { - this.items[b0] = ItemStack.createStack(nbttagcompound1); - } - } - - this.burnTime = nbttagcompound.getShort("BurnTime"); - this.cookTime = nbttagcompound.getShort("CookTime"); - this.ticksForCurrentFuel = fuelTime(this.items[1]); - if (nbttagcompound.hasKeyOfType("CustomName", 8)) { - this.o = nbttagcompound.getString("CustomName"); - } - } - - public void b(NBTTagCompound nbttagcompound) { - super.b(nbttagcompound); - nbttagcompound.setShort("BurnTime", (short) this.burnTime); - nbttagcompound.setShort("CookTime", (short) this.cookTime); - NBTTagList nbttaglist = new NBTTagList(); - - for (int i = 0; i < this.items.length; ++i) { - if (this.items[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - - nbttagcompound1.setByte("Slot", (byte) i); - this.items[i].save(nbttagcompound1); - nbttaglist.add(nbttagcompound1); - } - } - - nbttagcompound.set("Items", nbttaglist); - if (this.k_()) { - nbttagcompound.setString("CustomName", this.o); - } - } - - public int getMaxStackSize() { - return maxStack; // CraftBukkit - } - - public boolean isBurning() { - return this.burnTime > 0; - } - - public void h() { - boolean flag = this.burnTime > 0; - boolean flag1 = false; - - // CraftBukkit start - Use wall time instead of ticks for cooking - int elapsedTicks = MinecraftServer.currentTick - this.lastTick; - this.lastTick = MinecraftServer.currentTick; - - // CraftBukkit - moved from below - if (this.isBurning() && this.canBurn()) { - this.cookTime += elapsedTicks; - if (this.cookTime >= 200) { - this.cookTime %= 200; - this.burn(); - flag1 = true; - } - } else { - this.cookTime = 0; - } - // CraftBukkit end - - if (this.burnTime > 0) { - this.burnTime -= elapsedTicks; // CraftBukkit - use elapsedTicks in place of constant - } - - if (!this.world.isStatic) { - if (this.burnTime != 0 || this.items[1] != null && this.items[0] != null) { - // CraftBukkit start - Handle multiple elapsed ticks - if (this.burnTime <= 0 && this.canBurn()) { // CraftBukkit - == to <= - CraftItemStack fuel = CraftItemStack.asCraftMirror(this.items[1]); - - FurnaceBurnEvent furnaceBurnEvent = new FurnaceBurnEvent(this.world.getWorld().getBlockAt(this.x, this.y, this.z), fuel, fuelTime(this.items[1])); - this.world.getServer().getPluginManager().callEvent(furnaceBurnEvent); - - if (furnaceBurnEvent.isCancelled()) { - return; - } - - this.ticksForCurrentFuel = furnaceBurnEvent.getBurnTime(); - this.burnTime += this.ticksForCurrentFuel; - if (this.burnTime > 0 && furnaceBurnEvent.isBurning()) { - // CraftBukkit end - flag1 = true; - if (this.items[1] != null) { - --this.items[1].count; - if (this.items[1].count == 0) { - Item item = this.items[1].getItem().t(); - - this.items[1] = item != null ? new ItemStack(item) : null; - } - } - } - } - - /* CraftBukkit start - Moved up - if (this.isBurning() && this.canBurn()) { - ++this.cookTime; - if (this.cookTime == 200) { - this.cookTime = 0; - this.burn(); - flag1 = true; - } - } else { - this.cookTime = 0; - } - */ - } - - if (flag != this.burnTime > 0) { - flag1 = true; - BlockFurnace.a(this.burnTime > 0, this.world, this.x, this.y, this.z); - } - } - - if (flag1) { - this.update(); - } - } - - private boolean canBurn() { - if (this.items[0] == null) { - return false; - } else { - ItemStack itemstack = RecipesFurnace.getInstance().getResult(this.items[0]); - - // CraftBukkit - consider resultant count instead of current count - return itemstack == null ? false : (this.items[2] == null ? true : (!this.items[2].doMaterialsMatch(itemstack) ? false : (this.items[2].count + itemstack.count <= this.getMaxStackSize() && this.items[2].count < this.items[2].getMaxStackSize() ? true : this.items[2].count + itemstack.count <= itemstack.getMaxStackSize()))); - } - } - - public void burn() { - if (this.canBurn()) { - ItemStack itemstack = RecipesFurnace.getInstance().getResult(this.items[0]); - - // CraftBukkit start - fire FurnaceSmeltEvent - CraftItemStack source = CraftItemStack.asCraftMirror(this.items[0]); - org.bukkit.inventory.ItemStack result = CraftItemStack.asBukkitCopy(itemstack); - - FurnaceSmeltEvent furnaceSmeltEvent = new FurnaceSmeltEvent(this.world.getWorld().getBlockAt(this.x, this.y, this.z), source, result); - this.world.getServer().getPluginManager().callEvent(furnaceSmeltEvent); - - if (furnaceSmeltEvent.isCancelled()) { - return; - } - - result = furnaceSmeltEvent.getResult(); - itemstack = CraftItemStack.asNMSCopy(result); - - if (itemstack != null) { - if (this.items[2] == null) { - this.items[2] = itemstack; - } else if (CraftItemStack.asCraftMirror(this.items[2]).isSimilar(result)) { - this.items[2].count += itemstack.count; - } else { - return; - } - } - // CraftBukkit end - - --this.items[0].count; - if (this.items[0].count <= 0) { - this.items[0] = null; - } - } - } - - public static int fuelTime(ItemStack itemstack) { - if (itemstack == null) { - return 0; - } else { - Item item = itemstack.getItem(); - - if (item instanceof ItemBlock && Block.a(item) != Blocks.AIR) { - Block block = Block.a(item); - - if (block == Blocks.WOOD_STEP) { - return 150; - } - - if (block.getMaterial() == Material.WOOD) { - return 300; - } - - if (block == Blocks.COAL_BLOCK) { - return 16000; - } - } - - return item instanceof ItemTool && ((ItemTool) item).j().equals("WOOD") ? 200 : (item instanceof ItemSword && ((ItemSword) item).j().equals("WOOD") ? 200 : (item instanceof ItemHoe && ((ItemHoe) item).i().equals("WOOD") ? 200 : (item == Items.STICK ? 100 : (item == Items.COAL ? 1600 : (item == Items.LAVA_BUCKET ? 20000 : (item == Item.getItemOf(Blocks.SAPLING) ? 100 : (item == Items.BLAZE_ROD ? 2400 : 0))))))); - } - } - - public static boolean isFuel(ItemStack itemstack) { - return fuelTime(itemstack) > 0; - } - - 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 closeContainer() {} - - public boolean b(int i, ItemStack itemstack) { - return i == 2 ? false : (i == 1 ? isFuel(itemstack) : true); - } - - public int[] getSlotsForFace(int i) { - return i == 0 ? l : (i == 1 ? k : m); - } - - public boolean canPlaceItemThroughFace(int i, ItemStack itemstack, int j) { - return this.b(i, itemstack); - } - - public boolean canTakeItemThroughFace(int i, ItemStack itemstack, int j) { - return j != 0 || i != 1 || itemstack.getItem() == Items.BUCKET; - } -} diff --git a/src/main/java/net/minecraft/server/TileEntityHopper.java b/src/main/java/net/minecraft/server/TileEntityHopper.java deleted file mode 100644 index ebdf08e7..00000000 --- a/src/main/java/net/minecraft/server/TileEntityHopper.java +++ /dev/null @@ -1,584 +0,0 @@ -package net.minecraft.server; - -import java.util.List; - -// CraftBukkit start -import org.bukkit.craftbukkit.entity.CraftHumanEntity; -import org.bukkit.craftbukkit.inventory.CraftItemStack; -import org.bukkit.entity.HumanEntity; -import org.bukkit.event.inventory.InventoryMoveItemEvent; -import org.bukkit.event.inventory.InventoryPickupItemEvent; -import org.bukkit.inventory.Inventory; -// CraftBukkit end - -public class TileEntityHopper extends TileEntity implements IHopper { - - private ItemStack[] a = new ItemStack[5]; - private String i; - private int j = -1; - - // CraftBukkit start - add fields and methods - public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>(); - private int maxStack = MAX_STACK; - - public ItemStack[] getContents() { - return this.a; - } - - 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 TileEntityHopper() {} - - public void a(NBTTagCompound nbttagcompound) { - super.a(nbttagcompound); - NBTTagList nbttaglist = nbttagcompound.getList("Items", 10); - - this.a = new ItemStack[this.getSize()]; - if (nbttagcompound.hasKeyOfType("CustomName", 8)) { - this.i = nbttagcompound.getString("CustomName"); - } - - this.j = nbttagcompound.getInt("TransferCooldown"); - - for (int i = 0; i < nbttaglist.size(); ++i) { - NBTTagCompound nbttagcompound1 = nbttaglist.get(i); - byte b0 = nbttagcompound1.getByte("Slot"); - - if (b0 >= 0 && b0 < this.a.length) { - this.a[b0] = ItemStack.createStack(nbttagcompound1); - } - } - } - - public void b(NBTTagCompound nbttagcompound) { - super.b(nbttagcompound); - NBTTagList nbttaglist = new NBTTagList(); - - for (int i = 0; i < this.a.length; ++i) { - if (this.a[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - - nbttagcompound1.setByte("Slot", (byte) i); - this.a[i].save(nbttagcompound1); - nbttaglist.add(nbttagcompound1); - } - } - - nbttagcompound.set("Items", nbttaglist); - nbttagcompound.setInt("TransferCooldown", this.j); - if (this.k_()) { - nbttagcompound.setString("CustomName", this.i); - } - } - - public void update() { - super.update(); - } - - public int getSize() { - return this.a.length; - } - - public ItemStack getItem(int i) { - return this.a[i]; - } - - public ItemStack splitStack(int i, int j) { - if (this.a[i] != null) { - ItemStack itemstack; - - if (this.a[i].count <= j) { - itemstack = this.a[i]; - this.a[i] = null; - return itemstack; - } else { - itemstack = this.a[i].a(j); - if (this.a[i].count == 0) { - this.a[i] = null; - } - - return itemstack; - } - } else { - return null; - } - } - - public ItemStack splitWithoutUpdate(int i) { - if (this.a[i] != null) { - ItemStack itemstack = this.a[i]; - - this.a[i] = null; - return itemstack; - } else { - return null; - } - } - - public void setItem(int i, ItemStack itemstack) { - this.a[i] = itemstack; - if (itemstack != null && itemstack.count > this.getMaxStackSize()) { - itemstack.count = this.getMaxStackSize(); - } - } - - public String getInventoryName() { - return this.k_() ? this.i : "container.hopper"; - } - - public boolean k_() { - return this.i != null && this.i.length() > 0; - } - - public void a(String s) { - this.i = s; - } - - 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 closeContainer() {} - - public boolean b(int i, ItemStack itemstack) { - return true; - } - - public void h() { - if (this.world != null && !this.world.isStatic) { - --this.j; - if (!this.j()) { - this.c(0); - this.i(); - } - } - } - - public boolean i() { - if (this.world != null && !this.world.isStatic) { - if (!this.j() && BlockHopper.c(this.p())) { - boolean flag = false; - - if (!this.k()) { - flag = this.y(); - } - - if (!this.l()) { - flag = suckInItems(this) || flag; - } - - if (flag) { - this.c(8); - this.update(); - return true; - } - } - - return false; - } else { - return false; - } - } - - private boolean k() { - ItemStack[] aitemstack = this.a; - int i = aitemstack.length; - - for (int j = 0; j < i; ++j) { - ItemStack itemstack = aitemstack[j]; - - if (itemstack != null) { - return false; - } - } - - return true; - } - - private boolean l() { - ItemStack[] aitemstack = this.a; - int i = aitemstack.length; - - for (int j = 0; j < i; ++j) { - ItemStack itemstack = aitemstack[j]; - - if (itemstack == null || itemstack.count != itemstack.getMaxStackSize()) { - return false; - } - } - - return true; - } - - private boolean y() { - IInventory iinventory = this.z(); - - if (iinventory == null) { - return false; - } else { - int i = Facing.OPPOSITE_FACING[BlockHopper.b(this.p())]; - - if (this.a(iinventory, i)) { - return false; - } else { - for (int j = 0; j < this.getSize(); ++j) { - if (this.getItem(j) != null) { - ItemStack itemstack = this.getItem(j).cloneItemStack(); - // CraftBukkit start - Call event when pushing items into other inventories - CraftItemStack oitemstack = CraftItemStack.asCraftMirror(this.splitStack(j, 1)); - - Inventory destinationInventory; - // Have to special case large chests as they work oddly - if (iinventory instanceof InventoryLargeChest) { - destinationInventory = new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest((InventoryLargeChest) iinventory); - } else { - destinationInventory = iinventory.getOwner().getInventory(); - } - - InventoryMoveItemEvent event = new InventoryMoveItemEvent(this.getOwner().getInventory(), oitemstack.clone(), destinationInventory, true); - this.getWorld().getServer().getPluginManager().callEvent(event); - if (event.isCancelled()) { - this.setItem(j, itemstack); - this.c(8); // Delay hopper checks - return false; - } - ItemStack itemstack1 = addItem(iinventory, CraftItemStack.asNMSCopy(event.getItem()), i); - - if (itemstack1 == null || itemstack1.count == 0) { - if (event.getItem().equals(oitemstack)) { - iinventory.update(); - } else { - this.setItem(j, itemstack); - } - // CraftBukkit end - return true; - } - - this.setItem(j, itemstack); - } - } - - return false; - } - } - } - - private boolean a(IInventory iinventory, int i) { - if (iinventory instanceof IWorldInventory && i > -1) { - IWorldInventory iworldinventory = (IWorldInventory) iinventory; - int[] aint = iworldinventory.getSlotsForFace(i); - - for (int j = 0; j < aint.length; ++j) { - ItemStack itemstack = iworldinventory.getItem(aint[j]); - - if (itemstack == null || itemstack.count != itemstack.getMaxStackSize()) { - return false; - } - } - } else { - int k = iinventory.getSize(); - - for (int l = 0; l < k; ++l) { - ItemStack itemstack1 = iinventory.getItem(l); - - if (itemstack1 == null || itemstack1.count != itemstack1.getMaxStackSize()) { - return false; - } - } - } - - return true; - } - - private static boolean b(IInventory iinventory, int i) { - if (iinventory instanceof IWorldInventory && i > -1) { - IWorldInventory iworldinventory = (IWorldInventory) iinventory; - int[] aint = iworldinventory.getSlotsForFace(i); - - for (int j = 0; j < aint.length; ++j) { - if (iworldinventory.getItem(aint[j]) != null) { - return false; - } - } - } else { - int k = iinventory.getSize(); - - for (int l = 0; l < k; ++l) { - if (iinventory.getItem(l) != null) { - return false; - } - } - } - - return true; - } - - public static boolean suckInItems(IHopper ihopper) { - IInventory iinventory = getSourceInventory(ihopper); - - if (iinventory != null) { - byte b0 = 0; - - if (b(iinventory, b0)) { - return false; - } - - if (iinventory instanceof IWorldInventory && b0 > -1) { - IWorldInventory iworldinventory = (IWorldInventory) iinventory; - int[] aint = iworldinventory.getSlotsForFace(b0); - - for (int i = 0; i < aint.length; ++i) { - if (tryTakeInItemFromSlot(ihopper, iinventory, aint[i], b0)) { - return true; - } - } - } else { - int j = iinventory.getSize(); - - for (int k = 0; k < j; ++k) { - if (tryTakeInItemFromSlot(ihopper, iinventory, k, b0)) { - return true; - } - } - } - } else { - EntityItem entityitem = getEntityItemAt(ihopper.getWorld(), ihopper.x(), ihopper.aD() + 1.0D, ihopper.aE()); - - if (entityitem != null) { - return addEntityItem(ihopper, entityitem); - } - } - - return false; - } - - private static boolean tryTakeInItemFromSlot(IHopper ihopper, IInventory iinventory, int i, int j) { - ItemStack itemstack = iinventory.getItem(i); - - if (itemstack != null && canTakeItemFromInventory(iinventory, itemstack, i, j)) { - ItemStack itemstack1 = itemstack.cloneItemStack(); - // CraftBukkit start - Call event on collection of items from inventories into the hopper - CraftItemStack oitemstack = CraftItemStack.asCraftMirror(iinventory.splitStack(i, 1)); - - Inventory sourceInventory; - // Have to special case large chests as they work oddly - if (iinventory instanceof InventoryLargeChest) { - sourceInventory = new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest((InventoryLargeChest) iinventory); - } else { - sourceInventory = iinventory.getOwner().getInventory(); - } - - InventoryMoveItemEvent event = new InventoryMoveItemEvent(sourceInventory, oitemstack.clone(), ihopper.getOwner().getInventory(), false); - - ihopper.getWorld().getServer().getPluginManager().callEvent(event); - if (event.isCancelled()) { - iinventory.setItem(i, itemstack1); - - if (ihopper instanceof TileEntityHopper) { - ((TileEntityHopper) ihopper).c(8); // Delay hopper checks - } else if (ihopper instanceof EntityMinecartHopper) { - ((EntityMinecartHopper) ihopper).l(4); // Delay hopper minecart checks - } - - return false; - } - ItemStack itemstack2 = addItem(ihopper, CraftItemStack.asNMSCopy(event.getItem()), -1); - - if (itemstack2 == null || itemstack2.count == 0) { - if (event.getItem().equals(oitemstack)) { - iinventory.update(); - } else { - iinventory.setItem(i, itemstack1); - } - // CraftBukkit end - - return true; - } - - iinventory.setItem(i, itemstack1); - } - - return false; - } - - public static boolean addEntityItem(IInventory iinventory, EntityItem entityitem) { - boolean flag = false; - - if (entityitem == null) { - return false; - } else { - // CraftBukkit start - InventoryPickupItemEvent event = new InventoryPickupItemEvent(iinventory.getOwner().getInventory(), (org.bukkit.entity.Item) entityitem.getBukkitEntity()); - entityitem.world.getServer().getPluginManager().callEvent(event); - if (event.isCancelled()) { - return false; - } - // CraftBukkit end - - ItemStack itemstack = entityitem.getItemStack().cloneItemStack(); - ItemStack itemstack1 = addItem(iinventory, itemstack, -1); - - if (itemstack1 != null && itemstack1.count != 0) { - entityitem.setItemStack(itemstack1); - } else { - flag = true; - entityitem.die(); - } - - return flag; - } - } - - public static ItemStack addItem(IInventory iinventory, ItemStack itemstack, int i) { - if (iinventory instanceof IWorldInventory && i > -1) { - IWorldInventory iworldinventory = (IWorldInventory) iinventory; - int[] aint = iworldinventory.getSlotsForFace(i); - - for (int j = 0; j < aint.length && itemstack != null && itemstack.count > 0; ++j) { - itemstack = tryMoveInItem(iinventory, itemstack, aint[j], i); - } - } else { - int k = iinventory.getSize(); - - for (int l = 0; l < k && itemstack != null && itemstack.count > 0; ++l) { - itemstack = tryMoveInItem(iinventory, itemstack, l, i); - } - } - - if (itemstack != null && itemstack.count == 0) { - itemstack = null; - } - - return itemstack; - } - - private static boolean canPlaceItemInInventory(IInventory iinventory, ItemStack itemstack, int i, int j) { - return !iinventory.b(i, itemstack) ? false : !(iinventory instanceof IWorldInventory) || ((IWorldInventory) iinventory).canPlaceItemThroughFace(i, itemstack, j); - } - - private static boolean canTakeItemFromInventory(IInventory iinventory, ItemStack itemstack, int i, int j) { - return !(iinventory instanceof IWorldInventory) || ((IWorldInventory) iinventory).canTakeItemThroughFace(i, itemstack, j); - } - - private static ItemStack tryMoveInItem(IInventory iinventory, ItemStack itemstack, int i, int j) { - ItemStack itemstack1 = iinventory.getItem(i); - - if (canPlaceItemInInventory(iinventory, itemstack, i, j)) { - boolean flag = false; - - if (itemstack1 == null) { - iinventory.setItem(i, itemstack); - itemstack = null; - flag = true; - } else if (canMergeItems(itemstack1, itemstack)) { - int k = itemstack.getMaxStackSize() - itemstack1.count; - int l = Math.min(itemstack.count, k); - - itemstack.count -= l; - itemstack1.count += l; - flag = l > 0; - } - - if (flag) { - if (iinventory instanceof TileEntityHopper) { - ((TileEntityHopper) iinventory).c(8); - iinventory.update(); - } - - iinventory.update(); - } - } - - return itemstack; - } - - private IInventory z() { - int i = BlockHopper.b(this.p()); - - return getInventoryAt(this.getWorld(), (double) (this.x + Facing.b[i]), (double) (this.y + Facing.c[i]), (double) (this.z + Facing.d[i])); - } - - public static IInventory getSourceInventory(IHopper ihopper) { - return getInventoryAt(ihopper.getWorld(), ihopper.x(), ihopper.aD() + 1.0D, ihopper.aE()); - } - - public static EntityItem getEntityItemAt(World world, double d0, double d1, double d2) { - List list = world.a(EntityItem.class, AxisAlignedBB.a(d0, d1, d2, d0 + 1.0D, d1 + 1.0D, d2 + 1.0D), IEntitySelector.a); - - return list.size() > 0 ? (EntityItem) list.get(0) : null; - } - - public static IInventory getInventoryAt(World world, double d0, double d1, double d2) { - IInventory iinventory = null; - int i = MathHelper.floor(d0); - int j = MathHelper.floor(d1); - int k = MathHelper.floor(d2); - TileEntity tileentity = world.getTileEntity(i, j, k); - - if (tileentity != null && tileentity instanceof IInventory) { - iinventory = (IInventory) tileentity; - if (iinventory instanceof TileEntityChest) { - Block block = world.getType(i, j, k); - - if (block instanceof BlockChest) { - iinventory = ((BlockChest) block).m(world, i, j, k); - } - } - } - - if (iinventory == null) { - List list = world.getEntities((Entity) null, AxisAlignedBB.a(d0, d1, d2, d0 + 1.0D, d1 + 1.0D, d2 + 1.0D), IEntitySelector.c); - - if (list != null && list.size() > 0) { - iinventory = (IInventory) list.get(world.random.nextInt(list.size())); - } - } - - return iinventory; - } - - private static boolean canMergeItems(ItemStack itemstack, ItemStack itemstack1) { - return itemstack.getItem() != itemstack1.getItem() ? false : (itemstack.getData() != itemstack1.getData() ? false : (itemstack.count > itemstack.getMaxStackSize() ? false : ItemStack.equals(itemstack, itemstack1))); - } - - public double x() { - return (double) this.x; - } - - public double aD() { - return (double) this.y; - } - - public double aE() { - return (double) this.z; - } - - public void c(int i) { - this.j = i; - } - - public boolean j() { - return this.j > 0; - } -} diff --git a/src/main/java/net/minecraft/server/TileEntityNote.java b/src/main/java/net/minecraft/server/TileEntityNote.java deleted file mode 100644 index aa020389..00000000 --- a/src/main/java/net/minecraft/server/TileEntityNote.java +++ /dev/null @@ -1,61 +0,0 @@ -package net.minecraft.server; - -public class TileEntityNote extends TileEntity { - - public byte note; - public boolean i; - - public TileEntityNote() {} - - public void b(NBTTagCompound nbttagcompound) { - super.b(nbttagcompound); - nbttagcompound.setByte("note", this.note); - } - - public void a(NBTTagCompound nbttagcompound) { - super.a(nbttagcompound); - this.note = nbttagcompound.getByte("note"); - if (this.note < 0) { - this.note = 0; - } - - if (this.note > 24) { - this.note = 24; - } - } - - public void a() { - this.note = (byte) ((this.note + 1) % 25); - this.update(); - } - - public void play(World world, int i, int j, int k) { - if (world.getType(i, j + 1, k).getMaterial() == Material.AIR) { - Material material = world.getType(i, j - 1, k).getMaterial(); - byte b0 = 0; - - if (material == Material.STONE) { - b0 = 1; - } - - if (material == Material.SAND) { - b0 = 2; - } - - if (material == Material.SHATTERABLE) { - b0 = 3; - } - - if (material == Material.WOOD) { - b0 = 4; - } - - // CraftBukkit start - org.bukkit.event.block.NotePlayEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callNotePlayEvent(this.world, i, j, k, b0, this.note); - if (!event.isCancelled()) { - this.world.playBlockAction(i, j, k, Blocks.NOTE_BLOCK, event.getInstrument().getType(), event.getNote().getId()); - } - // CraftBukkit end - } - } -} diff --git a/src/main/java/net/minecraft/server/TileEntityPiston.java b/src/main/java/net/minecraft/server/TileEntityPiston.java deleted file mode 100644 index 69fe247b..00000000 --- a/src/main/java/net/minecraft/server/TileEntityPiston.java +++ /dev/null @@ -1,132 +0,0 @@ -package net.minecraft.server; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -public class TileEntityPiston extends TileEntity { - - private Block a; - private int i; - private int j; - private boolean k; - private boolean l; - private float m; - private float n; - private List o = new ArrayList(); - - public TileEntityPiston() {} - - public TileEntityPiston(Block block, int i, int j, boolean flag, boolean flag1) { - this.a = block; - this.i = i; - this.j = j; - this.k = flag; - this.l = flag1; - } - - public Block a() { - return this.a; - } - - public int p() { - return this.i; - } - - public boolean b() { - return this.k; - } - - public int c() { - return this.j; - } - - public float a(float f) { - if (f > 1.0F) { - f = 1.0F; - } - - return this.n + (this.m - this.n) * f; - } - - private void a(float f, float f1) { - if (this.k) { - f = 1.0F - f; - } else { - --f; - } - - AxisAlignedBB axisalignedbb = Blocks.PISTON_MOVING.a(this.world, this.x, this.y, this.z, this.a, f, this.j); - - if (axisalignedbb != null) { - List list = this.world.getEntities((Entity) null, axisalignedbb); - - if (!list.isEmpty()) { - this.o.addAll(list); - Iterator iterator = this.o.iterator(); - - while (iterator.hasNext()) { - Entity entity = (Entity) iterator.next(); - - entity.move((double) (f1 * (float) Facing.b[this.j]), (double) (f1 * (float) Facing.c[this.j]), (double) (f1 * (float) Facing.d[this.j])); - } - - this.o.clear(); - } - } - } - - public void f() { - if (this.n < 1.0F && this.world != null) { - this.n = this.m = 1.0F; - this.world.p(this.x, this.y, this.z); - this.s(); - if (this.world.getType(this.x, this.y, this.z) == Blocks.PISTON_MOVING) { - this.world.setTypeAndData(this.x, this.y, this.z, this.a, this.i, 3); - this.world.e(this.x, this.y, this.z, this.a); - } - } - } - - public void h() { - if (this.world == null) return; // CraftBukkit - - this.n = this.m; - if (this.n >= 1.0F) { - this.a(1.0F, 0.25F); - this.world.p(this.x, this.y, this.z); - this.s(); - if (this.world.getType(this.x, this.y, this.z) == Blocks.PISTON_MOVING) { - this.world.setTypeAndData(this.x, this.y, this.z, this.a, this.i, 3); - this.world.e(this.x, this.y, this.z, this.a); - } - } else { - this.m += 0.5F; - if (this.m >= 1.0F) { - this.m = 1.0F; - } - - if (this.k) { - this.a(this.m, this.m - this.n + 0.0625F); - } - } - } - - public void a(NBTTagCompound nbttagcompound) { - super.a(nbttagcompound); - this.a = Block.getById(nbttagcompound.getInt("blockId")); - this.i = nbttagcompound.getInt("blockData"); - this.j = nbttagcompound.getInt("facing"); - this.n = this.m = nbttagcompound.getFloat("progress"); - this.k = nbttagcompound.getBoolean("extending"); - } - - public void b(NBTTagCompound nbttagcompound) { - super.b(nbttagcompound); - nbttagcompound.setInt("blockId", Block.getId(this.a)); - nbttagcompound.setInt("blockData", this.i); - nbttagcompound.setInt("facing", this.j); - nbttagcompound.setFloat("progress", this.n); - nbttagcompound.setBoolean("extending", this.k); - } -} diff --git a/src/main/java/net/minecraft/server/TileEntityRecordPlayer.java b/src/main/java/net/minecraft/server/TileEntityRecordPlayer.java deleted file mode 100644 index 8abeac49..00000000 --- a/src/main/java/net/minecraft/server/TileEntityRecordPlayer.java +++ /dev/null @@ -1,40 +0,0 @@ -package net.minecraft.server; - -public class TileEntityRecordPlayer extends TileEntity { - - private ItemStack record; - - public TileEntityRecordPlayer() {} - - public void a(NBTTagCompound nbttagcompound) { - super.a(nbttagcompound); - if (nbttagcompound.hasKeyOfType("RecordItem", 10)) { - this.setRecord(ItemStack.createStack(nbttagcompound.getCompound("RecordItem"))); - } else if (nbttagcompound.getInt("Record") > 0) { - this.setRecord(new ItemStack(Item.getById(nbttagcompound.getInt("Record")), 1, 0)); - } - } - - public void b(NBTTagCompound nbttagcompound) { - super.b(nbttagcompound); - if (this.getRecord() != null) { - nbttagcompound.set("RecordItem", this.getRecord().save(new NBTTagCompound())); - nbttagcompound.setInt("Record", Item.getId(this.getRecord().getItem())); - } - } - - public ItemStack getRecord() { - return this.record; - } - - public void setRecord(ItemStack itemstack) { - // CraftBukkit start - There can only be one - if (itemstack != null) { - itemstack.count = 1; - } - // CraftBukkit end - - this.record = itemstack; - this.update(); - } -} diff --git a/src/main/java/net/minecraft/server/TileEntitySign.java b/src/main/java/net/minecraft/server/TileEntitySign.java deleted file mode 100644 index 552919c4..00000000 --- a/src/main/java/net/minecraft/server/TileEntitySign.java +++ /dev/null @@ -1,63 +0,0 @@ -package net.minecraft.server; - -public class TileEntitySign extends TileEntity { - - public String[] lines = new String[] { "", "", "", ""}; - public int i = -1; - public boolean isEditable = true; // CraftBukkit - private -> public - private EntityHuman k; - - public TileEntitySign() {} - - public void b(NBTTagCompound nbttagcompound) { - super.b(nbttagcompound); - nbttagcompound.setString("Text1", this.lines[0]); - nbttagcompound.setString("Text2", this.lines[1]); - nbttagcompound.setString("Text3", this.lines[2]); - nbttagcompound.setString("Text4", this.lines[3]); - } - - public void a(NBTTagCompound nbttagcompound) { - this.isEditable = false; - super.a(nbttagcompound); - - for (int i = 0; i < 4; ++i) { - this.lines[i] = nbttagcompound.getString("Text" + (i + 1)); - if (this.lines[i].length() > 15) { - this.lines[i] = this.lines[i].substring(0, 15); - } - } - } - - public Packet getUpdatePacket() { - String[] astring = sanitizeLines(this.lines); // CraftBukkit - call sign line sanitizer to limit line length - - return new PacketPlayOutUpdateSign(this.x, this.y, this.z, astring); - } - - public boolean a() { - return this.isEditable; - } - - public void a(EntityHuman entityhuman) { - this.k = entityhuman; - } - - public EntityHuman b() { - return this.k; - } - - // CraftBukkit start - central method to limit sign text to 15 chars per line - public static String[] sanitizeLines(String[] lines) { - String[] astring = new String[4]; - for (int i = 0; i < 4; ++i) { - astring[i] = lines[i]; - - if (lines[i].length() > 15) { - astring[i] = lines[i].substring(0, 15); - } - } - return astring; - } - // CraftBukkit end -} diff --git a/src/main/java/net/minecraft/server/TileEntitySkull.java b/src/main/java/net/minecraft/server/TileEntitySkull.java deleted file mode 100644 index 7c3757fb..00000000 --- a/src/main/java/net/minecraft/server/TileEntitySkull.java +++ /dev/null @@ -1,97 +0,0 @@ -package net.minecraft.server; - -import java.util.UUID; - -import net.minecraft.util.com.google.common.collect.Iterables; -import net.minecraft.util.com.mojang.authlib.GameProfile; -import net.minecraft.util.com.mojang.authlib.properties.Property; - -public class TileEntitySkull extends TileEntity { - - private int a; - private int i; - private GameProfile j = null; - - public TileEntitySkull() {} - - public void b(NBTTagCompound nbttagcompound) { - super.b(nbttagcompound); - nbttagcompound.setByte("SkullType", (byte) (this.a & 255)); - nbttagcompound.setByte("Rot", (byte) (this.i & 255)); - if (this.j != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - - GameProfileSerializer.serialize(nbttagcompound1, this.j); - nbttagcompound.set("Owner", nbttagcompound1); - } - } - - public void a(NBTTagCompound nbttagcompound) { - super.a(nbttagcompound); - this.a = nbttagcompound.getByte("SkullType"); - this.i = nbttagcompound.getByte("Rot"); - if (this.a == 3) { - if (nbttagcompound.hasKeyOfType("Owner", 10)) { - this.j = GameProfileSerializer.deserialize(nbttagcompound.getCompound("Owner")); - } else if (nbttagcompound.hasKeyOfType("ExtraType", 8) && !UtilColor.b(nbttagcompound.getString("ExtraType"))) { - this.j = new GameProfile((UUID) null, nbttagcompound.getString("ExtraType")); - this.d(); - } - } - } - - public GameProfile getGameProfile() { - return this.j; - } - - public Packet getUpdatePacket() { - NBTTagCompound nbttagcompound = new NBTTagCompound(); - - this.b(nbttagcompound); - return new PacketPlayOutTileEntityData(this.x, this.y, this.z, 4, nbttagcompound); - } - - public void setSkullType(int i) { - this.a = i; - this.j = null; - } - - public void setGameProfile(GameProfile gameprofile) { - this.a = 3; - this.j = gameprofile; - this.d(); - } - - private void d() { - if (this.j != null && !UtilColor.b(this.j.getName())) { - if (!this.j.isComplete() || !this.j.getProperties().containsKey("textures")) { - GameProfile gameprofile = MinecraftServer.getServer().getUserCache().getProfile(this.j.getName()); - - if (gameprofile != null) { - Property property = (Property) Iterables.getFirst(gameprofile.getProperties().get("textures"), null); - - if (property == null) { - gameprofile = MinecraftServer.getServer().av().fillProfileProperties(gameprofile, true); - } - - this.j = gameprofile; - this.update(); - } - } - } - } - - public int getSkullType() { - return this.a; - } - - public void setRotation(int i) { - this.i = i; - } - - // CraftBukkit start - add method - public int getRotation() { - return this.i; - } - // CraftBukkit end -} diff --git a/src/main/java/net/minecraft/server/Village.java b/src/main/java/net/minecraft/server/Village.java deleted file mode 100644 index 89f1b74e..00000000 --- a/src/main/java/net/minecraft/server/Village.java +++ /dev/null @@ -1,446 +0,0 @@ -package net.minecraft.server; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.TreeMap; - -public class Village { - - 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); - private int size; - private int f; - private int time; - private int population; - private int noBreedTicks; - private TreeMap playerStandings = new TreeMap(); - private List aggressors = new ArrayList(); - private int ironGolemCount; - - 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.m(); - this.l(); - if (i % 20 == 0) { - this.k(); - } - - if (i % 30 == 0) { - this.countPopulation(); - } - - int j = this.population / 10; - - 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); - this.world.addEntity(entityirongolem, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.VILLAGE_DEFENSE); // CraftBukkit - ++this.ironGolemCount; - } - } - } - - private Vec3D a(int i, int j, int k, int l, int i1, int j1) { - for (int k1 = 0; k1 < 10; ++k1) { - int l1 = i + this.world.random.nextInt(16) - 8; - int i2 = j + this.world.random.nextInt(6) - 3; - 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((double) l1, (double) i2, (double) j2); - } - } - - return null; - } - - private boolean b(int i, int j, int k, int l, int i1, int j1) { - if (!World.a((IBlockAccess) this.world, i, j - 1, k)) { - return false; - } else { - int k1 = i - l / 2; - int l1 = k - j1 / 2; - - for (int i2 = k1; i2 < k1 + l; ++i2) { - for (int j2 = j; j2 < j + i1; ++j2) { - for (int k2 = l1; k2 < l1 + j1; ++k2) { - if (this.world.getType(i2, j2, k2).r()) { - return false; - } - } - } - } - - return true; - } - } - - private void countPopulation() { - List list = this.world.a(EntityIronGolem.class, AxisAlignedBB.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.ironGolemCount = list.size(); - } - - private void k() { - List list = this.world.a(EntityVillager.class, AxisAlignedBB.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() { - return this.center; - } - - public int getSize() { - return this.size; - } - - public int getDoorCount() { - return this.doors.size(); - } - - public int d() { - return this.time - this.f; - } - - public int getPopulationCount() { - return this.population; - } - - public boolean a(int i, int j, int k) { - return this.center.e(i, j, k) < (float) (this.size * this.size); - } - - public List getDoors() { - return this.doors; - } - - public VillageDoor b(int i, int j, int k) { - VillageDoor villagedoor = null; - int l = Integer.MAX_VALUE; - Iterator iterator = this.doors.iterator(); - - while (iterator.hasNext()) { - VillageDoor villagedoor1 = (VillageDoor) iterator.next(); - int i1 = villagedoor1.b(i, j, k); - - if (i1 < l) { - villagedoor = villagedoor1; - l = i1; - } - } - - return villagedoor; - } - - public VillageDoor c(int i, int j, int k) { - VillageDoor villagedoor = null; - int l = Integer.MAX_VALUE; - Iterator iterator = this.doors.iterator(); - - while (iterator.hasNext()) { - VillageDoor villagedoor1 = (VillageDoor) iterator.next(); - int i1 = villagedoor1.b(i, j, k); - - if (i1 > 256) { - i1 *= 1000; - } else { - i1 = villagedoor1.f(); - } - - if (i1 < l) { - villagedoor = villagedoor1; - l = i1; - } - } - - return villagedoor; - } - - public VillageDoor e(int i, int j, int k) { - if (this.center.e(i, j, k) > (float) (this.size * this.size)) { - return null; - } else { - Iterator iterator = this.doors.iterator(); - - VillageDoor villagedoor; - - do { - if (!iterator.hasNext()) { - return null; - } - - villagedoor = (VillageDoor) iterator.next(); - } while (villagedoor.locX != i || villagedoor.locZ != k || Math.abs(villagedoor.locY - j) > 1); - - return villagedoor; - } - } - - public void addDoor(VillageDoor villagedoor) { - this.doors.add(villagedoor); - this.c.x += villagedoor.locX; - this.c.y += villagedoor.locY; - this.c.z += villagedoor.locZ; - this.n(); - this.f = villagedoor.addedTime; - } - - public boolean isAbandoned() { - return this.doors.isEmpty(); - } - - public void a(EntityLiving entityliving) { - Iterator iterator = this.aggressors.iterator(); - - VillageAggressor villageaggressor; - - do { - if (!iterator.hasNext()) { - this.aggressors.add(new VillageAggressor(this, entityliving, this.time)); - return; - } - - villageaggressor = (VillageAggressor) iterator.next(); - } while (villageaggressor.a != entityliving); - - villageaggressor.b = this.time; - } - - public EntityLiving b(EntityLiving entityliving) { - double d0 = Double.MAX_VALUE; - VillageAggressor villageaggressor = null; - - for (int i = 0; i < this.aggressors.size(); ++i) { - VillageAggressor villageaggressor1 = (VillageAggressor) this.aggressors.get(i); - double d1 = villageaggressor1.a.f(entityliving); - - if (d1 <= d0) { - villageaggressor = villageaggressor1; - d0 = d1; - } - } - - return villageaggressor != null ? villageaggressor.a : null; - } - - 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.f(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(); - - if (!villageaggressor.a.isAlive() || Math.abs(this.time - villageaggressor.b) > 300) { - iterator.remove(); - } - } - } - - private void m() { - boolean flag = false; - boolean flag1 = this.world.random.nextInt(50) == 0; - Iterator iterator = this.doors.iterator(); - - while (iterator.hasNext()) { - VillageDoor villagedoor = (VillageDoor) iterator.next(); - - if (flag1) { - villagedoor.d(); - } - - if (!this.isDoor(villagedoor.locX, villagedoor.locY, villagedoor.locZ) || Math.abs(this.time - villagedoor.addedTime) > 1200) { - this.c.x -= villagedoor.locX; - this.c.y -= villagedoor.locY; - this.c.z -= villagedoor.locZ; - flag = true; - villagedoor.removed = true; - iterator.remove(); - } - } - - if (flag) { - this.n(); - } - } - - private boolean isDoor(int i, int j, int k) { - return this.world.getType(i, j, k) == Blocks.WOODEN_DOOR; - } - - private void n() { - int i = this.doors.size(); - - if (i == 0) { - this.center.b(0, 0, 0); - this.size = 0; - } else { - this.center.b(this.c.x / i, this.c.y / i, this.c.z / i); - int j = 0; - - VillageDoor villagedoor; - - for (Iterator iterator = this.doors.iterator(); iterator.hasNext(); j = Math.max(villagedoor.b(this.center.x, this.center.y, this.center.z), j)) { - villagedoor = (VillageDoor) iterator.next(); - } - - 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", 10); - - for (int i = 0; i < nbttaglist.size(); ++i) { - NBTTagCompound nbttagcompound1 = 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", 10); - - for (int j = 0; j < nbttaglist1.size(); ++j) { - NBTTagCompound nbttagcompound2 = 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(); - Iterator iterator = this.doors.iterator(); - - while (iterator.hasNext()) { - VillageDoor villagedoor = (VillageDoor) iterator.next(); - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - - 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(); - Iterator iterator1 = this.playerStandings.keySet().iterator(); - - while (iterator1.hasNext()) { - String s = (String) iterator1.next(); - NBTTagCompound nbttagcompound2 = new NBTTagCompound(); - - 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 deleted file mode 100644 index 93e1a1ed..00000000 --- a/src/main/java/net/minecraft/server/VillageSiege.java +++ /dev/null @@ -1,172 +0,0 @@ -package net.minecraft.server; - -import java.util.Iterator; -import java.util.List; - -public class VillageSiege { - - private World world; - private boolean b; - private int c = -1; - private int d; - private int e; - private Village f; - private int g; - private int h; - private int i; - - public VillageSiege(World world) { - this.world = world; - } - - public void a() { - boolean flag = false; - - if (flag) { - if (this.c == 2) { - this.d = 100; - return; - } - } else { - if (this.world.w()) { - this.c = 0; - return; - } - - if (this.c == 2) { - return; - } - - if (this.c == 0) { - float f = this.world.c(0.0F); - - if ((double) f < 0.5D || (double) f > 0.501D) { - return; - } - - this.c = this.world.random.nextInt(10) == 0 ? 1 : 2; - this.b = false; - if (this.c == 2) { - return; - } - } - } - - if (!this.b) { - if (!this.b()) { - return; - } - - this.b = true; - } - - if (this.e > 0) { - --this.e; - } else { - this.e = 2; - if (this.d > 0) { - this.c(); - --this.d; - } else { - this.c = 2; - } - } - } - - private boolean b() { - List list = this.world.players; - Iterator iterator = list.iterator(); - - while (iterator.hasNext()) { - EntityHuman entityhuman = (EntityHuman) iterator.next(); - - this.f = this.world.villages.getClosestVillage((int) entityhuman.locX, (int) entityhuman.locY, (int) entityhuman.locZ, 1); - if (this.f != null && this.f.getDoorCount() >= 10 && this.f.d() >= 20 && this.f.getPopulationCount() >= 20) { - ChunkCoordinates chunkcoordinates = this.f.getCenter(); - float f = (float) this.f.getSize(); - boolean flag = false; - int i = 0; - - while (true) { - if (i < 10) { - this.g = chunkcoordinates.x + (int) ((double) (MathHelper.cos(this.world.random.nextFloat() * 3.1415927F * 2.0F) * f) * 0.9D); - this.h = chunkcoordinates.y; - this.i = chunkcoordinates.z + (int) ((double) (MathHelper.sin(this.world.random.nextFloat() * 3.1415927F * 2.0F) * f) * 0.9D); - flag = false; - Iterator iterator1 = this.world.villages.getVillages().iterator(); - - while (iterator1.hasNext()) { - Village village = (Village) iterator1.next(); - - if (village != this.f && village.a(this.g, this.h, this.i)) { - flag = true; - break; - } - } - - if (flag) { - ++i; - continue; - } - } - - if (flag) { - return false; - } - - Vec3D vec3d = this.a(this.g, this.h, this.i); - - if (vec3d != null) { - this.e = 0; - this.d = 20; - return true; - } - break; - } - } - } - - return false; - } - - private boolean c() { - Vec3D vec3d = this.a(this.g, this.h, this.i); - - if (vec3d == null) { - return false; - } else { - EntityZombie entityzombie; - - try { - entityzombie = new EntityZombie(this.world); - entityzombie.prepare((GroupDataEntity) null); - 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); - this.world.addEntity(entityzombie, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.VILLAGE_INVASION); // CraftBukkit - ChunkCoordinates chunkcoordinates = this.f.getCenter(); - - entityzombie.a(chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z, this.f.getSize()); - return true; - } - } - - private Vec3D a(int i, int j, int k) { - for (int l = 0; l < 10; ++l) { - int i1 = i + this.world.random.nextInt(16) - 8; - int j1 = j + this.world.random.nextInt(6) - 3; - 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)) { - // CraftBukkit - add Return - return Vec3D.a((double) i1, (double) j1, (double) k1); - } - } - - return null; - } -} diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java deleted file mode 100644 index 08c506ce..00000000 --- a/src/main/java/net/minecraft/server/World.java +++ /dev/null @@ -1,2873 +0,0 @@ -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.UUID; -import java.util.concurrent.Callable; - -// CraftBukkit start -import org.bukkit.Bukkit; -import org.bukkit.block.BlockState; -import org.bukkit.craftbukkit.util.CraftMagicNumbers; -import org.bukkit.craftbukkit.util.LongHashSet; -import org.bukkit.generator.ChunkGenerator; -import org.bukkit.craftbukkit.CraftServer; -import org.bukkit.craftbukkit.CraftWorld; -import org.bukkit.craftbukkit.event.CraftEventFactory; -import org.bukkit.event.block.BlockCanBuildEvent; -import org.bukkit.event.block.BlockPhysicsEvent; -import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; -import org.bukkit.event.weather.WeatherChangeEvent; -import org.bukkit.event.weather.ThunderChangeEvent; -// CraftBukkit end - -public abstract class World implements IBlockAccess { - - public boolean d; - public List entityList = new ArrayList(); - protected List f = new ArrayList(); - public Set tileEntityList = new HashSet(); // CraftBukkit - ArrayList -> HashSet - private List a = new ArrayList(); - private List b = new ArrayList(); - public List players = new ArrayList(); - public List i = new ArrayList(); - private long c = 16777215L; - public int j; - protected int k = (new Random()).nextInt(); - protected final int l = 1013904223; - protected float m; - protected float n; - protected float o; - protected float p; - public int q; - public EnumDifficulty difficulty; - public Random random = new Random(); - public WorldProvider worldProvider; // CraftBukkit - remove final - protected List u = new ArrayList(); - public IChunkProvider chunkProvider; // CraftBukkit - public - protected final IDataManager dataManager; - public WorldData worldData; // CraftBukkit - public - public boolean isLoading; - public PersistentCollection worldMaps; - public final PersistentVillage villages; - protected final VillageSiege siegeManager = new VillageSiege(this); - public final MethodProfiler methodProfiler; - private final Calendar J = Calendar.getInstance(); - public Scoreboard scoreboard = new Scoreboard(); // CraftBukkit - protected -> public - public boolean isStatic; - // CraftBukkit start - public, longhashset - protected LongHashSet chunkTickList = new LongHashSet(); - private int K; - public boolean allowMonsters; - public boolean allowAnimals; - // Added the following - public boolean captureBlockStates = false; - public boolean captureTreeGeneration = false; - public ArrayList<BlockState> capturedBlockStates= new ArrayList<BlockState>(); - public long ticksPerAnimalSpawns; - public long ticksPerMonsterSpawns; - public boolean populating; - private int tickPosition; - // CraftBukkit end - private ArrayList L; - private boolean M; - int[] I; - - public BiomeBase getBiome(int i, int j) { - if (this.isLoaded(i, 0, j)) { - Chunk chunk = this.getChunkAtWorldCoords(i, j); - - try { - return chunk.getBiome(i & 15, j & 15, this.worldProvider.e); - } catch (Throwable throwable) { - CrashReport crashreport = CrashReport.a(throwable, "Getting biome"); - CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Coordinates of biome request"); - - crashreportsystemdetails.a("Location", (Callable) (new CrashReportWorldLocation(this, i, j))); - throw new ReportedException(crashreport); - } - } else { - return this.worldProvider.e.getBiome(i, j); - } - } - - public WorldChunkManager getWorldChunkManager() { - return this.worldProvider.e; - } - - // CraftBukkit start - private final CraftWorld world; - public boolean pvpMode; - public boolean keepSpawnInMemory = true; - public ChunkGenerator generator; - - public CraftWorld getWorld() { - return this.world; - } - - public CraftServer getServer() { - return (CraftServer) Bukkit.getServer(); - } - - public Chunk getChunkIfLoaded(int x, int z) { - return ((ChunkProviderServer) this.chunkProvider).getChunkIfLoaded(x, z); - } - - // Changed signature - added gen and env - public World(IDataManager idatamanager, String s, WorldSettings worldsettings, WorldProvider worldprovider, MethodProfiler methodprofiler, ChunkGenerator gen, org.bukkit.World.Environment env) { - this.generator = gen; - this.world = new CraftWorld((WorldServer) this, gen, env); - this.ticksPerAnimalSpawns = this.getServer().getTicksPerAnimalSpawns(); // CraftBukkit - this.ticksPerMonsterSpawns = this.getServer().getTicksPerMonsterSpawns(); // CraftBukkit - // CraftBukkit end - - this.K = this.random.nextInt(12000); - this.allowMonsters = true; - this.allowAnimals = true; - this.L = new ArrayList(); - this.I = new int['\u8000']; - this.dataManager = idatamanager; - this.methodProfiler = methodprofiler; - this.worldMaps = new PersistentCollection(idatamanager); - this.worldData = idatamanager.getWorldData(); - if (worldprovider != null) { - this.worldProvider = worldprovider; - } else if (this.worldData != null && this.worldData.j() != 0) { - this.worldProvider = WorldProvider.byDimension(this.worldData.j()); - } else { - this.worldProvider = WorldProvider.byDimension(0); - } - - if (this.worldData == null) { - this.worldData = new WorldData(worldsettings, s); - } else { - this.worldData.setName(s); - } - - this.worldProvider.a(this); - this.chunkProvider = this.j(); - if (!this.worldData.isInitialized()) { - try { - this.a(worldsettings); - } catch (Throwable throwable) { - CrashReport crashreport = CrashReport.a(throwable, "Exception initializing level"); - - try { - this.a(crashreport); - } catch (Throwable throwable1) { - ; - } - - throw new ReportedException(crashreport); - } - - this.worldData.d(true); - } - - PersistentVillage persistentvillage = (PersistentVillage) this.worldMaps.get(PersistentVillage.class, "villages"); - - if (persistentvillage == null) { - this.villages = new PersistentVillage(this); - this.worldMaps.a("villages", this.villages); - } else { - this.villages = persistentvillage; - this.villages.a(this); - } - - this.B(); - this.a(); - - this.getServer().addWorld(this.world); // CraftBukkit - } - - protected abstract IChunkProvider j(); - - protected void a(WorldSettings worldsettings) { - this.worldData.d(true); - } - - public Block b(int i, int j) { - int k; - - for (k = 63; !this.isEmpty(i, k + 1, j); ++k) { - ; - } - - return this.getType(i, k, j); - } - - public Block getType(int i, int j, int k) { - // CraftBukkit start - tree generation - if (captureTreeGeneration) { - Iterator<BlockState> it = capturedBlockStates.iterator(); - while (it.hasNext()) { - BlockState previous = it.next(); - if (previous.getX() == i && previous.getY() == j && previous.getZ() == k) { - return CraftMagicNumbers.getBlock(previous.getTypeId()); - } - } - } - // CraftBukkit end - if (i >= -30000000 && k >= -30000000 && i < 30000000 && k < 30000000 && j >= 0 && j < 256) { - Chunk chunk = null; - - try { - chunk = this.getChunkAt(i >> 4, k >> 4); - return chunk.getType(i & 15, j, k & 15); - } catch (Throwable throwable) { - CrashReport crashreport = CrashReport.a(throwable, "Exception getting block type in world"); - CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Requested block coordinates"); - - crashreportsystemdetails.a("Found chunk", Boolean.valueOf(chunk == null)); - crashreportsystemdetails.a("Location", CrashReportSystemDetails.a(i, j, k)); - throw new ReportedException(crashreport); - } - } else { - return Blocks.AIR; - } - } - - public boolean isEmpty(int i, int j, int k) { - return this.getType(i, j, k).getMaterial() == Material.AIR; - } - - public boolean isLoaded(int i, int j, int k) { - return j >= 0 && j < 256 ? this.isChunkLoaded(i >> 4, k >> 4) : false; - } - - public boolean areChunksLoaded(int i, int j, int k, int l) { - return this.b(i - l, j - l, k - l, i + l, j + l, k + l); - } - - public boolean b(int i, int j, int k, int l, int i1, int j1) { - if (i1 >= 0 && j < 256) { - i >>= 4; - k >>= 4; - l >>= 4; - j1 >>= 4; - - for (int k1 = i; k1 <= l; ++k1) { - for (int l1 = k; l1 <= j1; ++l1) { - if (!this.isChunkLoaded(k1, l1)) { - return false; - } - } - } - - return true; - } else { - return false; - } - } - - protected boolean isChunkLoaded(int i, int j) { - return this.chunkProvider.isChunkLoaded(i, j); - } - - public Chunk getChunkAtWorldCoords(int i, int j) { - return this.getChunkAt(i >> 4, j >> 4); - } - - public Chunk getChunkAt(int i, int j) { - return this.chunkProvider.getOrCreateChunk(i, j); - } - - public boolean setTypeAndData(int i, int j, int k, Block block, int l, int i1) { - // CraftBukkit start - tree generation - if (this.captureTreeGeneration) { - BlockState blockstate = null; - Iterator<BlockState> it = capturedBlockStates.iterator(); - while (it.hasNext()) { - BlockState previous = it.next(); - if (previous.getX() == i && previous.getY() == j && previous.getZ() == k) { - blockstate = previous; - it.remove(); - break; - } - } - if (blockstate == null) { - blockstate = org.bukkit.craftbukkit.block.CraftBlockState.getBlockState(this, i, j, k, i1); - } - blockstate.setTypeId(CraftMagicNumbers.getId(block)); - blockstate.setRawData((byte) l); - this.capturedBlockStates.add(blockstate); - return true; - } - if (i >= -30000000 && k >= -30000000 && i < 30000000 && k < 30000000) { - if (j < 0) { - return false; - } else if (j >= 256) { - return false; - } else { - Chunk chunk = this.getChunkAt(i >> 4, k >> 4); - Block block1 = null; - - if ((i1 & 1) != 0) { - block1 = chunk.getType(i & 15, j, k & 15); - } - - // CraftBukkit start - capture blockstates - BlockState blockstate = null; - if (this.captureBlockStates) { - blockstate = org.bukkit.craftbukkit.block.CraftBlockState.getBlockState(this, i, j, k, i1); - this.capturedBlockStates.add(blockstate); - } - // CraftBukkit end - - boolean flag = chunk.a(i & 15, j, k & 15, block, l); - - // CraftBukkit start - remove blockstate if failed - if (!flag && this.captureBlockStates) { - this.capturedBlockStates.remove(blockstate); - } - // CraftBukkit end - - this.methodProfiler.a("checkLight"); - this.t(i, j, k); - this.methodProfiler.b(); - // CraftBukkit start - if (flag && !this.captureBlockStates) { // Don't notify clients or update physics while capturing blockstates - // Modularize client and physic updates - this.notifyAndUpdatePhysics(i, j, k, chunk, block1, block, i1); - // CraftBukkit end - } - - return flag; - } - } else { - return false; - } - } - - // CraftBukkit start - Split off from original setTypeAndData(int i, int j, int k, Block block, int l, int i1) method in order to directly send client and physic updates - public void notifyAndUpdatePhysics(int i, int j, int k, Chunk chunk, Block oldBlock, Block newBlock, int flag) - { - // should be isReady() - if ((flag & 2) != 0 && (chunk == null || chunk.isReady())) { // allow chunk to be null here as chunk.isReady() is false when we send our notification during block placement - this.notify(i, j, k); - } - - if ((flag & 1) != 0) { - this.update(i, j, k, oldBlock); - if (newBlock.isComplexRedstone()) { - this.updateAdjacentComparators(i, j, k, newBlock); - } - } - } - // CraftBukkit end - - public int getData(int i, int j, int k) { - // CraftBukkit start - tree generation - if (captureTreeGeneration) { - Iterator<BlockState> it = capturedBlockStates.iterator(); - while (it.hasNext()) { - BlockState previous = it.next(); - if (previous.getX() == i && previous.getY() == j && previous.getZ() == k) { - return previous.getRawData(); - } - } - } - // CraftBukkit end - if (i >= -30000000 && k >= -30000000 && i < 30000000 && k < 30000000) { - if (j < 0) { - return 0; - } else if (j >= 256) { - return 0; - } else { - Chunk chunk = this.getChunkAt(i >> 4, k >> 4); - - i &= 15; - k &= 15; - return chunk.getData(i, j, k); - } - } else { - return 0; - } - } - - public boolean setData(int i, int j, int k, int l, int i1) { - // CraftBukkit start - tree generation - if (this.captureTreeGeneration) { - BlockState blockstate = null; - Iterator<BlockState> it = capturedBlockStates.iterator(); - while (it.hasNext()) { - BlockState previous = it.next(); - if (previous.getX() == i && previous.getY() == j && previous.getZ() == k) { - blockstate = previous; - it.remove(); - break; - } - } - if (blockstate == null) { - blockstate = org.bukkit.craftbukkit.block.CraftBlockState.getBlockState(this, i, j, k, i1); - } - blockstate.setRawData((byte) l); - this.capturedBlockStates.add(blockstate); - return true; - } - // CraftBukkit end - if (i >= -30000000 && k >= -30000000 && i < 30000000 && k < 30000000) { - if (j < 0) { - return false; - } else if (j >= 256) { - return false; - } else { - Chunk chunk = this.getChunkAt(i >> 4, k >> 4); - int j1 = i & 15; - int k1 = k & 15; - boolean flag = chunk.a(j1, j, k1, l); - - if (flag) { - Block block = chunk.getType(j1, j, k1); - - if ((i1 & 2) != 0 && (!this.isStatic || (i1 & 4) == 0) && chunk.isReady()) { - this.notify(i, j, k); - } - - if (!this.isStatic && (i1 & 1) != 0) { - this.update(i, j, k, block); - if (block.isComplexRedstone()) { - this.updateAdjacentComparators(i, j, k, block); - } - } - } - - return flag; - } - } else { - return false; - } - } - - public boolean setAir(int i, int j, int k) { - return this.setTypeAndData(i, j, k, Blocks.AIR, 0, 3); - } - - public boolean setAir(int i, int j, int k, boolean flag) { - Block block = this.getType(i, j, k); - - if (block.getMaterial() == Material.AIR) { - return false; - } else { - int l = this.getData(i, j, k); - - this.triggerEffect(2001, i, j, k, Block.getId(block) + (l << 12)); - if (flag) { - block.b(this, i, j, k, l, 0); - } - - return this.setTypeAndData(i, j, k, Blocks.AIR, 0, 3); - } - } - - public boolean setTypeUpdate(int i, int j, int k, Block block) { - return this.setTypeAndData(i, j, k, block, 0, 3); - } - - public void notify(int i, int j, int k) { - for (int l = 0; l < this.u.size(); ++l) { - ((IWorldAccess) this.u.get(l)).a(i, j, k); - } - } - - public void update(int i, int j, int k, Block block) { - // CraftBukkit start - if (this.populating) { - return; - } - // CraftBukkit end - this.applyPhysics(i, j, k, block); - } - - public void b(int i, int j, int k, int l) { - int i1; - - if (k > l) { - i1 = l; - l = k; - k = i1; - } - - if (!this.worldProvider.g) { - for (i1 = k; i1 <= l; ++i1) { - this.c(EnumSkyBlock.SKY, i, i1, j); - } - } - - this.c(i, k, j, i, l, j); - } - - public void c(int i, int j, int k, int l, int i1, int j1) { - for (int k1 = 0; k1 < this.u.size(); ++k1) { - ((IWorldAccess) this.u.get(k1)).a(i, j, k, l, i1, j1); - } - } - - public void applyPhysics(int i, int j, int k, Block block) { - this.e(i - 1, j, k, block); - this.e(i + 1, j, k, block); - this.e(i, j - 1, k, block); - this.e(i, j + 1, k, block); - this.e(i, j, k - 1, block); - this.e(i, j, k + 1, block); - } - - public void b(int i, int j, int k, Block block, int l) { - if (l != 4) { - this.e(i - 1, j, k, block); - } - - if (l != 5) { - this.e(i + 1, j, k, block); - } - - if (l != 0) { - this.e(i, j - 1, k, block); - } - - if (l != 1) { - this.e(i, j + 1, k, block); - } - - if (l != 2) { - this.e(i, j, k - 1, block); - } - - if (l != 3) { - this.e(i, j, k + 1, block); - } - } - - public void e(int i, int j, int k, Block block) { - if (!this.isStatic) { - Block block1 = this.getType(i, j, k); - - try { - // CraftBukkit start - CraftWorld world = ((WorldServer) this).getWorld(); - if (world != null) { - BlockPhysicsEvent event = new BlockPhysicsEvent(world.getBlockAt(i, j, k), CraftMagicNumbers.getId(block)); - this.getServer().getPluginManager().callEvent(event); - - if (event.isCancelled()) { - return; - } - } - // CraftBukkit end - - block1.doPhysics(this, i, j, k, block); - } catch (Throwable throwable) { - CrashReport crashreport = CrashReport.a(throwable, "Exception while updating neighbours"); - CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Block being updated"); - - int l; - - try { - l = this.getData(i, j, k); - } catch (Throwable throwable1) { - l = -1; - } - - crashreportsystemdetails.a("Source block type", (Callable) (new CrashReportSourceBlockType(this, block))); - CrashReportSystemDetails.a(crashreportsystemdetails, i, j, k, block1, l); - throw new ReportedException(crashreport); - } - } - } - - public boolean a(int i, int j, int k, Block block) { - return false; - } - - public boolean i(int i, int j, int k) { - return this.getChunkAt(i >> 4, k >> 4).d(i & 15, j, k & 15); - } - - public int j(int i, int j, int k) { - if (j < 0) { - return 0; - } else { - if (j >= 256) { - j = 255; - } - - return this.getChunkAt(i >> 4, k >> 4).b(i & 15, j, k & 15, 0); - } - } - - public int getLightLevel(int i, int j, int k) { - return this.b(i, j, k, true); - } - - public int b(int i, int j, int k, boolean flag) { - if (i >= -30000000 && k >= -30000000 && i < 30000000 && k < 30000000) { - if (flag && this.getType(i, j, k).n()) { - int l = this.b(i, j + 1, k, false); - int i1 = this.b(i + 1, j, k, false); - int j1 = this.b(i - 1, j, k, false); - int k1 = this.b(i, j, k + 1, false); - int l1 = this.b(i, j, k - 1, false); - - if (i1 > l) { - l = i1; - } - - if (j1 > l) { - l = j1; - } - - if (k1 > l) { - l = k1; - } - - if (l1 > l) { - l = l1; - } - - return l; - } else if (j < 0) { - return 0; - } else { - if (j >= 256) { - j = 255; - } - - Chunk chunk = this.getChunkAt(i >> 4, k >> 4); - - i &= 15; - k &= 15; - return chunk.b(i, j, k, this.j); - } - } else { - return 15; - } - } - - public int getHighestBlockYAt(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.b(i & 15, j & 15); - } - } else { - return 64; - } - } - - 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.r; - } - } else { - return 64; - } - } - - public int b(EnumSkyBlock enumskyblock, int i, int j, int k) { - if (j < 0) { - j = 0; - } - - if (j >= 256) { - j = 255; - } - - if (i >= -30000000 && k >= -30000000 && i < 30000000 && k < 30000000) { - int l = i >> 4; - int i1 = k >> 4; - - if (!this.isChunkLoaded(l, i1)) { - return enumskyblock.c; - } else { - Chunk chunk = this.getChunkAt(l, i1); - - return chunk.getBrightness(enumskyblock, i & 15, j, k & 15); - } - } else { - return enumskyblock.c; - } - } - - public void b(EnumSkyBlock enumskyblock, int i, int j, int k, int l) { - if (i >= -30000000 && k >= -30000000 && i < 30000000 && k < 30000000) { - if (j >= 0) { - if (j < 256) { - if (this.isChunkLoaded(i >> 4, k >> 4)) { - Chunk chunk = this.getChunkAt(i >> 4, k >> 4); - - chunk.a(enumskyblock, i & 15, j, k & 15, l); - - for (int i1 = 0; i1 < this.u.size(); ++i1) { - ((IWorldAccess) this.u.get(i1)).b(i, j, k); - } - } - } - } - } - } - - public void m(int i, int j, int k) { - for (int l = 0; l < this.u.size(); ++l) { - ((IWorldAccess) this.u.get(l)).b(i, j, k); - } - } - - public float n(int i, int j, int k) { - return this.worldProvider.h[this.getLightLevel(i, j, k)]; - } - - public boolean w() { - return this.j < 4; - } - - public MovingObjectPosition a(Vec3D vec3d, Vec3D vec3d1) { - return this.rayTrace(vec3d, vec3d1, false, false, false); - } - - public MovingObjectPosition rayTrace(Vec3D vec3d, Vec3D vec3d1, boolean flag) { - return this.rayTrace(vec3d, vec3d1, flag, false, false); - } - - public MovingObjectPosition rayTrace(Vec3D vec3d, Vec3D vec3d1, boolean flag, boolean flag1, boolean flag2) { - 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); - Block block = this.getType(l, i1, j1); - int k1 = this.getData(l, i1, j1); - - if ((!flag1 || block.a(this, l, i1, j1) != null) && block.a(k1, flag)) { - MovingObjectPosition movingobjectposition = block.a(this, l, i1, j1, vec3d, vec3d1); - - if (movingobjectposition != null) { - return movingobjectposition; - } - } - - MovingObjectPosition movingobjectposition1 = null; - - k1 = 200; - - while (k1-- >= 0) { - if (Double.isNaN(vec3d.a) || Double.isNaN(vec3d.b) || Double.isNaN(vec3d.c)) { - return null; - } - - if (l == i && i1 == j && j1 == k) { - return flag2 ? movingobjectposition1 : null; - } - - boolean flag3 = true; - boolean flag4 = true; - boolean flag5 = true; - double d0 = 999.0D; - double d1 = 999.0D; - double d2 = 999.0D; - - if (i > l) { - d0 = (double) l + 1.0D; - } else if (i < l) { - d0 = (double) l + 0.0D; - } else { - flag3 = false; - } - - if (j > i1) { - d1 = (double) i1 + 1.0D; - } else if (j < i1) { - d1 = (double) i1 + 0.0D; - } else { - flag4 = false; - } - - if (k > j1) { - d2 = (double) j1 + 1.0D; - } else if (k < j1) { - d2 = (double) j1 + 0.0D; - } else { - flag5 = false; - } - - 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; - - if (flag3) { - d3 = (d0 - vec3d.a) / d6; - } - - if (flag4) { - d4 = (d1 - vec3d.b) / d7; - } - - if (flag5) { - d5 = (d2 - vec3d.c) / d8; - } - - boolean flag6 = false; - byte b0; - - if (d3 < d4 && d3 < d5) { - if (i > l) { - b0 = 4; - } else { - b0 = 5; - } - - vec3d.a = d0; - vec3d.b += d7 * d3; - vec3d.c += d8 * d3; - } else if (d4 < d5) { - if (j > i1) { - b0 = 0; - } else { - b0 = 1; - } - - vec3d.a += d6 * d4; - vec3d.b = d1; - vec3d.c += d8 * d4; - } else { - if (k > j1) { - b0 = 2; - } else { - b0 = 3; - } - - vec3d.a += d6 * d5; - vec3d.b += d7 * d5; - vec3d.c = d2; - } - - Vec3D vec3d2 = Vec3D.a(vec3d.a, vec3d.b, vec3d.c); - - l = (int) (vec3d2.a = (double) MathHelper.floor(vec3d.a)); - if (b0 == 5) { - --l; - ++vec3d2.a; - } - - i1 = (int) (vec3d2.b = (double) MathHelper.floor(vec3d.b)); - if (b0 == 1) { - --i1; - ++vec3d2.b; - } - - j1 = (int) (vec3d2.c = (double) MathHelper.floor(vec3d.c)); - if (b0 == 3) { - --j1; - ++vec3d2.c; - } - - Block block1 = this.getType(l, i1, j1); - int l1 = this.getData(l, i1, j1); - - if (!flag1 || block1.a(this, l, i1, j1) != null) { - if (block1.a(l1, flag)) { - MovingObjectPosition movingobjectposition2 = block1.a(this, l, i1, j1, vec3d, vec3d1); - - if (movingobjectposition2 != null) { - return movingobjectposition2; - } - } else { - movingobjectposition1 = new MovingObjectPosition(l, i1, j1, b0, vec3d, false); - } - } - } - - return flag2 ? movingobjectposition1 : null; - } else { - return null; - } - } else { - return null; - } - } - - public void makeSound(Entity entity, String s, float f, float f1) { - for (int i = 0; i < this.u.size(); ++i) { - ((IWorldAccess) this.u.get(i)).a(s, entity.locX, entity.locY - (double) entity.height, entity.locZ, f, f1); - } - } - - public void a(EntityHuman entityhuman, String s, float f, float f1) { - for (int i = 0; i < this.u.size(); ++i) { - ((IWorldAccess) this.u.get(i)).a(entityhuman, s, entityhuman.locX, entityhuman.locY - (double) entityhuman.height, entityhuman.locZ, f, f1); - } - } - - public void makeSound(double d0, double d1, double d2, String s, float f, float f1) { - for (int i = 0; i < this.u.size(); ++i) { - ((IWorldAccess) this.u.get(i)).a(s, d0, d1, d2, f, f1); - } - } - - public void a(double d0, double d1, double d2, String s, float f, float f1, boolean flag) {} - - public void a(String s, int i, int j, int k) { - for (int l = 0; l < this.u.size(); ++l) { - ((IWorldAccess) this.u.get(l)).a(s, i, j, k); - } - } - - public void addParticle(String s, double d0, double d1, double d2, double d3, double d4, double d5) { - for (int i = 0; i < this.u.size(); ++i) { - ((IWorldAccess) this.u.get(i)).a(s, d0, d1, d2, d3, d4, d5); - } - } - - public boolean strikeLightning(Entity entity) { - this.i.add(entity); - return true; - } - - public boolean addEntity(Entity entity) { - // CraftBukkit start - Used for entities other than creatures - return this.addEntity(entity, SpawnReason.DEFAULT); // Set reason as DEFAULT - } - - public boolean addEntity(Entity entity, SpawnReason spawnReason) { // Changed signature, added SpawnReason - if (entity == null) return false; - // CraftBukkit end - - int i = MathHelper.floor(entity.locX / 16.0D); - int j = MathHelper.floor(entity.locZ / 16.0D); - boolean flag = entity.attachedToPlayer; - - if (entity instanceof EntityHuman) { - flag = true; - } - - // CraftBukkit start - org.bukkit.event.Cancellable event = null; - if (entity instanceof EntityLiving && !(entity instanceof EntityPlayer)) { - boolean isAnimal = entity instanceof EntityAnimal || entity instanceof EntityWaterAnimal || entity instanceof EntityGolem; - boolean isMonster = entity instanceof EntityMonster || entity instanceof EntityGhast || entity instanceof EntitySlime; - - if (spawnReason != SpawnReason.CUSTOM) { - if (isAnimal && !allowAnimals || isMonster && !allowMonsters) { - entity.dead = true; - return false; - } - } - - event = CraftEventFactory.callCreatureSpawnEvent((EntityLiving) entity, spawnReason); - } else if (entity instanceof EntityItem) { - event = CraftEventFactory.callItemSpawnEvent((EntityItem) entity); - } else if (entity.getBukkitEntity() instanceof org.bukkit.entity.Projectile) { - // Not all projectiles extend EntityProjectile, so check for Bukkit interface instead - event = CraftEventFactory.callProjectileLaunchEvent(entity); - } - - if (event != null && (event.isCancelled() || entity.dead)) { - entity.dead = true; - return false; - } - // CraftBukkit end - - if (!flag && !this.isChunkLoaded(i, j)) { - entity.dead = true; // CraftBukkit - return false; - } else { - if (entity instanceof EntityHuman) { - EntityHuman entityhuman = (EntityHuman) entity; - - this.players.add(entityhuman); - this.everyoneSleeping(); - this.b(entity); - } - - this.getChunkAt(i, j).a(entity); - this.entityList.add(entity); - this.a(entity); - return true; - } - } - - protected void a(Entity entity) { - for (int i = 0; i < this.u.size(); ++i) { - ((IWorldAccess) this.u.get(i)).a(entity); - } - - entity.valid = true; // CraftBukkit - } - - protected void b(Entity entity) { - for (int i = 0; i < this.u.size(); ++i) { - ((IWorldAccess) this.u.get(i)).b(entity); - } - - entity.valid = false; // CraftBukkit - } - - public void kill(Entity entity) { - if (entity.passenger != null) { - entity.passenger.mount((Entity) null); - } - - if (entity.vehicle != null) { - entity.mount((Entity) null); - } - - entity.die(); - if (entity instanceof EntityHuman) { - this.players.remove(entity); - this.everyoneSleeping(); - } - } - - public void removeEntity(Entity entity) { - entity.die(); - if (entity instanceof EntityHuman) { - this.players.remove(entity); - this.everyoneSleeping(); - } - - int i = entity.ah; - int j = entity.aj; - - if (entity.ag && this.isChunkLoaded(i, j)) { - this.getChunkAt(i, j).b(entity); - } - - // CraftBukkit start - Decrement loop variable field if we've already ticked this entity - int index = this.entityList.indexOf(entity); - if (index != -1) { - if (index <= this.tickPosition) { - this.tickPosition--; - } - this.entityList.remove(index); - } - // CraftBukkit end - - this.b(entity); - } - - public void addIWorldAccess(IWorldAccess iworldaccess) { - this.u.add(iworldaccess); - } - - public List getCubes(Entity entity, AxisAlignedBB axisalignedbb) { - this.L.clear(); - int i = MathHelper.floor(axisalignedbb.a); - int j = MathHelper.floor(axisalignedbb.d + 1.0D); - int k = MathHelper.floor(axisalignedbb.b); - int l = MathHelper.floor(axisalignedbb.e + 1.0D); - int i1 = MathHelper.floor(axisalignedbb.c); - int j1 = MathHelper.floor(axisalignedbb.f + 1.0D); - - for (int k1 = i; k1 < j; ++k1) { - for (int l1 = i1; l1 < j1; ++l1) { - if (this.isLoaded(k1, 64, l1)) { - for (int i2 = k - 1; i2 < l; ++i2) { - Block block; - - if (k1 >= -30000000 && k1 < 30000000 && l1 >= -30000000 && l1 < 30000000) { - block = this.getType(k1, i2, l1); - } else { - block = Blocks.STONE; - } - - block.a(this, k1, i2, l1, axisalignedbb, this.L, entity); - } - } - } - } - - double d0 = 0.25D; - List list = this.getEntities(entity, axisalignedbb.grow(d0, d0, d0)); - - for (int j2 = 0; j2 < list.size(); ++j2) { - AxisAlignedBB axisalignedbb1 = ((Entity) list.get(j2)).J(); - - if (axisalignedbb1 != null && axisalignedbb1.b(axisalignedbb)) { - this.L.add(axisalignedbb1); - } - - axisalignedbb1 = entity.h((Entity) list.get(j2)); - if (axisalignedbb1 != null && axisalignedbb1.b(axisalignedbb)) { - this.L.add(axisalignedbb1); - } - } - - return this.L; - } - - public List a(AxisAlignedBB axisalignedbb) { - this.L.clear(); - int i = MathHelper.floor(axisalignedbb.a); - int j = MathHelper.floor(axisalignedbb.d + 1.0D); - int k = MathHelper.floor(axisalignedbb.b); - int l = MathHelper.floor(axisalignedbb.e + 1.0D); - int i1 = MathHelper.floor(axisalignedbb.c); - int j1 = MathHelper.floor(axisalignedbb.f + 1.0D); - - for (int k1 = i; k1 < j; ++k1) { - for (int l1 = i1; l1 < j1; ++l1) { - if (this.isLoaded(k1, 64, l1)) { - for (int i2 = k - 1; i2 < l; ++i2) { - Block block; - - if (k1 >= -30000000 && k1 < 30000000 && l1 >= -30000000 && l1 < 30000000) { - block = this.getType(k1, i2, l1); - } else { - block = Blocks.BEDROCK; - } - - block.a(this, k1, i2, l1, axisalignedbb, this.L, (Entity) null); - } - } - } - } - - return this.L; - } - - public int a(float f) { - float f1 = this.c(f); - float f2 = 1.0F - (MathHelper.cos(f1 * 3.1415927F * 2.0F) * 2.0F + 0.5F); - - if (f2 < 0.0F) { - f2 = 0.0F; - } - - if (f2 > 1.0F) { - f2 = 1.0F; - } - - f2 = 1.0F - f2; - f2 = (float) ((double) f2 * (1.0D - (double) (this.j(f) * 5.0F) / 16.0D)); - f2 = (float) ((double) f2 * (1.0D - (double) (this.h(f) * 5.0F) / 16.0D)); - f2 = 1.0F - f2; - return (int) (f2 * 11.0F); - } - - public float c(float f) { - return this.worldProvider.a(this.worldData.getDayTime(), f); - } - - public float y() { - return WorldProvider.a[this.worldProvider.a(this.worldData.getDayTime())]; - } - - public float d(float f) { - float f1 = this.c(f); - - return f1 * 3.1415927F * 2.0F; - } - - public int h(int i, int j) { - return this.getChunkAtWorldCoords(i, j).d(i & 15, j & 15); - } - - public int i(int i, int j) { - Chunk chunk = this.getChunkAtWorldCoords(i, j); - int k = chunk.h() + 15; - - i &= 15; - - for (j &= 15; k > 0; --k) { - Block block = chunk.getType(i, k, j); - - if (block.getMaterial().isSolid() && block.getMaterial() != Material.LEAVES) { - return k + 1; - } - } - - return -1; - } - - public void a(int i, int j, int k, Block block, int l) {} - - public void a(int i, int j, int k, Block block, int l, int i1) {} - - public void b(int i, int j, int k, Block block, int l, int i1) {} - - public void tickEntities() { - this.methodProfiler.a("entities"); - this.methodProfiler.a("global"); - - int i; - Entity entity; - CrashReport crashreport; - CrashReportSystemDetails crashreportsystemdetails; - - for (i = 0; i < this.i.size(); ++i) { - entity = (Entity) this.i.get(i); - // CraftBukkit start - Fixed an NPE - if (entity == null) { - continue; - } - // CraftBukkit end - - try { - ++entity.ticksLived; - entity.h(); - } catch (Throwable throwable) { - crashreport = CrashReport.a(throwable, "Ticking entity"); - crashreportsystemdetails = crashreport.a("Entity being ticked"); - if (entity == null) { - crashreportsystemdetails.a("Entity", "~~NULL~~"); - } else { - entity.a(crashreportsystemdetails); - } - - throw new ReportedException(crashreport); - } - - if (entity.dead) { - this.i.remove(i--); - } - } - - this.methodProfiler.c("remove"); - this.entityList.removeAll(this.f); - - int j; - int k; - - for (i = 0; i < this.f.size(); ++i) { - entity = (Entity) this.f.get(i); - j = entity.ah; - k = entity.aj; - if (entity.ag && this.isChunkLoaded(j, k)) { - this.getChunkAt(j, k).b(entity); - } - } - - for (i = 0; i < this.f.size(); ++i) { - this.b((Entity) this.f.get(i)); - } - - this.f.clear(); - this.methodProfiler.c("regular"); - - // CraftBukkit start - Use field for loop variable - for (this.tickPosition = 0; this.tickPosition < this.entityList.size(); ++this.tickPosition) { - entity = (Entity) this.entityList.get(this.tickPosition); - if (entity.vehicle != null) { - if (!entity.vehicle.dead && entity.vehicle.passenger == entity) { - continue; - } - - entity.vehicle.passenger = null; - entity.vehicle = null; - } - - this.methodProfiler.a("tick"); - if (!entity.dead) { - try { - this.playerJoinedWorld(entity); - } catch (Throwable throwable1) { - crashreport = CrashReport.a(throwable1, "Ticking entity"); - crashreportsystemdetails = crashreport.a("Entity being ticked"); - entity.a(crashreportsystemdetails); - throw new ReportedException(crashreport); - } - } - - this.methodProfiler.b(); - this.methodProfiler.a("remove"); - if (entity.dead) { - j = entity.ah; - k = entity.aj; - if (entity.ag && this.isChunkLoaded(j, k)) { - this.getChunkAt(j, k).b(entity); - } - - this.entityList.remove(this.tickPosition--); // CraftBukkit - Use field for loop variable - this.b(entity); - } - - this.methodProfiler.b(); - } - - this.methodProfiler.c("blockEntities"); - this.M = true; - // CraftBukkit start - From below, clean up tile entities before ticking them - if (!this.b.isEmpty()) { - this.tileEntityList.removeAll(this.b); - this.b.clear(); - } - // CraftBukkit end - - Iterator iterator = this.tileEntityList.iterator(); - - while (iterator.hasNext()) { - TileEntity tileentity = (TileEntity) iterator.next(); - - if (!tileentity.r() && tileentity.o() && this.isLoaded(tileentity.x, tileentity.y, tileentity.z)) { - try { - tileentity.h(); - } catch (Throwable throwable2) { - crashreport = CrashReport.a(throwable2, "Ticking block entity"); - crashreportsystemdetails = crashreport.a("Block entity being ticked"); - tileentity.a(crashreportsystemdetails); - throw new ReportedException(crashreport); - } - } - - if (tileentity.r()) { - iterator.remove(); - if (this.isChunkLoaded(tileentity.x >> 4, tileentity.z >> 4)) { - Chunk chunk = this.getChunkAt(tileentity.x >> 4, tileentity.z >> 4); - - if (chunk != null) { - chunk.f(tileentity.x & 15, tileentity.y, tileentity.z & 15); - } - } - } - } - - this.M = false; - /* CraftBukkit start - Moved up - if (!this.b.isEmpty()) { - this.tileEntityList.removeAll(this.b); - this.b.clear(); - } - */ // CraftBukkit end - - this.methodProfiler.c("pendingBlockEntities"); - if (!this.a.isEmpty()) { - for (int l = 0; l < this.a.size(); ++l) { - TileEntity tileentity1 = (TileEntity) this.a.get(l); - - if (!tileentity1.r()) { - /* CraftBukkit start - Order matters, moved down - if (!this.tileEntityList.contains(tileentity1)) { - this.tileEntityList.add(tileentity1); - } - // CraftBukkit end */ - - if (this.isChunkLoaded(tileentity1.x >> 4, tileentity1.z >> 4)) { - Chunk chunk1 = this.getChunkAt(tileentity1.x >> 4, tileentity1.z >> 4); - - if (chunk1 != null) { - chunk1.a(tileentity1.x & 15, tileentity1.y, tileentity1.z & 15, tileentity1); - // CraftBukkit start - Moved down from above - if (!this.tileEntityList.contains(tileentity1)) { - this.tileEntityList.add(tileentity1); - } - // CraftBukkit end - } - } - - this.notify(tileentity1.x, tileentity1.y, tileentity1.z); - } - } - - this.a.clear(); - } - - this.methodProfiler.b(); - this.methodProfiler.b(); - } - - public void a(Collection collection) { - if (this.M) { - this.a.addAll(collection); - } else { - this.tileEntityList.addAll(collection); - } - } - - public void playerJoinedWorld(Entity entity) { - this.entityJoinedWorld(entity, true); - } - - public void entityJoinedWorld(Entity entity, boolean flag) { - int i = MathHelper.floor(entity.locX); - int j = MathHelper.floor(entity.locZ); - byte b0 = 32; - - // CraftBukkit start - Use neighbor cache instead of looking up - Chunk startingChunk = this.getChunkIfLoaded(i >> 4, j >> 4); - if (!flag || (startingChunk != null && startingChunk.areNeighborsLoaded(2)) /* this.b(i - b0, 0, j - b0, i + b0, 0, j + b0) */) { - // CraftBukkit end - entity.S = entity.locX; - entity.T = entity.locY; - entity.U = entity.locZ; - entity.lastYaw = entity.yaw; - entity.lastPitch = entity.pitch; - if (flag && entity.ag) { - ++entity.ticksLived; - if (entity.vehicle != null) { - entity.ab(); - } else { - entity.h(); - } - } - - this.methodProfiler.a("chunkCheck"); - if (Double.isNaN(entity.locX) || Double.isInfinite(entity.locX)) { - entity.locX = entity.S; - } - - if (Double.isNaN(entity.locY) || Double.isInfinite(entity.locY)) { - entity.locY = entity.T; - } - - if (Double.isNaN(entity.locZ) || Double.isInfinite(entity.locZ)) { - entity.locZ = entity.U; - } - - if (Double.isNaN((double) entity.pitch) || Double.isInfinite((double) entity.pitch)) { - entity.pitch = entity.lastPitch; - } - - if (Double.isNaN((double) entity.yaw) || Double.isInfinite((double) entity.yaw)) { - entity.yaw = entity.lastYaw; - } - - int k = MathHelper.floor(entity.locX / 16.0D); - 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 (this.isChunkLoaded(k, i1)) { - entity.ag = true; - this.getChunkAt(k, i1).a(entity); - } else { - entity.ag = false; - } - } - - this.methodProfiler.b(); - if (flag && entity.ag && entity.passenger != null) { - if (!entity.passenger.dead && entity.passenger.vehicle == entity) { - this.playerJoinedWorld(entity.passenger); - } else { - entity.passenger.vehicle = null; - entity.passenger = null; - } - } - } - } - - public boolean b(AxisAlignedBB axisalignedbb) { - return this.a(axisalignedbb, (Entity) null); - } - - public boolean a(AxisAlignedBB axisalignedbb, Entity entity) { - List list = this.getEntities((Entity) null, axisalignedbb); - - for (int i = 0; i < list.size(); ++i) { - Entity entity1 = (Entity) list.get(i); - - if (!entity1.dead && entity1.k && entity1 != entity) { - return false; - } - } - - return true; - } - - public boolean c(AxisAlignedBB axisalignedbb) { - int i = MathHelper.floor(axisalignedbb.a); - int j = MathHelper.floor(axisalignedbb.d + 1.0D); - int k = MathHelper.floor(axisalignedbb.b); - int l = MathHelper.floor(axisalignedbb.e + 1.0D); - int i1 = MathHelper.floor(axisalignedbb.c); - int j1 = MathHelper.floor(axisalignedbb.f + 1.0D); - - if (axisalignedbb.a < 0.0D) { - --i; - } - - if (axisalignedbb.b < 0.0D) { - --k; - } - - if (axisalignedbb.c < 0.0D) { - --i1; - } - - for (int k1 = i; k1 < j; ++k1) { - for (int l1 = k; l1 < l; ++l1) { - for (int i2 = i1; i2 < j1; ++i2) { - Block block = this.getType(k1, l1, i2); - - if (block.getMaterial() != Material.AIR) { - return true; - } - } - } - } - - return false; - } - - public boolean containsLiquid(AxisAlignedBB axisalignedbb) { - int i = MathHelper.floor(axisalignedbb.a); - int j = MathHelper.floor(axisalignedbb.d + 1.0D); - int k = MathHelper.floor(axisalignedbb.b); - int l = MathHelper.floor(axisalignedbb.e + 1.0D); - int i1 = MathHelper.floor(axisalignedbb.c); - int j1 = MathHelper.floor(axisalignedbb.f + 1.0D); - - if (axisalignedbb.a < 0.0D) { - --i; - } - - if (axisalignedbb.b < 0.0D) { - --k; - } - - if (axisalignedbb.c < 0.0D) { - --i1; - } - - for (int k1 = i; k1 < j; ++k1) { - for (int l1 = k; l1 < l; ++l1) { - for (int i2 = i1; i2 < j1; ++i2) { - Block block = this.getType(k1, l1, i2); - - if (block.getMaterial().isLiquid()) { - return true; - } - } - } - } - - return false; - } - - public boolean e(AxisAlignedBB axisalignedbb) { - int i = MathHelper.floor(axisalignedbb.a); - int j = MathHelper.floor(axisalignedbb.d + 1.0D); - int k = MathHelper.floor(axisalignedbb.b); - int l = MathHelper.floor(axisalignedbb.e + 1.0D); - int i1 = MathHelper.floor(axisalignedbb.c); - int j1 = MathHelper.floor(axisalignedbb.f + 1.0D); - - if (this.b(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) { - Block block = this.getType(k1, l1, i2); - - if (block == Blocks.FIRE || block == Blocks.LAVA || block == Blocks.STATIONARY_LAVA) { - return true; - } - } - } - } - } - - return false; - } - - public boolean a(AxisAlignedBB axisalignedbb, Material material, Entity entity) { - int i = MathHelper.floor(axisalignedbb.a); - int j = MathHelper.floor(axisalignedbb.d + 1.0D); - int k = MathHelper.floor(axisalignedbb.b); - int l = MathHelper.floor(axisalignedbb.e + 1.0D); - int i1 = MathHelper.floor(axisalignedbb.c); - int j1 = MathHelper.floor(axisalignedbb.f + 1.0D); - - if (!this.b(i, k, i1, j, l, j1)) { - return false; - } else { - boolean flag = false; - Vec3D vec3d = Vec3D.a(0.0D, 0.0D, 0.0D); - - for (int k1 = i; k1 < j; ++k1) { - for (int l1 = k; l1 < l; ++l1) { - for (int i2 = i1; i2 < j1; ++i2) { - Block block = this.getType(k1, l1, i2); - - if (block.getMaterial() == material) { - double d0 = (double) ((float) (l1 + 1) - BlockFluids.b(this.getData(k1, l1, i2))); - - if ((double) l >= d0) { - flag = true; - block.a(this, k1, l1, i2, entity, vec3d); - } - } - } - } - } - - if (vec3d.b() > 0.0D && entity.aC()) { - vec3d = vec3d.a(); - double d1 = 0.014D; - - entity.motX += vec3d.a * d1; - entity.motY += vec3d.b * d1; - entity.motZ += vec3d.c * d1; - } - - return flag; - } - } - - public boolean a(AxisAlignedBB axisalignedbb, Material material) { - int i = MathHelper.floor(axisalignedbb.a); - int j = MathHelper.floor(axisalignedbb.d + 1.0D); - int k = MathHelper.floor(axisalignedbb.b); - int l = MathHelper.floor(axisalignedbb.e + 1.0D); - int i1 = MathHelper.floor(axisalignedbb.c); - int j1 = MathHelper.floor(axisalignedbb.f + 1.0D); - - for (int k1 = i; k1 < j; ++k1) { - for (int l1 = k; l1 < l; ++l1) { - for (int i2 = i1; i2 < j1; ++i2) { - if (this.getType(k1, l1, i2).getMaterial() == material) { - return true; - } - } - } - } - - return false; - } - - public boolean b(AxisAlignedBB axisalignedbb, Material material) { - int i = MathHelper.floor(axisalignedbb.a); - int j = MathHelper.floor(axisalignedbb.d + 1.0D); - int k = MathHelper.floor(axisalignedbb.b); - int l = MathHelper.floor(axisalignedbb.e + 1.0D); - int i1 = MathHelper.floor(axisalignedbb.c); - int j1 = MathHelper.floor(axisalignedbb.f + 1.0D); - - for (int k1 = i; k1 < j; ++k1) { - for (int l1 = k; l1 < l; ++l1) { - for (int i2 = i1; i2 < j1; ++i2) { - Block block = this.getType(k1, l1, i2); - - if (block.getMaterial() == material) { - int j2 = this.getData(k1, l1, i2); - double d0 = (double) (l1 + 1); - - if (j2 < 8) { - d0 = (double) (l1 + 1) - (double) j2 / 8.0D; - } - - if (d0 >= axisalignedbb.b) { - return true; - } - } - } - } - } - - return 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, 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; - } - - public float a(Vec3D vec3d, AxisAlignedBB axisalignedbb) { - double d0 = 1.0D / ((axisalignedbb.d - axisalignedbb.a) * 2.0D + 1.0D); - double d1 = 1.0D / ((axisalignedbb.e - axisalignedbb.b) * 2.0D + 1.0D); - double d2 = 1.0D / ((axisalignedbb.f - axisalignedbb.c) * 2.0D + 1.0D); - - if (d0 >= 0.0D && d1 >= 0.0D && d2 >= 0.0D) { - int i = 0; - int j = 0; - - Vec3D vec3d2 = vec3d.a(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)) { - double d3 = axisalignedbb.a + (axisalignedbb.d - axisalignedbb.a) * (double) f; - double d4 = axisalignedbb.b + (axisalignedbb.e - axisalignedbb.b) * (double) f1; - double d5 = axisalignedbb.c + (axisalignedbb.f - axisalignedbb.c) * (double) f2; - - if (this.a(vec3d2.b(d3, d4, d5), vec3d) == null) { // CraftBukkit - ++i; - } - - ++j; - } - } - } - - return (float) i / (float) j; - } else { - return 0.0F; - } - } - - public boolean douseFire(EntityHuman entityhuman, int i, int j, int k, int l) { - if (l == 0) { - --j; - } - - if (l == 1) { - ++j; - } - - if (l == 2) { - --k; - } - - if (l == 3) { - ++k; - } - - if (l == 4) { - --i; - } - - if (l == 5) { - ++i; - } - - if (this.getType(i, j, k) == Blocks.FIRE) { - this.a(entityhuman, 1004, i, j, k, 0); - this.setAir(i, j, k); - return true; - } else { - return false; - } - } - - public TileEntity getTileEntity(int i, int j, int k) { - if (j >= 0 && j < 256) { - TileEntity tileentity = null; - int l; - TileEntity tileentity1; - - if (this.M) { - for (l = 0; l < this.a.size(); ++l) { - tileentity1 = (TileEntity) this.a.get(l); - if (!tileentity1.r() && tileentity1.x == i && tileentity1.y == j && tileentity1.z == k) { - tileentity = tileentity1; - break; - } - } - } - - if (tileentity == null) { - Chunk chunk = this.getChunkAt(i >> 4, k >> 4); - - if (chunk != null) { - tileentity = chunk.e(i & 15, j, k & 15); - } - } - - if (tileentity == null) { - for (l = 0; l < this.a.size(); ++l) { - tileentity1 = (TileEntity) this.a.get(l); - if (!tileentity1.r() && tileentity1.x == i && tileentity1.y == j && tileentity1.z == k) { - tileentity = tileentity1; - break; - } - } - } - - return tileentity; - } else { - return null; - } - } - - public void setTileEntity(int i, int j, int k, TileEntity tileentity) { - if (tileentity != null && !tileentity.r()) { - if (this.M) { - tileentity.x = i; - tileentity.y = j; - tileentity.z = k; - Iterator iterator = this.a.iterator(); - - while (iterator.hasNext()) { - TileEntity tileentity1 = (TileEntity) iterator.next(); - - if (tileentity1.x == i && tileentity1.y == j && tileentity1.z == k) { - tileentity1.s(); - iterator.remove(); - } - } - - this.a.add(tileentity); - } else { - this.tileEntityList.add(tileentity); - Chunk chunk = this.getChunkAt(i >> 4, k >> 4); - - if (chunk != null) { - chunk.a(i & 15, j, k & 15, tileentity); - } - } - } - } - - public void p(int i, int j, int k) { - TileEntity tileentity = this.getTileEntity(i, j, k); - - if (tileentity != null && this.M) { - tileentity.s(); - this.a.remove(tileentity); - } else { - if (tileentity != null) { - this.a.remove(tileentity); - this.tileEntityList.remove(tileentity); - } - - Chunk chunk = this.getChunkAt(i >> 4, k >> 4); - - if (chunk != null) { - chunk.f(i & 15, j, k & 15); - } - } - } - - public void a(TileEntity tileentity) { - this.b.add(tileentity); - } - - public boolean q(int i, int j, int k) { - AxisAlignedBB axisalignedbb = this.getType(i, j, k).a(this, i, j, k); - - return axisalignedbb != null && axisalignedbb.a() >= 1.0D; - } - - public static boolean a(IBlockAccess iblockaccess, int i, int j, int k) { - Block block = iblockaccess.getType(i, j, k); - int l = iblockaccess.getData(i, j, k); - - return block.getMaterial().k() && block.d() ? true : (block instanceof BlockStairs ? (l & 4) == 4 : (block instanceof BlockStepAbstract ? (l & 8) == 8 : (block instanceof BlockHopper ? true : (block instanceof BlockSnow ? (l & 7) == 7 : false)))); - } - - public boolean c(int i, int j, int k, boolean flag) { - if (i >= -30000000 && k >= -30000000 && i < 30000000 && k < 30000000) { - Chunk chunk = this.chunkProvider.getOrCreateChunk(i >> 4, k >> 4); - - if (chunk != null && !chunk.isEmpty()) { - Block block = this.getType(i, j, k); - - return block.getMaterial().k() && block.d(); - } else { - return flag; - } - } else { - return flag; - } - } - - public void B() { - int i = this.a(1.0F); - - if (i != this.j) { - this.j = i; - } - } - - public void setSpawnFlags(boolean flag, boolean flag1) { - this.allowMonsters = flag; - this.allowAnimals = flag1; - } - - public void doTick() { - this.o(); - } - - private void a() { - if (this.worldData.hasStorm()) { - this.n = 1.0F; - if (this.worldData.isThundering()) { - this.p = 1.0F; - } - } - } - - protected void o() { - if (!this.worldProvider.g) { - if (!this.isStatic) { - int i = this.worldData.getThunderDuration(); - - if (i <= 0) { - if (this.worldData.isThundering()) { - this.worldData.setThunderDuration(this.random.nextInt(12000) + 3600); - } else { - this.worldData.setThunderDuration(this.random.nextInt(168000) + 12000); - } - } else { - --i; - this.worldData.setThunderDuration(i); - if (i <= 0) { - // CraftBukkit start - ThunderChangeEvent thunder = new ThunderChangeEvent(this.getWorld(), !this.worldData.isThundering()); - this.getServer().getPluginManager().callEvent(thunder); - if (!thunder.isCancelled()) { - this.worldData.setThundering(!this.worldData.isThundering()); - } - // CraftBukkit end - } - } - - this.o = this.p; - if (this.worldData.isThundering()) { - this.p = (float) ((double) this.p + 0.01D); - } else { - this.p = (float) ((double) this.p - 0.01D); - } - - this.p = MathHelper.a(this.p, 0.0F, 1.0F); - int j = this.worldData.getWeatherDuration(); - - if (j <= 0) { - if (this.worldData.hasStorm()) { - this.worldData.setWeatherDuration(this.random.nextInt(12000) + 12000); - } else { - this.worldData.setWeatherDuration(this.random.nextInt(168000) + 12000); - } - } else { - --j; - this.worldData.setWeatherDuration(j); - if (j <= 0) { - // CraftBukkit start - WeatherChangeEvent weather = new WeatherChangeEvent(this.getWorld(), !this.worldData.hasStorm()); - this.getServer().getPluginManager().callEvent(weather); - - if (!weather.isCancelled()) { - this.worldData.setStorm(!this.worldData.hasStorm()); - } - // CraftBukkit end - } - } - - this.m = this.n; - if (this.worldData.hasStorm()) { - this.n = (float) ((double) this.n + 0.01D); - } else { - this.n = (float) ((double) this.n - 0.01D); - } - - this.n = MathHelper.a(this.n, 0.0F, 1.0F); - } - } - } - - protected void C() { - // this.chunkTickList.clear(); // CraftBukkit - removed - this.methodProfiler.a("buildList"); - - int i; - EntityHuman entityhuman; - int j; - int k; - int l; - - for (i = 0; i < this.players.size(); ++i) { - entityhuman = (EntityHuman) this.players.get(i); - j = MathHelper.floor(entityhuman.locX / 16.0D); - k = MathHelper.floor(entityhuman.locZ / 16.0D); - l = this.p(); - - for (int i1 = -l; i1 <= l; ++i1) { - for (int j1 = -l; j1 <= l; ++j1) { - this.chunkTickList.add(org.bukkit.craftbukkit.util.LongHash.toLong(i1 + j, j1 + k)); // CraftBukkit - } - } - } - - this.methodProfiler.b(); - if (this.K > 0) { - --this.K; - } - - this.methodProfiler.a("playerCheckLight"); - if (!this.players.isEmpty()) { - i = this.random.nextInt(this.players.size()); - entityhuman = (EntityHuman) this.players.get(i); - j = MathHelper.floor(entityhuman.locX) + this.random.nextInt(11) - 5; - k = MathHelper.floor(entityhuman.locY) + this.random.nextInt(11) - 5; - l = MathHelper.floor(entityhuman.locZ) + this.random.nextInt(11) - 5; - this.t(j, k, l); - } - - this.methodProfiler.b(); - } - - protected abstract int p(); - - protected void a(int i, int j, Chunk chunk) { - this.methodProfiler.c("moodSound"); - if (this.K == 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; - Block block = chunk.getType(l, j1, i1); - - l += i; - i1 += j; - if (block.getMaterial() == Material.AIR && this.j(l, j1, i1) <= this.random.nextInt(8) && this.b(EnumSkyBlock.SKY, l, j1, i1) <= 0) { - EntityHuman entityhuman = this.findNearbyPlayer((double) l + 0.5D, (double) j1 + 0.5D, (double) i1 + 0.5D, 8.0D); - - 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.K = this.random.nextInt(12000) + 6000; - } - } - } - - this.methodProfiler.c("checkLight"); - chunk.o(); - } - - protected void g() { - this.C(); - } - - public boolean r(int i, int j, int k) { - return this.d(i, j, k, false); - } - - public boolean s(int i, int j, int k) { - return this.d(i, j, k, true); - } - - public boolean d(int i, int j, int k, boolean flag) { - BiomeBase biomebase = this.getBiome(i, k); - float f = biomebase.a(i, j, k); - - if (f > 0.15F) { - return false; - } else { - if (j >= 0 && j < 256 && this.b(EnumSkyBlock.BLOCK, i, j, k) < 10) { - Block block = this.getType(i, j, k); - - if ((block == Blocks.STATIONARY_WATER || block == Blocks.WATER) && this.getData(i, j, k) == 0) { - if (!flag) { - return true; - } - - boolean flag1 = true; - - if (flag1 && this.getType(i - 1, j, k).getMaterial() != Material.WATER) { - flag1 = false; - } - - if (flag1 && this.getType(i + 1, j, k).getMaterial() != Material.WATER) { - flag1 = false; - } - - if (flag1 && this.getType(i, j, k - 1).getMaterial() != Material.WATER) { - flag1 = false; - } - - if (flag1 && this.getType(i, j, k + 1).getMaterial() != Material.WATER) { - flag1 = false; - } - - if (!flag1) { - return true; - } - } - } - - return false; - } - } - - public boolean e(int i, int j, int k, boolean flag) { - BiomeBase biomebase = this.getBiome(i, k); - float f = biomebase.a(i, j, k); - - if (f > 0.15F) { - return false; - } else if (!flag) { - return true; - } else { - if (j >= 0 && j < 256 && this.b(EnumSkyBlock.BLOCK, i, j, k) < 10) { - Block block = this.getType(i, j, k); - - if (block.getMaterial() == Material.AIR && Blocks.SNOW.canPlace(this, i, j, k)) { - return true; - } - } - - return false; - } - } - - public boolean t(int i, int j, int k) { - boolean flag = false; - - if (!this.worldProvider.g) { - flag |= this.c(EnumSkyBlock.SKY, i, j, k); - } - - flag |= this.c(EnumSkyBlock.BLOCK, i, j, k); - return flag; - } - - private int a(int i, int j, int k, EnumSkyBlock enumskyblock) { - if (enumskyblock == EnumSkyBlock.SKY && this.i(i, j, k)) { - return 15; - } else { - Block block = this.getType(i, j, k); - int l = enumskyblock == EnumSkyBlock.SKY ? 0 : block.m(); - int i1 = block.k(); - - if (i1 >= 15 && block.m() > 0) { - i1 = 1; - } - - if (i1 < 1) { - i1 = 1; - } - - if (i1 >= 15) { - return 0; - } else if (l >= 14) { - return l; - } else { - for (int j1 = 0; j1 < 6; ++j1) { - int k1 = i + Facing.b[j1]; - int l1 = j + Facing.c[j1]; - int i2 = k + Facing.d[j1]; - int j2 = this.b(enumskyblock, k1, l1, i2) - i1; - - if (j2 > l) { - l = j2; - } - - if (l >= 14) { - return l; - } - } - - return l; - } - } - } - - public boolean c(EnumSkyBlock enumskyblock, int i, int j, int k) { - // CraftBukkit start - Use neighbor cache instead of looking up - Chunk chunk = this.getChunkIfLoaded(i >> 4, k >> 4); - if (chunk == null || !chunk.areNeighborsLoaded(1) /* !this.areChunksLoaded(i, j, k, 17)*/) { - // CraftBukkit end - return false; - } else { - int l = 0; - int i1 = 0; - - this.methodProfiler.a("getBrightness"); - int j1 = this.b(enumskyblock, i, j, k); - int k1 = this.a(i, j, k, enumskyblock); - int l1; - int i2; - int j2; - int k2; - int l2; - int i3; - int j3; - int k3; - int l3; - - if (k1 > j1) { - this.I[i1++] = 133152; - } else if (k1 < j1) { - this.I[i1++] = 133152 | j1 << 18; - - while (l < i1) { - l1 = this.I[l++]; - i2 = (l1 & 63) - 32 + i; - j2 = (l1 >> 6 & 63) - 32 + j; - k2 = (l1 >> 12 & 63) - 32 + k; - l2 = l1 >> 18 & 15; - i3 = this.b(enumskyblock, i2, j2, k2); - if (i3 == l2) { - this.b(enumskyblock, i2, j2, k2, 0); - if (l2 > 0) { - j3 = MathHelper.a(i2 - i); - l3 = MathHelper.a(j2 - j); - k3 = MathHelper.a(k2 - k); - if (j3 + l3 + k3 < 17) { - for (int i4 = 0; i4 < 6; ++i4) { - int j4 = i2 + Facing.b[i4]; - int k4 = j2 + Facing.c[i4]; - int l4 = k2 + Facing.d[i4]; - int i5 = Math.max(1, this.getType(j4, k4, l4).k()); - - i3 = this.b(enumskyblock, j4, k4, l4); - if (i3 == l2 - i5 && i1 < this.I.length) { - this.I[i1++] = j4 - i + 32 | k4 - j + 32 << 6 | l4 - k + 32 << 12 | l2 - i5 << 18; - } - } - } - } - } - } - - l = 0; - } - - this.methodProfiler.b(); - this.methodProfiler.a("checkedPosition < toCheckCount"); - - while (l < i1) { - l1 = this.I[l++]; - i2 = (l1 & 63) - 32 + i; - j2 = (l1 >> 6 & 63) - 32 + j; - k2 = (l1 >> 12 & 63) - 32 + k; - l2 = this.b(enumskyblock, i2, j2, k2); - i3 = this.a(i2, j2, k2, enumskyblock); - if (i3 != l2) { - this.b(enumskyblock, i2, j2, k2, i3); - if (i3 > l2) { - j3 = Math.abs(i2 - i); - l3 = Math.abs(j2 - j); - k3 = Math.abs(k2 - k); - boolean flag = i1 < this.I.length - 6; - - if (j3 + l3 + k3 < 17 && flag) { - if (this.b(enumskyblock, i2 - 1, j2, k2) < i3) { - this.I[i1++] = i2 - 1 - i + 32 + (j2 - j + 32 << 6) + (k2 - k + 32 << 12); - } - - if (this.b(enumskyblock, i2 + 1, j2, k2) < i3) { - this.I[i1++] = i2 + 1 - i + 32 + (j2 - j + 32 << 6) + (k2 - k + 32 << 12); - } - - if (this.b(enumskyblock, i2, j2 - 1, k2) < i3) { - this.I[i1++] = i2 - i + 32 + (j2 - 1 - j + 32 << 6) + (k2 - k + 32 << 12); - } - - if (this.b(enumskyblock, i2, j2 + 1, k2) < i3) { - this.I[i1++] = i2 - i + 32 + (j2 + 1 - j + 32 << 6) + (k2 - k + 32 << 12); - } - - if (this.b(enumskyblock, i2, j2, k2 - 1) < i3) { - this.I[i1++] = i2 - i + 32 + (j2 - j + 32 << 6) + (k2 - 1 - k + 32 << 12); - } - - if (this.b(enumskyblock, i2, j2, k2 + 1) < i3) { - this.I[i1++] = i2 - i + 32 + (j2 - j + 32 << 6) + (k2 + 1 - k + 32 << 12); - } - } - } - } - } - - this.methodProfiler.b(); - return true; - } - } - - public boolean a(boolean flag) { - return false; - } - - public List a(Chunk chunk, boolean flag) { - return null; - } - - public List getEntities(Entity entity, AxisAlignedBB axisalignedbb) { - return this.getEntities(entity, axisalignedbb, (IEntitySelector) null); - } - - public List getEntities(Entity entity, AxisAlignedBB axisalignedbb, IEntitySelector ientityselector) { - ArrayList arraylist = new ArrayList(); - 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); - int l = MathHelper.floor((axisalignedbb.f + 2.0D) / 16.0D); - - 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, arraylist, ientityselector); - } - } - } - - return arraylist; - } - - 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); - int l = MathHelper.floor((axisalignedbb.f + 2.0D) / 16.0D); - ArrayList arraylist = new ArrayList(); - - 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, ientityselector); - } - } - } - - return arraylist; - } - - public Entity a(Class oclass, AxisAlignedBB axisalignedbb, Entity entity) { - List list = this.a(oclass, axisalignedbb); - Entity entity1 = null; - double d0 = Double.MAX_VALUE; - - for (int i = 0; i < list.size(); ++i) { - Entity entity2 = (Entity) list.get(i); - - if (entity2 != entity) { - double d1 = entity.f(entity2); - - if (d1 <= d0) { - entity1 = entity2; - d0 = d1; - } - } - } - - 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(); - } - } - - public int a(Class oclass) { - int i = 0; - - for (int j = 0; j < this.entityList.size(); ++j) { - Entity entity = (Entity) this.entityList.get(j); - - // CraftBukkit start - Split out persistent check, don't apply it to special persistent mobs - if (entity instanceof EntityInsentient) { - EntityInsentient entityinsentient = (EntityInsentient) entity; - if (entityinsentient.isTypeNotPersistent() && entityinsentient.isPersistent()) { - continue; - } - } - - if (oclass.isAssignableFrom(entity.getClass())) { - // if ((!(entity instanceof EntityInsentient) || !((EntityInsentient) entity).isPersistent()) && oclass.isAssignableFrom(entity.getClass())) { - // CraftBukkit end - ++i; - } - } - - return i; - } - - public void a(List list) { - // CraftBukkit start - // this.entityList.addAll(list); - Entity entity = null; - - for (int i = 0; i < list.size(); ++i) { - entity = (Entity) list.get(i); - if (entity == null) { - continue; - } - this.entityList.add(entity); - // CraftBukkit end - this.a((Entity) list.get(i)); - } - } - - public void b(List list) { - this.f.addAll(list); - } - - public boolean mayPlace(Block block, int i, int j, int k, boolean flag, int l, Entity entity, ItemStack itemstack) { - Block block1 = this.getType(i, j, k); - AxisAlignedBB axisalignedbb = flag ? null : block.a(this, i, j, k); - - // CraftBukkit start - store default return - boolean defaultReturn = axisalignedbb != null && !this.a(axisalignedbb, entity) ? false : (block1.getMaterial() == Material.ORIENTABLE && block == Blocks.ANVIL ? true : block1.getMaterial().isReplaceable() && block.canPlace(this, i, j, k, l, itemstack)); - - // CraftBukkit start - BlockCanBuildEvent event = new BlockCanBuildEvent(this.getWorld().getBlockAt(i, j, k), CraftMagicNumbers.getId(block), defaultReturn); - this.getServer().getPluginManager().callEvent(event); - - return event.isBuildable(); - // CraftBukkit end - } - - public PathEntity findPath(Entity entity, Entity entity1, float f, boolean flag, boolean flag1, boolean flag2, boolean flag3) { - this.methodProfiler.a("pathfind"); - int i = MathHelper.floor(entity.locX); - int j = MathHelper.floor(entity.locY + 1.0D); - int k = MathHelper.floor(entity.locZ); - int l = (int) (f + 16.0F); - int i1 = i - l; - int j1 = j - l; - int k1 = k - l; - int l1 = i + l; - int i2 = j + l; - int j2 = k + l; - ChunkCache chunkcache = new ChunkCache(this, i1, j1, k1, l1, i2, j2, 0); - PathEntity pathentity = (new Pathfinder(chunkcache, flag, flag1, flag2, flag3)).a(entity, entity1, f); - - this.methodProfiler.b(); - return pathentity; - } - - public PathEntity a(Entity entity, int i, int j, int k, float f, boolean flag, boolean flag1, boolean flag2, boolean flag3) { - this.methodProfiler.a("pathfind"); - int l = MathHelper.floor(entity.locX); - int i1 = MathHelper.floor(entity.locY); - int j1 = MathHelper.floor(entity.locZ); - int k1 = (int) (f + 8.0F); - int l1 = l - k1; - int i2 = i1 - k1; - int j2 = j1 - k1; - int k2 = l + k1; - int l2 = i1 + k1; - int i3 = j1 + k1; - ChunkCache chunkcache = new ChunkCache(this, l1, i2, j2, k2, l2, i3, 0); - PathEntity pathentity = (new Pathfinder(chunkcache, flag, flag1, flag2, flag3)).a(entity, i, j, k, f); - - this.methodProfiler.b(); - return pathentity; - } - - public int getBlockPower(int i, int j, int k, int l) { - return this.getType(i, j, k).c(this, i, j, k, l); - } - - public int getBlockPower(int i, int j, int k) { - byte b0 = 0; - int l = Math.max(b0, this.getBlockPower(i, j - 1, k, 0)); - - if (l >= 15) { - return l; - } else { - l = Math.max(l, this.getBlockPower(i, j + 1, k, 1)); - if (l >= 15) { - return l; - } else { - l = Math.max(l, this.getBlockPower(i, j, k - 1, 2)); - if (l >= 15) { - return l; - } else { - l = Math.max(l, this.getBlockPower(i, j, k + 1, 3)); - if (l >= 15) { - return l; - } else { - l = Math.max(l, this.getBlockPower(i - 1, j, k, 4)); - if (l >= 15) { - return l; - } else { - l = Math.max(l, this.getBlockPower(i + 1, j, k, 5)); - return l >= 15 ? l : l; - } - } - } - } - } - } - - public boolean isBlockFacePowered(int i, int j, int k, int l) { - return this.getBlockFacePower(i, j, k, l) > 0; - } - - public int getBlockFacePower(int i, int j, int k, int l) { - return this.getType(i, j, k).r() ? this.getBlockPower(i, j, k) : this.getType(i, j, k).b(this, i, j, k, l); - } - - public boolean isBlockIndirectlyPowered(int i, int j, int k) { - return this.getBlockFacePower(i, j - 1, k, 0) > 0 ? true : (this.getBlockFacePower(i, j + 1, k, 1) > 0 ? true : (this.getBlockFacePower(i, j, k - 1, 2) > 0 ? true : (this.getBlockFacePower(i, j, k + 1, 3) > 0 ? true : (this.getBlockFacePower(i - 1, j, k, 4) > 0 ? true : this.getBlockFacePower(i + 1, j, k, 5) > 0)))); - } - - public int getHighestNeighborSignal(int i, int j, int k) { - int l = 0; - - for (int i1 = 0; i1 < 6; ++i1) { - int j1 = this.getBlockFacePower(i + Facing.b[i1], j + Facing.c[i1], k + Facing.d[i1], i1); - - if (j1 >= 15) { - return 15; - } - - if (j1 > l) { - l = j1; - } - } - - return l; - } - - public EntityHuman findNearbyPlayer(Entity entity, double d0) { - return this.findNearbyPlayer(entity.locX, entity.locY, entity.locZ, d0); - } - - public EntityHuman findNearbyPlayer(double d0, double d1, double d2, double d3) { - double d4 = -1.0D; - EntityHuman entityhuman = null; - - for (int i = 0; i < this.players.size(); ++i) { - EntityHuman entityhuman1 = (EntityHuman) this.players.get(i); - // CraftBukkit start - Fixed an NPE - if (entityhuman1 == null || entityhuman1.dead) { - continue; - } - // CraftBukkit end - double d5 = entityhuman1.e(d0, d1, d2); - - if ((d3 < 0.0D || d5 < d3 * d3) && (d4 == -1.0D || d5 < d4)) { - d4 = d5; - entityhuman = entityhuman1; - } - } - - return entityhuman; - } - - public EntityHuman findNearbyVulnerablePlayer(Entity entity, double d0) { - return this.findNearbyVulnerablePlayer(entity.locX, entity.locY, entity.locZ, d0); - } - - public EntityHuman findNearbyVulnerablePlayer(double d0, double d1, double d2, double d3) { - double d4 = -1.0D; - EntityHuman entityhuman = null; - - for (int i = 0; i < this.players.size(); ++i) { - EntityHuman entityhuman1 = (EntityHuman) this.players.get(i); - // CraftBukkit start - Fixed an NPE - if (entityhuman1 == null || entityhuman1.dead) { - continue; - } - // CraftBukkit end - - if (!entityhuman1.abilities.isInvulnerable && entityhuman1.isAlive()) { - double d5 = entityhuman1.e(d0, d1, d2); - double d6 = d3; - - if (entityhuman1.isSneaking()) { - d6 = d3 * 0.800000011920929D; - } - - if (entityhuman1.isInvisible()) { - float f = entityhuman1.bE(); - - 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; - } - } - } - - return entityhuman; - } - - public EntityHuman a(String s) { - for (int i = 0; i < this.players.size(); ++i) { - EntityHuman entityhuman = (EntityHuman) this.players.get(i); - - if (s.equals(entityhuman.getName())) { - return entityhuman; - } - } - - return null; - } - - public EntityHuman a(UUID uuid) { - for (int i = 0; i < this.players.size(); ++i) { - EntityHuman entityhuman = (EntityHuman) this.players.get(i); - - if (uuid.equals(entityhuman.getUniqueID())) { - return entityhuman; - } - } - - return null; - } - - public void G() throws ExceptionWorldConflict { // CraftBukkit - added throws - this.dataManager.checkSession(); - } - - public long getSeed() { - return this.worldData.getSeed(); - } - - public long getTime() { - return this.worldData.getTime(); - } - - public long getDayTime() { - return this.worldData.getDayTime(); - } - - public void setDayTime(long i) { - this.worldData.setDayTime(i); - } - - public ChunkCoordinates getSpawn() { - return new ChunkCoordinates(this.worldData.c(), this.worldData.d(), this.worldData.e()); - } - - public void x(int i, int j, int k) { - this.worldData.setSpawn(i, j, k); - } - - public boolean a(EntityHuman entityhuman, int i, int j, int k) { - return true; - } - - public void broadcastEntityEffect(Entity entity, byte b0) {} - - public IChunkProvider L() { - return this.chunkProvider; - } - - public void playBlockAction(int i, int j, int k, Block block, int l, int i1) { - block.a(this, i, j, k, l, i1); - } - - public IDataManager getDataManager() { - return this.dataManager; - } - - public WorldData getWorldData() { - return this.worldData; - } - - public GameRules getGameRules() { - return this.worldData.getGameRules(); - } - - public void everyoneSleeping() {} - - // CraftBukkit start - // Calls the method that checks to see if players are sleeping - // Called by CraftPlayer.setPermanentSleeping() - public void checkSleepStatus() { - if (!this.isStatic) { - this.everyoneSleeping(); - } - } - // CraftBukkit end - - public float h(float f) { - return (this.o + (this.p - this.o) * f) * this.j(f); - } - - public float j(float f) { - return this.m + (this.n - this.m) * f; - } - - public boolean P() { - return (double) this.h(1.0F) > 0.9D; - } - - public boolean Q() { - return (double) this.j(1.0F) > 0.2D; - } - - public boolean isRainingAt(int i, int j, int k) { - if (!this.Q()) { - return false; - } else if (!this.i(i, j, k)) { - return false; - } else if (this.h(i, k) > j) { - return false; - } else { - BiomeBase biomebase = this.getBiome(i, k); - - return biomebase.d() ? false : (this.e(i, j, k, false) ? false : biomebase.e()); - } - } - - public boolean z(int i, int j, int k) { - BiomeBase biomebase = this.getBiome(i, k); - - return biomebase.f(); - } - - public void a(String s, PersistentBase persistentbase) { - this.worldMaps.a(s, persistentbase); - } - - public PersistentBase a(Class oclass, String s) { - return this.worldMaps.get(oclass, s); - } - - public int b(String s) { - return this.worldMaps.a(s); - } - - public void b(int i, int j, int k, int l, int i1) { - for (int j1 = 0; j1 < this.u.size(); ++j1) { - ((IWorldAccess) this.u.get(j1)).a(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) { - try { - for (int j1 = 0; j1 < this.u.size(); ++j1) { - ((IWorldAccess) this.u.get(j1)).a(entityhuman, i, j, k, l, i1); - } - } catch (Throwable throwable) { - CrashReport crashreport = CrashReport.a(throwable, "Playing level event"); - CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Level event being played"); - - crashreportsystemdetails.a("Block coordinates", CrashReportSystemDetails.a(j, k, l)); - crashreportsystemdetails.a("Event source", entityhuman); - crashreportsystemdetails.a("Event type", Integer.valueOf(i)); - crashreportsystemdetails.a("Event data", Integer.valueOf(i1)); - throw new ReportedException(crashreport); - } - } - - public int getHeight() { - return 256; - } - - public int S() { - return this.worldProvider.g ? 128 : 256; - } - - public Random A(int i, int j, int k) { - long l = (long) i * 341873128712L + (long) j * 132897987541L + this.getWorldData().getSeed() + (long) k; - - this.random.setSeed(l); - return this.random; - } - - public ChunkPosition b(String s, int i, int j, int k) { - return this.L().findNearestMapFeature(this, s, i, j, k); - } - - public CrashReportSystemDetails a(CrashReport crashreport) { - CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Affected level", 1); - - crashreportsystemdetails.a("Level name", (this.worldData == null ? "????" : this.worldData.getName())); - crashreportsystemdetails.a("All players", (Callable) (new CrashReportPlayers(this))); - crashreportsystemdetails.a("Chunk stats", (Callable) (new CrashReportChunkStats(this))); - - try { - this.worldData.a(crashreportsystemdetails); - } catch (Throwable throwable) { - crashreportsystemdetails.a("Level Data Unobtainable", throwable); - } - - return crashreportsystemdetails; - } - - public void d(int i, int j, int k, int l, int i1) { - for (int j1 = 0; j1 < this.u.size(); ++j1) { - IWorldAccess iworldaccess = (IWorldAccess) this.u.get(j1); - - iworldaccess.b(i, j, k, l, i1); - } - } - - public Calendar V() { - if (this.getTime() % 600L == 0L) { - this.J.setTimeInMillis(MinecraftServer.ar()); - } - - return this.J; - } - - public Scoreboard getScoreboard() { - return this.scoreboard; - } - - public void updateAdjacentComparators(int i, int j, int k, Block block) { - for (int l = 0; l < 4; ++l) { - int i1 = i + Direction.a[l]; - int j1 = k + Direction.b[l]; - Block block1 = this.getType(i1, j, j1); - - if (Blocks.REDSTONE_COMPARATOR_OFF.e(block1)) { - block1.doPhysics(this, i1, j, j1, block); - } else if (block1.r()) { - i1 += Direction.a[l]; - j1 += Direction.b[l]; - Block block2 = this.getType(i1, j, j1); - - if (Blocks.REDSTONE_COMPARATOR_OFF.e(block2)) { - block2.doPhysics(this, i1, j, j1, block); - } - } - } - } - - public float b(double d0, double d1, double d2) { - return this.B(MathHelper.floor(d0), MathHelper.floor(d1), MathHelper.floor(d2)); - } - - public float B(int i, int j, int k) { - float f = 0.0F; - boolean flag = this.difficulty == EnumDifficulty.HARD; - - if (this.isLoaded(i, j, k)) { - float f1 = this.y(); - - f += MathHelper.a((float) this.getChunkAtWorldCoords(i, k).s / 3600000.0F, 0.0F, 1.0F) * (flag ? 1.0F : 0.75F); - f += f1 * 0.25F; - } - - if (this.difficulty == EnumDifficulty.EASY || this.difficulty == EnumDifficulty.PEACEFUL) { - f *= (float) this.difficulty.a() / 2.0F; - } - - return MathHelper.a(f, 0.0F, flag ? 1.5F : 1.0F); - } - - public void X() { - Iterator iterator = this.u.iterator(); - - while (iterator.hasNext()) { - IWorldAccess iworldaccess = (IWorldAccess) iterator.next(); - - iworldaccess.b(); - } - } -} diff --git a/src/main/java/net/minecraft/server/WorldGenBigTree.java b/src/main/java/net/minecraft/server/WorldGenBigTree.java deleted file mode 100644 index 1f8f1a98..00000000 --- a/src/main/java/net/minecraft/server/WorldGenBigTree.java +++ /dev/null @@ -1,372 +0,0 @@ -package net.minecraft.server; - -import java.util.Random; - -public class WorldGenBigTree extends WorldGenTreeAbstract { - - static final byte[] a = new byte[] { (byte) 2, (byte) 0, (byte) 0, (byte) 1, (byte) 2, (byte) 1}; - Random b = new Random(); - World world; - int[] d = new int[] { 0, 0, 0}; - int e; - int f; - double g = 0.618D; - double h = 1.0D; - double i = 0.381D; - double j = 1.0D; - double k = 1.0D; - int l = 1; - int m = 12; - int n = 4; - int[][] o; - - public WorldGenBigTree(boolean flag) { - super(flag); - } - - void a() { - this.f = (int) ((double) this.e * this.g); - if (this.f >= this.e) { - this.f = this.e - 1; - } - - int i = (int) (1.382D + Math.pow(this.k * (double) this.e / 13.0D, 2.0D)); - - if (i < 1) { - i = 1; - } - - int[][] aint = new int[i * this.e][4]; - int j = this.d[1] + this.e - this.n; - int k = 1; - int l = this.d[1] + this.f; - int i1 = j - this.d[1]; - - aint[0][0] = this.d[0]; - aint[0][1] = j; - aint[0][2] = this.d[2]; - aint[0][3] = l; - --j; - - while (i1 >= 0) { - int j1 = 0; - float f = this.a(i1); - - if (f < 0.0F) { - --j; - --i1; - } else { - for (double d0 = 0.5D; j1 < i; ++j1) { - double d1 = this.j * (double) f * ((double) this.b.nextFloat() + 0.328D); - double d2 = (double) this.b.nextFloat() * 2.0D * 3.14159D; - int k1 = MathHelper.floor(d1 * Math.sin(d2) + (double) this.d[0] + d0); - int l1 = MathHelper.floor(d1 * Math.cos(d2) + (double) this.d[2] + d0); - int[] aint1 = new int[] { k1, j, l1}; - int[] aint2 = new int[] { k1, j + this.n, l1}; - - if (this.a(aint1, aint2) == -1) { - int[] aint3 = new int[] { this.d[0], this.d[1], this.d[2]}; - double d3 = Math.sqrt(Math.pow((double) Math.abs(this.d[0] - aint1[0]), 2.0D) + Math.pow((double) Math.abs(this.d[2] - aint1[2]), 2.0D)); - double d4 = d3 * this.i; - - if ((double) aint1[1] - d4 > (double) l) { - aint3[1] = l; - } else { - aint3[1] = (int) ((double) aint1[1] - d4); - } - - if (this.a(aint3, aint1) == -1) { - aint[k][0] = k1; - aint[k][1] = j; - aint[k][2] = l1; - aint[k][3] = aint3[1]; - ++k; - } - } - } - - --j; - --i1; - } - } - - this.o = new int[k][4]; - System.arraycopy(aint, 0, this.o, 0, k); - } - - void a(int i, int j, int k, float f, byte b0, Block block) { - int l = (int) ((double) f + 0.618D); - byte b1 = a[b0]; - byte b2 = a[b0 + 3]; - int[] aint = new int[] { i, j, k}; - int[] aint1 = new int[] { 0, 0, 0}; - int i1 = -l; - int j1 = -l; - - for (aint1[b0] = aint[b0]; i1 <= l; ++i1) { - aint1[b1] = aint[b1] + i1; - j1 = -l; - - while (j1 <= l) { - double d0 = Math.pow((double) Math.abs(i1) + 0.5D, 2.0D) + Math.pow((double) Math.abs(j1) + 0.5D, 2.0D); - - if (d0 > (double) (f * f)) { - ++j1; - } else { - aint1[b2] = aint[b2] + j1; - Block block1 = this.world.getType(aint1[0], aint1[1], aint1[2]); - - if (block1.getMaterial() != Material.AIR && block1.getMaterial() != Material.LEAVES) { - ++j1; - } else { - this.setTypeAndData(this.world, aint1[0], aint1[1], aint1[2], block, 0); - ++j1; - } - } - } - } - } - - float a(int i) { - if ((double) i < (double) ((float) this.e) * 0.3D) { - return -1.618F; - } else { - float f = (float) this.e / 2.0F; - float f1 = (float) this.e / 2.0F - (float) i; - float f2; - - if (f1 == 0.0F) { - f2 = f; - } else if (Math.abs(f1) >= f) { - f2 = 0.0F; - } else { - f2 = (float) Math.sqrt(Math.pow((double) Math.abs(f), 2.0D) - Math.pow((double) Math.abs(f1), 2.0D)); - } - - f2 *= 0.5F; - return f2; - } - } - - float b(int i) { - return i >= 0 && i < this.n ? (i != 0 && i != this.n - 1 ? 3.0F : 2.0F) : -1.0F; - } - - void a(int i, int j, int k) { - int l = j; - - for (int i1 = j + this.n; l < i1; ++l) { - float f = this.b(l - j); - - this.a(i, l, k, f, (byte) 1, Blocks.LEAVES); - } - } - - void a(int[] aint, int[] aint1, Block block) { - int[] aint2 = new int[] { 0, 0, 0}; - byte b0 = 0; - - byte b1; - - for (b1 = 0; b0 < 3; ++b0) { - aint2[b0] = aint1[b0] - aint[b0]; - if (Math.abs(aint2[b0]) > Math.abs(aint2[b1])) { - b1 = b0; - } - } - - if (aint2[b1] != 0) { - byte b2 = a[b1]; - byte b3 = a[b1 + 3]; - byte b4; - - if (aint2[b1] > 0) { - b4 = 1; - } else { - b4 = -1; - } - - double d0 = (double) aint2[b2] / (double) aint2[b1]; - double d1 = (double) aint2[b3] / (double) aint2[b1]; - int[] aint3 = new int[] { 0, 0, 0}; - int i = 0; - - for (int j = aint2[b1] + b4; i != j; i += b4) { - aint3[b1] = MathHelper.floor((double) (aint[b1] + i) + 0.5D); - aint3[b2] = MathHelper.floor((double) aint[b2] + (double) i * d0 + 0.5D); - aint3[b3] = MathHelper.floor((double) aint[b3] + (double) i * d1 + 0.5D); - byte b5 = 0; - int k = Math.abs(aint3[0] - aint[0]); - int l = Math.abs(aint3[2] - aint[2]); - int i1 = Math.max(k, l); - - if (i1 > 0) { - if (k == i1) { - b5 = 4; - } else if (l == i1) { - b5 = 8; - } - } - - this.setTypeAndData(this.world, aint3[0], aint3[1], aint3[2], block, b5); - } - } - } - - void b() { - int i = 0; - - for (int j = this.o.length; i < j; ++i) { - int k = this.o[i][0]; - int l = this.o[i][1]; - int i1 = this.o[i][2]; - - this.a(k, l, i1); - } - } - - boolean c(int i) { - return (double) i >= (double) this.e * 0.2D; - } - - void c() { - int i = this.d[0]; - int j = this.d[1]; - int k = this.d[1] + this.f; - int l = this.d[2]; - int[] aint = new int[] { i, j, l}; - int[] aint1 = new int[] { i, k, l}; - - this.a(aint, aint1, Blocks.LOG); - if (this.l == 2) { - ++aint[0]; - ++aint1[0]; - this.a(aint, aint1, Blocks.LOG); - ++aint[2]; - ++aint1[2]; - this.a(aint, aint1, Blocks.LOG); - aint[0] += -1; - aint1[0] += -1; - this.a(aint, aint1, Blocks.LOG); - } - } - - void d() { - int i = 0; - int j = this.o.length; - - for (int[] aint = new int[] { this.d[0], this.d[1], this.d[2]}; i < j; ++i) { - int[] aint1 = this.o[i]; - int[] aint2 = new int[] { aint1[0], aint1[1], aint1[2]}; - - aint[1] = aint1[3]; - int k = aint[1] - this.d[1]; - - if (this.c(k)) { - this.a(aint, aint2, Blocks.LOG); - } - } - } - - int a(int[] aint, int[] aint1) { - int[] aint2 = new int[] { 0, 0, 0}; - byte b0 = 0; - - byte b1; - - for (b1 = 0; b0 < 3; ++b0) { - aint2[b0] = aint1[b0] - aint[b0]; - if (Math.abs(aint2[b0]) > Math.abs(aint2[b1])) { - b1 = b0; - } - } - - if (aint2[b1] == 0) { - return -1; - } else { - byte b2 = a[b1]; - byte b3 = a[b1 + 3]; - byte b4; - - if (aint2[b1] > 0) { - b4 = 1; - } else { - b4 = -1; - } - - double d0 = (double) aint2[b2] / (double) aint2[b1]; - double d1 = (double) aint2[b3] / (double) aint2[b1]; - int[] aint3 = new int[] { 0, 0, 0}; - int i = 0; - - int j; - - for (j = aint2[b1] + b4; i != j; i += b4) { - aint3[b1] = aint[b1] + i; - aint3[b2] = MathHelper.floor((double) aint[b2] + (double) i * d0); - aint3[b3] = MathHelper.floor((double) aint[b3] + (double) i * d1); - Block block = this.world.getType(aint3[0], aint3[1], aint3[2]); - - if (!this.a(block) || aint[1] >= 256) { // CraftBukkit - fix trees wrapping around - break; - } - } - - return i == j ? -1 : Math.abs(i); - } - } - - boolean e() { - int[] aint = new int[] { this.d[0], this.d[1], this.d[2]}; - int[] aint1 = new int[] { this.d[0], this.d[1] + this.e - 1, this.d[2]}; - Block block = this.world.getType(this.d[0], this.d[1] - 1, this.d[2]); - - if (block != Blocks.DIRT && block != Blocks.GRASS && block != Blocks.SOIL) { - return false; - } else { - int i = this.a(aint, aint1); - - if (i == -1) { - return true; - } else if (i < 6) { - return false; - } else { - this.e = i; - return true; - } - } - } - - public void a(double d0, double d1, double d2) { - this.m = (int) (d0 * 12.0D); - if (d0 > 0.5D) { - this.n = 5; - } - - this.j = d1; - this.k = d2; - } - - public boolean generate(World world, Random random, int i, int j, int k) { - this.world = world; - long l = random.nextLong(); - - this.b.setSeed(l); - this.d[0] = i; - this.d[1] = j; - this.d[2] = k; - if (this.e == 0) { - this.e = 5 + this.b.nextInt(this.m); - } - - if (!this.e()) { - return false; - } else { - this.a(); - this.b(); - this.c(); - this.d(); - return true; - } - } -} diff --git a/src/main/java/net/minecraft/server/WorldGenGroundBush.java b/src/main/java/net/minecraft/server/WorldGenGroundBush.java deleted file mode 100644 index ea8fdb55..00000000 --- a/src/main/java/net/minecraft/server/WorldGenGroundBush.java +++ /dev/null @@ -1,53 +0,0 @@ -package net.minecraft.server; - -import java.util.Random; - -public class WorldGenGroundBush extends WorldGenTrees { - - private int a; - private int b; - - public WorldGenGroundBush(int i, int j) { - super(false); - this.b = i; - this.a = j; - } - - public boolean a(World world, Random random, int i, int j, int k) { - Block block; - - while (((block = world.getType(i, j, k)).getMaterial() == Material.AIR || block.getMaterial() == Material.LEAVES) && j > 0) { - --j; - } - - Block block1 = world.getType(i, j, k); - - if (block1 == Blocks.DIRT || block1 == Blocks.GRASS) { - ++j; - this.setTypeAndData(world, i, j, k, Blocks.LOG, this.b); - - for (int l = j; l <= j + 2; ++l) { - int i1 = l - j; - int j1 = 2 - i1; - - for (int k1 = i - j1; k1 <= i + j1; ++k1) { - int l1 = k1 - i; - - for (int i2 = k - j1; i2 <= k + j1; ++i2) { - int j2 = i2 - k; - - if ((Math.abs(l1) != j1 || Math.abs(j2) != j1 || random.nextInt(2) != 0) && !world.getType(k1, l, i2).j()) { - this.setTypeAndData(world, k1, l, i2, Blocks.LEAVES, this.a); - } - } - } - } - // CraftBukkit start - Return false if gen was unsuccessful - } else { - return false; - } - // CraftBukkit end - - return true; - } -} diff --git a/src/main/java/net/minecraft/server/WorldGenMegaTreeAbstract.java b/src/main/java/net/minecraft/server/WorldGenMegaTreeAbstract.java deleted file mode 100644 index 0fd21716..00000000 --- a/src/main/java/net/minecraft/server/WorldGenMegaTreeAbstract.java +++ /dev/null @@ -1,126 +0,0 @@ -package net.minecraft.server; - -import java.util.Random; - -public abstract class WorldGenMegaTreeAbstract extends WorldGenTreeAbstract { - - protected final int a; - protected final int b; - protected final int c; - protected int d; - - public WorldGenMegaTreeAbstract(boolean flag, int i, int j, int k, int l) { - super(flag); - this.a = i; - this.d = j; - this.b = k; - this.c = l; - } - - protected int a(Random random) { - int i = random.nextInt(3) + this.a; - - if (this.d > 1) { - i += random.nextInt(this.d); - } - - return i; - } - - private boolean b(World world, Random random, int i, int j, int k, int l) { - boolean flag = true; - - if (j >= 1 && j + l + 1 <= 256) { - for (int i1 = j; i1 <= j + 1 + l; ++i1) { - byte b0 = 2; - - if (i1 == j) { - b0 = 1; - } - - if (i1 >= j + 1 + l - 2) { - b0 = 2; - } - - for (int j1 = i - b0; j1 <= i + b0 && flag; ++j1) { - for (int k1 = k - b0; k1 <= k + b0 && flag; ++k1) { - if (i1 >= 0 && i1 < 256) { - Block block = world.getType(j1, i1, k1); - - // CraftBukkit - ignore our own saplings - if (block != Blocks.SAPLING && !this.a(block)) { - flag = false; - } - } else { - flag = false; - } - } - } - } - - return flag; - } else { - return false; - } - } - - private boolean c(World world, Random random, int i, int j, int k) { - Block block = world.getType(i, j - 1, k); - - if ((block == Blocks.GRASS || block == Blocks.DIRT) && j >= 2) { - world.setTypeAndData(i, j - 1, k, Blocks.DIRT, 0, 2); - world.setTypeAndData(i + 1, j - 1, k, Blocks.DIRT, 0, 2); - world.setTypeAndData(i, j - 1, k + 1, Blocks.DIRT, 0, 2); - world.setTypeAndData(i + 1, j - 1, k + 1, Blocks.DIRT, 0, 2); - return true; - } else { - return false; - } - } - - protected boolean a(World world, Random random, int i, int j, int k, int l) { - return this.b(world, random, i, j, k, l) && this.c(world, random, i, j, k); - } - - protected void a(World world, int i, int j, int k, int l, Random random) { - int i1 = l * l; - - for (int j1 = i - l; j1 <= i + l + 1; ++j1) { - int k1 = j1 - i; - - for (int l1 = k - l; l1 <= k + l + 1; ++l1) { - int i2 = l1 - k; - int j2 = k1 - 1; - int k2 = i2 - 1; - - if (k1 * k1 + i2 * i2 <= i1 || j2 * j2 + k2 * k2 <= i1 || k1 * k1 + k2 * k2 <= i1 || j2 * j2 + i2 * i2 <= i1) { - Block block = world.getType(j1, j, l1); - - if (block.getMaterial() == Material.AIR || block.getMaterial() == Material.LEAVES) { - this.setTypeAndData(world, j1, j, l1, Blocks.LEAVES, this.c); - } - } - } - } - } - - protected void b(World world, int i, int j, int k, int l, Random random) { - int i1 = l * l; - - for (int j1 = i - l; j1 <= i + l; ++j1) { - int k1 = j1 - i; - - for (int l1 = k - l; l1 <= k + l; ++l1) { - int i2 = l1 - k; - - if (k1 * k1 + i2 * i2 <= i1) { - Block block = world.getType(j1, j, l1); - - if (block.getMaterial() == Material.AIR || block.getMaterial() == Material.LEAVES) { - this.setTypeAndData(world, j1, j, l1, Blocks.LEAVES, this.c); - } - } - } - } - } -} diff --git a/src/main/java/net/minecraft/server/WorldGenVillagePiece.java b/src/main/java/net/minecraft/server/WorldGenVillagePiece.java deleted file mode 100644 index dd228e77..00000000 --- a/src/main/java/net/minecraft/server/WorldGenVillagePiece.java +++ /dev/null @@ -1,189 +0,0 @@ -package net.minecraft.server; - -import java.util.List; -import java.util.Random; - -abstract class WorldGenVillagePiece extends StructurePiece { - - protected int k = -1; - private int a; - private boolean b; - - public WorldGenVillagePiece() {} - - protected WorldGenVillagePiece(WorldGenVillageStartPiece worldgenvillagestartpiece, int i) { - super(i); - if (worldgenvillagestartpiece != null) { - this.b = worldgenvillagestartpiece.b; - } - } - - protected void a(NBTTagCompound nbttagcompound) { - nbttagcompound.setInt("HPos", this.k); - nbttagcompound.setInt("VCount", this.a); - nbttagcompound.setBoolean("Desert", this.b); - } - - protected void b(NBTTagCompound nbttagcompound) { - this.k = nbttagcompound.getInt("HPos"); - this.a = nbttagcompound.getInt("VCount"); - this.b = nbttagcompound.getBoolean("Desert"); - } - - protected StructurePiece a(WorldGenVillageStartPiece worldgenvillagestartpiece, List list, Random random, int i, int j) { - switch (this.g) { - case 0: - return WorldGenVillagePieces.a(worldgenvillagestartpiece, list, random, this.f.a - 1, this.f.b + i, this.f.c + j, 1, this.d()); - - case 1: - return WorldGenVillagePieces.a(worldgenvillagestartpiece, list, random, this.f.a + j, this.f.b + i, this.f.c - 1, 2, this.d()); - - case 2: - return WorldGenVillagePieces.a(worldgenvillagestartpiece, list, random, this.f.a - 1, this.f.b + i, this.f.c + j, 1, this.d()); - - case 3: - return WorldGenVillagePieces.a(worldgenvillagestartpiece, list, random, this.f.a + j, this.f.b + i, this.f.c - 1, 2, this.d()); - - default: - return null; - } - } - - protected StructurePiece b(WorldGenVillageStartPiece worldgenvillagestartpiece, List list, Random random, int i, int j) { - switch (this.g) { - case 0: - return WorldGenVillagePieces.a(worldgenvillagestartpiece, list, random, this.f.d + 1, this.f.b + i, this.f.c + j, 3, this.d()); - - case 1: - return WorldGenVillagePieces.a(worldgenvillagestartpiece, list, random, this.f.a + j, this.f.b + i, this.f.f + 1, 0, this.d()); - - case 2: - return WorldGenVillagePieces.a(worldgenvillagestartpiece, list, random, this.f.d + 1, this.f.b + i, this.f.c + j, 3, this.d()); - - case 3: - return WorldGenVillagePieces.a(worldgenvillagestartpiece, list, random, this.f.a + j, this.f.b + i, this.f.f + 1, 0, this.d()); - - default: - return null; - } - } - - protected int b(World world, StructureBoundingBox structureboundingbox) { - int i = 0; - int j = 0; - - for (int k = this.f.c; k <= this.f.f; ++k) { - for (int l = this.f.a; l <= this.f.d; ++l) { - if (structureboundingbox.b(l, 64, k)) { - i += Math.max(world.i(l, k), world.worldProvider.getSeaLevel()); - ++j; - } - } - } - - if (j == 0) { - return -1; - } else { - return i / j; - } - } - - protected static boolean a(StructureBoundingBox structureboundingbox) { - return structureboundingbox != null && structureboundingbox.b > 10; - } - - protected void a(World world, StructureBoundingBox structureboundingbox, int i, int j, int k, int l) { - if (this.a < l) { - for (int i1 = this.a; i1 < l; ++i1) { - int j1 = this.a(i + i1, k); - int k1 = this.a(j); - int l1 = this.b(i + i1, k); - - if (!structureboundingbox.b(j1, k1, l1)) { - break; - } - - ++this.a; - EntityVillager entityvillager = new EntityVillager(world, this.b(i1)); - - entityvillager.setPositionRotation((double) j1 + 0.5D, (double) k1, (double) l1 + 0.5D, 0.0F, 0.0F); - world.addEntity(entityvillager, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN); // CraftBukkit - add SpawnReason - } - } - } - - protected int b(int i) { - return 0; - } - - protected Block b(Block block, int i) { - if (this.b) { - if (block == Blocks.LOG || block == Blocks.LOG2) { - return Blocks.SANDSTONE; - } - - if (block == Blocks.COBBLESTONE) { - return Blocks.SANDSTONE; - } - - if (block == Blocks.WOOD) { - return Blocks.SANDSTONE; - } - - if (block == Blocks.WOOD_STAIRS) { - return Blocks.SANDSTONE_STAIRS; - } - - if (block == Blocks.COBBLESTONE_STAIRS) { - return Blocks.SANDSTONE_STAIRS; - } - - if (block == Blocks.GRAVEL) { - return Blocks.SANDSTONE; - } - } - - return block; - } - - protected int c(Block block, int i) { - if (this.b) { - if (block == Blocks.LOG || block == Blocks.LOG2) { - return 0; - } - - if (block == Blocks.COBBLESTONE) { - return 0; - } - - if (block == Blocks.WOOD) { - return 2; - } - } - - return i; - } - - protected void a(World world, Block block, int i, int j, int k, int l, StructureBoundingBox structureboundingbox) { - Block block1 = this.b(block, i); - int i1 = this.c(block, i); - - super.a(world, block1, i1, j, k, l, structureboundingbox); - } - - protected void a(World world, StructureBoundingBox structureboundingbox, int i, int j, int k, int l, int i1, int j1, Block block, Block block1, boolean flag) { - Block block2 = this.b(block, 0); - int k1 = this.c(block, 0); - Block block3 = this.b(block1, 0); - int l1 = this.c(block1, 0); - - super.a(world, structureboundingbox, i, j, k, l, i1, j1, block2, k1, block3, l1, flag); - } - - protected void b(World world, Block block, int i, int j, int k, int l, StructureBoundingBox structureboundingbox) { - Block block1 = this.b(block, i); - int i1 = this.c(block, i); - - super.b(world, block1, i1, j, k, l, structureboundingbox); - } -} diff --git a/src/main/java/net/minecraft/server/WorldGenVillagePieces.java b/src/main/java/net/minecraft/server/WorldGenVillagePieces.java deleted file mode 100644 index e08c6fe2..00000000 --- a/src/main/java/net/minecraft/server/WorldGenVillagePieces.java +++ /dev/null @@ -1,199 +0,0 @@ -package net.minecraft.server; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Random; - -public class WorldGenVillagePieces { - - public static void a() { - WorldGenFactory.a(WorldGenVillageLibrary.class, "ViBH"); - WorldGenFactory.a(WorldGenVillageFarm2.class, "ViDF"); - WorldGenFactory.a(WorldGenVillageFarm.class, "ViF"); - WorldGenFactory.a(WorldGenVillageLight.class, "ViL"); - WorldGenFactory.a(WorldGenVillageButcher.class, "ViPH"); - WorldGenFactory.a(WorldGenVillageHouse.class, "ViSH"); - WorldGenFactory.a(WorldGenVillageHut.class, "ViSmH"); - WorldGenFactory.a(WorldGenVillageTemple.class, "ViST"); - WorldGenFactory.a(WorldGenVillageBlacksmith.class, "ViS"); - WorldGenFactory.a(WorldGenVillageStartPiece.class, "ViStart"); - WorldGenFactory.a(WorldGenVillageRoad.class, "ViSR"); - WorldGenFactory.a(WorldGenVillageHouse2.class, "ViTRH"); - WorldGenFactory.a(WorldGenVillageWell.class, "ViW"); - } - - public static List a(Random random, int i) { - ArrayList arraylist = new ArrayList(); - - arraylist.add(new WorldGenVillagePieceWeight(WorldGenVillageHouse.class, 4, MathHelper.nextInt(random, 2 + i, 4 + i * 2))); - arraylist.add(new WorldGenVillagePieceWeight(WorldGenVillageTemple.class, 20, MathHelper.nextInt(random, 0 + i, 1 + i))); - arraylist.add(new WorldGenVillagePieceWeight(WorldGenVillageLibrary.class, 20, MathHelper.nextInt(random, 0 + i, 2 + i))); - arraylist.add(new WorldGenVillagePieceWeight(WorldGenVillageHut.class, 3, MathHelper.nextInt(random, 2 + i, 5 + i * 3))); - arraylist.add(new WorldGenVillagePieceWeight(WorldGenVillageButcher.class, 15, MathHelper.nextInt(random, 0 + i, 2 + i))); - arraylist.add(new WorldGenVillagePieceWeight(WorldGenVillageFarm2.class, 3, MathHelper.nextInt(random, 1 + i, 4 + i))); - arraylist.add(new WorldGenVillagePieceWeight(WorldGenVillageFarm.class, 3, MathHelper.nextInt(random, 2 + i, 4 + i * 2))); - arraylist.add(new WorldGenVillagePieceWeight(WorldGenVillageBlacksmith.class, 15, MathHelper.nextInt(random, 0, 1 + i))); - arraylist.add(new WorldGenVillagePieceWeight(WorldGenVillageHouse2.class, 8, MathHelper.nextInt(random, 0 + i, 3 + i * 2))); - Iterator iterator = arraylist.iterator(); - - while (iterator.hasNext()) { - if (((WorldGenVillagePieceWeight) iterator.next()).d == 0) { - iterator.remove(); - } - } - - return arraylist; - } - - private static int a(List list) { - boolean flag = false; - int i = 0; - - WorldGenVillagePieceWeight worldgenvillagepieceweight; - - for (Iterator iterator = list.iterator(); iterator.hasNext(); i += worldgenvillagepieceweight.b) { - worldgenvillagepieceweight = (WorldGenVillagePieceWeight) iterator.next(); - if (worldgenvillagepieceweight.d > 0 && worldgenvillagepieceweight.c < worldgenvillagepieceweight.d) { - flag = true; - } - } - - return flag ? i : -1; - } - - private static WorldGenVillagePiece a(WorldGenVillageStartPiece worldgenvillagestartpiece, WorldGenVillagePieceWeight worldgenvillagepieceweight, List list, Random random, int i, int j, int k, int l, int i1) { - Class oclass = worldgenvillagepieceweight.a; - Object object = null; - - if (oclass == WorldGenVillageHouse.class) { - object = WorldGenVillageHouse.a(worldgenvillagestartpiece, list, random, i, j, k, l, i1); - } else if (oclass == WorldGenVillageTemple.class) { - object = WorldGenVillageTemple.a(worldgenvillagestartpiece, list, random, i, j, k, l, i1); - } else if (oclass == WorldGenVillageLibrary.class) { - object = WorldGenVillageLibrary.a(worldgenvillagestartpiece, list, random, i, j, k, l, i1); - } else if (oclass == WorldGenVillageHut.class) { - object = WorldGenVillageHut.a(worldgenvillagestartpiece, list, random, i, j, k, l, i1); - } else if (oclass == WorldGenVillageButcher.class) { - object = WorldGenVillageButcher.a(worldgenvillagestartpiece, list, random, i, j, k, l, i1); - } else if (oclass == WorldGenVillageFarm2.class) { - object = WorldGenVillageFarm2.a(worldgenvillagestartpiece, list, random, i, j, k, l, i1); - } else if (oclass == WorldGenVillageFarm.class) { - object = WorldGenVillageFarm.a(worldgenvillagestartpiece, list, random, i, j, k, l, i1); - } else if (oclass == WorldGenVillageBlacksmith.class) { - object = WorldGenVillageBlacksmith.a(worldgenvillagestartpiece, list, random, i, j, k, l, i1); - } else if (oclass == WorldGenVillageHouse2.class) { - object = WorldGenVillageHouse2.a(worldgenvillagestartpiece, list, random, i, j, k, l, i1); - } - - return (WorldGenVillagePiece) object; - } - - private static WorldGenVillagePiece c(WorldGenVillageStartPiece worldgenvillagestartpiece, List list, Random random, int i, int j, int k, int l, int i1) { - int j1 = a(worldgenvillagestartpiece.e); - - if (j1 <= 0) { - return null; - } else { - int k1 = 0; - - while (k1 < 5) { - ++k1; - int l1 = random.nextInt(j1); - Iterator iterator = worldgenvillagestartpiece.e.iterator(); - - while (iterator.hasNext()) { - WorldGenVillagePieceWeight worldgenvillagepieceweight = (WorldGenVillagePieceWeight) iterator.next(); - - l1 -= worldgenvillagepieceweight.b; - if (l1 < 0) { - if (!worldgenvillagepieceweight.a(i1) || worldgenvillagepieceweight == worldgenvillagestartpiece.d && worldgenvillagestartpiece.e.size() > 1) { - break; - } - - WorldGenVillagePiece worldgenvillagepiece = a(worldgenvillagestartpiece, worldgenvillagepieceweight, list, random, i, j, k, l, i1); - - if (worldgenvillagepiece != null) { - ++worldgenvillagepieceweight.c; - worldgenvillagestartpiece.d = worldgenvillagepieceweight; - if (!worldgenvillagepieceweight.a()) { - worldgenvillagestartpiece.e.remove(worldgenvillagepieceweight); - } - - return worldgenvillagepiece; - } - } - } - } - - StructureBoundingBox structureboundingbox = WorldGenVillageLight.a(worldgenvillagestartpiece, list, random, i, j, k, l); - - if (structureboundingbox != null) { - return new WorldGenVillageLight(worldgenvillagestartpiece, i1, random, structureboundingbox, l); - } else { - return null; - } - } - } - - private static StructurePiece d(WorldGenVillageStartPiece worldgenvillagestartpiece, List list, Random random, int i, int j, int k, int l, int i1) { - if (i1 > 50) { - return null; - } else if (Math.abs(i - worldgenvillagestartpiece.c().a) <= 112 && Math.abs(k - worldgenvillagestartpiece.c().c) <= 112) { - WorldGenVillagePiece worldgenvillagepiece = c(worldgenvillagestartpiece, list, random, i, j, k, l, i1 + 1); - - if (worldgenvillagepiece != null) { - int j1 = (worldgenvillagepiece.f.a + worldgenvillagepiece.f.d) / 2; - int k1 = (worldgenvillagepiece.f.c + worldgenvillagepiece.f.f) / 2; - int l1 = worldgenvillagepiece.f.d - worldgenvillagepiece.f.a; - int i2 = worldgenvillagepiece.f.f - worldgenvillagepiece.f.c; - int j2 = l1 > i2 ? l1 : i2; - - if (worldgenvillagestartpiece.e().a(j1, k1, j2 / 2 + 4, WorldGenVillage.e)) { - list.add(worldgenvillagepiece); - worldgenvillagestartpiece.i.add(worldgenvillagepiece); - return worldgenvillagepiece; - } - } - - return null; - } else { - return null; - } - } - - private static StructurePiece e(WorldGenVillageStartPiece worldgenvillagestartpiece, List list, Random random, int i, int j, int k, int l, int i1) { - if (i1 > 3 + worldgenvillagestartpiece.c) { - return null; - } else if (Math.abs(i - worldgenvillagestartpiece.c().a) <= 112 && Math.abs(k - worldgenvillagestartpiece.c().c) <= 112) { - StructureBoundingBox structureboundingbox = WorldGenVillageRoad.a(worldgenvillagestartpiece, list, random, i, j, k, l); - - if (structureboundingbox != null && structureboundingbox.b > 10) { - WorldGenVillageRoad worldgenvillageroad = new WorldGenVillageRoad(worldgenvillagestartpiece, i1, random, structureboundingbox, l); - int j1 = (worldgenvillageroad.f.a + worldgenvillageroad.f.d) / 2; - int k1 = (worldgenvillageroad.f.c + worldgenvillageroad.f.f) / 2; - int l1 = worldgenvillageroad.f.d - worldgenvillageroad.f.a; - int i2 = worldgenvillageroad.f.f - worldgenvillageroad.f.c; - int j2 = l1 > i2 ? l1 : i2; - - if (worldgenvillagestartpiece.e().a(j1, k1, j2 / 2 + 4, WorldGenVillage.e)) { - list.add(worldgenvillageroad); - worldgenvillagestartpiece.j.add(worldgenvillageroad); - return worldgenvillageroad; - } - } - - return null; - } else { - return null; - } - } - - static StructurePiece a(WorldGenVillageStartPiece worldgenvillagestartpiece, List list, Random random, int i, int j, int k, int l, int i1) { - return d(worldgenvillagestartpiece, list, random, i, j, k, l, i1); - } - - static StructurePiece b(WorldGenVillageStartPiece worldgenvillagestartpiece, List list, Random random, int i, int j, int k, int l, int i1) { - return e(worldgenvillagestartpiece, list, random, i, j, k, l, i1); - } -} diff --git a/src/main/java/net/minecraft/server/WorldGenWitchHut.java b/src/main/java/net/minecraft/server/WorldGenWitchHut.java deleted file mode 100644 index ae60aeb8..00000000 --- a/src/main/java/net/minecraft/server/WorldGenWitchHut.java +++ /dev/null @@ -1,87 +0,0 @@ -package net.minecraft.server; - -import java.util.Random; - -public class WorldGenWitchHut extends WorldGenScatteredPiece { - - private boolean e; - - public WorldGenWitchHut() {} - - public WorldGenWitchHut(Random random, int i, int j) { - super(random, i, 64, j, 7, 5, 9); - } - - protected void a(NBTTagCompound nbttagcompound) { - super.a(nbttagcompound); - nbttagcompound.setBoolean("Witch", this.e); - } - - protected void b(NBTTagCompound nbttagcompound) { - super.b(nbttagcompound); - this.e = nbttagcompound.getBoolean("Witch"); - } - - public boolean a(World world, Random random, StructureBoundingBox structureboundingbox) { - if (!this.a(world, structureboundingbox, 0)) { - return false; - } else { - this.a(world, structureboundingbox, 1, 1, 1, 5, 1, 7, Blocks.WOOD, 1, Blocks.WOOD, 1, false); - this.a(world, structureboundingbox, 1, 4, 2, 5, 4, 7, Blocks.WOOD, 1, Blocks.WOOD, 1, false); - this.a(world, structureboundingbox, 2, 1, 0, 4, 1, 0, Blocks.WOOD, 1, Blocks.WOOD, 1, false); - this.a(world, structureboundingbox, 2, 2, 2, 3, 3, 2, Blocks.WOOD, 1, Blocks.WOOD, 1, false); - this.a(world, structureboundingbox, 1, 2, 3, 1, 3, 6, Blocks.WOOD, 1, Blocks.WOOD, 1, false); - this.a(world, structureboundingbox, 5, 2, 3, 5, 3, 6, Blocks.WOOD, 1, Blocks.WOOD, 1, false); - this.a(world, structureboundingbox, 2, 2, 7, 4, 3, 7, Blocks.WOOD, 1, Blocks.WOOD, 1, false); - this.a(world, structureboundingbox, 1, 0, 2, 1, 3, 2, Blocks.LOG, Blocks.LOG, false); - this.a(world, structureboundingbox, 5, 0, 2, 5, 3, 2, Blocks.LOG, Blocks.LOG, false); - this.a(world, structureboundingbox, 1, 0, 7, 1, 3, 7, Blocks.LOG, Blocks.LOG, false); - this.a(world, structureboundingbox, 5, 0, 7, 5, 3, 7, Blocks.LOG, Blocks.LOG, false); - this.a(world, Blocks.FENCE, 0, 2, 3, 2, structureboundingbox); - this.a(world, Blocks.FENCE, 0, 3, 3, 7, structureboundingbox); - this.a(world, Blocks.AIR, 0, 1, 3, 4, structureboundingbox); - this.a(world, Blocks.AIR, 0, 5, 3, 4, structureboundingbox); - this.a(world, Blocks.AIR, 0, 5, 3, 5, structureboundingbox); - this.a(world, Blocks.FLOWER_POT, 7, 1, 3, 5, structureboundingbox); - this.a(world, Blocks.WORKBENCH, 0, 3, 2, 6, structureboundingbox); - this.a(world, Blocks.CAULDRON, 0, 4, 2, 6, structureboundingbox); - this.a(world, Blocks.FENCE, 0, 1, 2, 1, structureboundingbox); - this.a(world, Blocks.FENCE, 0, 5, 2, 1, structureboundingbox); - int i = this.a(Blocks.WOOD_STAIRS, 3); - int j = this.a(Blocks.WOOD_STAIRS, 1); - int k = this.a(Blocks.WOOD_STAIRS, 0); - int l = this.a(Blocks.WOOD_STAIRS, 2); - - this.a(world, structureboundingbox, 0, 4, 1, 6, 4, 1, Blocks.SPRUCE_WOOD_STAIRS, i, Blocks.SPRUCE_WOOD_STAIRS, i, false); - this.a(world, structureboundingbox, 0, 4, 2, 0, 4, 7, Blocks.SPRUCE_WOOD_STAIRS, k, Blocks.SPRUCE_WOOD_STAIRS, k, false); - this.a(world, structureboundingbox, 6, 4, 2, 6, 4, 7, Blocks.SPRUCE_WOOD_STAIRS, j, Blocks.SPRUCE_WOOD_STAIRS, j, false); - this.a(world, structureboundingbox, 0, 4, 8, 6, 4, 8, Blocks.SPRUCE_WOOD_STAIRS, l, Blocks.SPRUCE_WOOD_STAIRS, l, false); - - int i1; - int j1; - - for (i1 = 2; i1 <= 7; i1 += 5) { - for (j1 = 1; j1 <= 5; j1 += 4) { - this.b(world, Blocks.LOG, 0, j1, -1, i1, structureboundingbox); - } - } - - if (!this.e) { - i1 = this.a(2, 5); - j1 = this.a(2); - int k1 = this.b(2, 5); - - if (structureboundingbox.b(i1, j1, k1)) { - this.e = true; - EntityWitch entitywitch = new EntityWitch(world); - - entitywitch.setPositionRotation((double) i1 + 0.5D, (double) j1, (double) k1 + 0.5D, 0.0F, 0.0F); - entitywitch.prepare((GroupDataEntity) null); - world.addEntity(entitywitch, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN); // CraftBukkit - add SpawnReason - } - } - - return true; - } - } -} diff --git a/src/main/java/net/minecraft/server/WorldManager.java b/src/main/java/net/minecraft/server/WorldManager.java deleted file mode 100644 index b3499024..00000000 --- a/src/main/java/net/minecraft/server/WorldManager.java +++ /dev/null @@ -1,73 +0,0 @@ -package net.minecraft.server; - -import java.util.Iterator; - -public class WorldManager implements IWorldAccess { - - private MinecraftServer server; - public WorldServer world; // CraftBukkit - private -> public - - public WorldManager(MinecraftServer minecraftserver, WorldServer worldserver) { - this.server = minecraftserver; - this.world = worldserver; - } - - public void a(String s, double d0, double d1, double d2, double d3, double d4, double d5) {} - - public void a(Entity entity) { - this.world.getTracker().track(entity); - } - - public void b(Entity entity) { - this.world.getTracker().untrackEntity(entity); - } - - public void a(String s, double d0, double d1, double d2, float f, float f1) { - // CraftBukkit - this.world.dimension - this.server.getPlayerList().sendPacketNearby(d0, d1, d2, f > 1.0F ? (double) (16.0F * f) : 16.0D, this.world.dimension, new PacketPlayOutNamedSoundEffect(s, d0, d1, d2, f, f1)); - } - - public void a(EntityHuman entityhuman, String s, double d0, double d1, double d2, float f, float f1) { - // CraftBukkit - this.world.dimension - this.server.getPlayerList().sendPacketNearby(entityhuman, d0, d1, d2, f > 1.0F ? (double) (16.0F * f) : 16.0D, this.world.dimension, new PacketPlayOutNamedSoundEffect(s, d0, d1, d2, f, f1)); - } - - public void a(int i, int j, int k, int l, int i1, int j1) {} - - public void a(int i, int j, int k) { - this.world.getPlayerChunkMap().flagDirty(i, j, k); - } - - public void b(int i, int j, int k) {} - - public void a(String s, int i, int j, int k) {} - - public void a(EntityHuman entityhuman, int i, int j, int k, int l, int i1) { - // CraftBukkit - this.world.dimension - this.server.getPlayerList().sendPacketNearby(entityhuman, (double) j, (double) k, (double) l, 64.0D, this.world.dimension, new PacketPlayOutWorldEvent(i, j, k, l, i1, false)); - } - - public void a(int i, int j, int k, int l, int i1) { - this.server.getPlayerList().sendAll(new PacketPlayOutWorldEvent(i, j, k, l, i1, true)); - } - - public void b(int i, int j, int k, int l, int i1) { - Iterator iterator = this.server.getPlayerList().players.iterator(); - - while (iterator.hasNext()) { - EntityPlayer entityplayer = (EntityPlayer) iterator.next(); - - if (entityplayer != null && entityplayer.world == this.world && entityplayer.getId() != i) { - double d0 = (double) j - entityplayer.locX; - double d1 = (double) k - entityplayer.locY; - double d2 = (double) l - entityplayer.locZ; - - if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D) { - entityplayer.playerConnection.sendPacket(new PacketPlayOutBlockBreakAnimation(i, j, k, l, i1)); - } - } - } - } - - public void b() {} -} diff --git a/src/main/java/net/minecraft/server/WorldMap.java b/src/main/java/net/minecraft/server/WorldMap.java deleted file mode 100644 index bd5cfca8..00000000 --- a/src/main/java/net/minecraft/server/WorldMap.java +++ /dev/null @@ -1,243 +0,0 @@ -package net.minecraft.server; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -// CraftBukkit start -import java.util.UUID; - -import org.bukkit.craftbukkit.CraftServer; -import org.bukkit.craftbukkit.CraftWorld; -import org.bukkit.craftbukkit.map.CraftMapView; -// CraftBukkit end - -public class WorldMap extends PersistentBase { - - public int centerX; - public int centerZ; - public byte map; - public byte scale; - public byte[] colors = new byte[16384]; - public List f = new ArrayList(); - private Map i = new HashMap(); - public Map decorations = new LinkedHashMap(); - - // CraftBukkit start - public final CraftMapView mapView; - private CraftServer server; - private UUID uniqueId = null; - // CraftBukkit end - - public WorldMap(String s) { - super(s); - // CraftBukkit start - mapView = new CraftMapView(this); - server = (CraftServer) org.bukkit.Bukkit.getServer(); - // CraftBukkit end - } - - public void a(NBTTagCompound nbttagcompound) { - // CraftBukkit start - byte dimension = nbttagcompound.getByte("dimension"); - - if (dimension >= 10) { - long least = nbttagcompound.getLong("UUIDLeast"); - long most = nbttagcompound.getLong("UUIDMost"); - - if (least != 0L && most != 0L) { - this.uniqueId = new UUID(most, least); - - CraftWorld world = (CraftWorld) server.getWorld(this.uniqueId); - // Check if the stored world details are correct. - if (world == null) { - /* All Maps which do not have their valid world loaded are set to a dimension which hopefully won't be reached. - This is to prevent them being corrupted with the wrong map data. */ - dimension = 127; - } else { - dimension = (byte) world.getHandle().dimension; - } - } - } - - this.map = dimension; - // CraftBukkit end - this.centerX = nbttagcompound.getInt("xCenter"); - this.centerZ = nbttagcompound.getInt("zCenter"); - this.scale = nbttagcompound.getByte("scale"); - if (this.scale < 0) { - this.scale = 0; - } - - if (this.scale > 4) { - this.scale = 4; - } - - short short1 = nbttagcompound.getShort("width"); - short short2 = nbttagcompound.getShort("height"); - - if (short1 == 128 && short2 == 128) { - this.colors = nbttagcompound.getByteArray("colors"); - } else { - byte[] abyte = nbttagcompound.getByteArray("colors"); - - this.colors = new byte[16384]; - int i = (128 - short1) / 2; - int j = (128 - short2) / 2; - - for (int k = 0; k < short2; ++k) { - int l = k + j; - - if (l >= 0 || l < 128) { - for (int i1 = 0; i1 < short1; ++i1) { - int j1 = i1 + i; - - if (j1 >= 0 || j1 < 128) { - this.colors[j1 + l * 128] = abyte[i1 + k * short1]; - } - } - } - } - } - } - - public void b(NBTTagCompound nbttagcompound) { - // CraftBukkit start - if (this.map >= 10) { - if (this.uniqueId == null) { - for (org.bukkit.World world : server.getWorlds()) { - CraftWorld cWorld = (CraftWorld) world; - if (cWorld.getHandle().dimension == this.map) { - this.uniqueId = cWorld.getUID(); - break; - } - } - } - /* Perform a second check to see if a matching world was found, this is a necessary - change incase Maps are forcefully unlinked from a World and lack a UID.*/ - if (this.uniqueId != null) { - nbttagcompound.setLong("UUIDLeast", this.uniqueId.getLeastSignificantBits()); - nbttagcompound.setLong("UUIDMost", this.uniqueId.getMostSignificantBits()); - } - } - // CraftBukkit end - nbttagcompound.setByte("dimension", this.map); - nbttagcompound.setInt("xCenter", this.centerX); - nbttagcompound.setInt("zCenter", this.centerZ); - nbttagcompound.setByte("scale", this.scale); - nbttagcompound.setShort("width", (short) 128); - nbttagcompound.setShort("height", (short) 128); - nbttagcompound.setByteArray("colors", this.colors); - } - - public void a(EntityHuman entityhuman, ItemStack itemstack) { - if (!this.i.containsKey(entityhuman)) { - WorldMapHumanTracker worldmaphumantracker = new WorldMapHumanTracker(this, entityhuman); - - this.i.put(entityhuman, worldmaphumantracker); - this.f.add(worldmaphumantracker); - } - - if (!entityhuman.inventory.c(itemstack)) { - this.decorations.remove(entityhuman.getName()); - } - - 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) || itemstack.A())) { - if (!itemstack.A() && 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 (itemstack.A()) { - this.a(1, entityhuman.world, "frame-" + itemstack.B().getId(), (double) itemstack.B().x, (double) itemstack.B().z, (double) (itemstack.B().direction * 90)); - } - } - - 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().getDayTime() / 10L); - - b3 = (byte) (k * k * 34187121 + k * 121 >> 15 & 15); - } - } else { - if (Math.abs(f) >= 320.0F || Math.abs(f1) >= 320.0F) { - this.decorations.remove(s); - return; - } - - i = 6; - b3 = 0; - if (f <= (float) (-b2)) { - b0 = (byte) ((int) ((double) (b2 * 2) + 2.5D)); - } - - 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.decorations.put(s, new WorldMapDecoration(this, (byte) i, b0, b1, b3)); - } - - public byte[] getUpdatePacket(ItemStack itemstack, World world, EntityHuman 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.c(); - - 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; - } - - if (worldmaphumantracker.c[i] < 0 || worldmaphumantracker.c[i] < k) { - worldmaphumantracker.c[i] = k; - } - } - } - - 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 deleted file mode 100644 index ec708d1a..00000000 --- a/src/main/java/net/minecraft/server/WorldMapHumanTracker.java +++ /dev/null @@ -1,103 +0,0 @@ -package net.minecraft.server; - -import java.util.Iterator; - -public class WorldMapHumanTracker { - - public final EntityHuman trackee; - public int[] b; - public int[] c; - private int f; - private int g; - private byte[] h; - public int d; - private boolean i; - final WorldMap worldMap; - - public WorldMapHumanTracker(WorldMap worldmap, EntityHuman entityhuman) { - this.worldMap = worldmap; - this.b = new int[128]; - this.c = new int[128]; - this.trackee = entityhuman; - - for (int i = 0; i < this.b.length; ++i) { - this.b[i] = 0; - this.c[i] = 127; - } - } - - public byte[] a(ItemStack itemstack) { - 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; - - abyte[i * 3 + 1] = (byte) (cursor.getRawType() << 4 | cursor.getDirection() & 15); - abyte[i * 3 + 2] = (byte) cursor.getX(); - abyte[i * 3 + 3] = (byte) cursor.getY(); - } - // CraftBukkit end - - boolean flag = !itemstack.A(); - - 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; - } - - if (!flag) { - this.h = abyte; - return abyte; - } - } - - 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; - - j = this.b[i]; - byte[] abyte1 = new byte[l + 3]; - - 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; - } - } - - return null; - } - } -} diff --git a/src/main/java/net/minecraft/server/WorldNBTStorage.java b/src/main/java/net/minecraft/server/WorldNBTStorage.java deleted file mode 100644 index 93ff8d3b..00000000 --- a/src/main/java/net/minecraft/server/WorldNBTStorage.java +++ /dev/null @@ -1,310 +0,0 @@ -package net.minecraft.server; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -// CraftBukkit start -import java.util.UUID; - -import org.bukkit.craftbukkit.entity.CraftPlayer; -// CraftBukkit end - -public class WorldNBTStorage implements IDataManager, IPlayerFileData { - - private static final Logger a = LogManager.getLogger(); - private final File baseDir; - private final File playerDir; - private final File dataDir; - private final long sessionId = MinecraftServer.ar(); - private final String f; - private UUID uuid = null; // CraftBukkit - - public WorldNBTStorage(File file1, String s, boolean flag) { - this.baseDir = new File(file1, s); - this.baseDir.mkdirs(); - this.playerDir = new File(this.baseDir, "playerdata"); - this.dataDir = new File(this.baseDir, "data"); - this.dataDir.mkdirs(); - this.f = s; - if (flag) { - this.playerDir.mkdirs(); - } - - this.h(); - } - - private void h() { - try { - File file1 = new File(this.baseDir, "session.lock"); - DataOutputStream dataoutputstream = new DataOutputStream(new FileOutputStream(file1)); - - try { - dataoutputstream.writeLong(this.sessionId); - } finally { - dataoutputstream.close(); - } - } catch (IOException ioexception) { - ioexception.printStackTrace(); - throw new RuntimeException("Failed to check session lock, aborting"); - } - } - - public File getDirectory() { - return this.baseDir; - } - - public void checkSession() throws ExceptionWorldConflict { // CraftBukkit - throws ExceptionWorldConflict - try { - File file1 = new File(this.baseDir, "session.lock"); - DataInputStream datainputstream = new DataInputStream(new FileInputStream(file1)); - - try { - if (datainputstream.readLong() != this.sessionId) { - throw new ExceptionWorldConflict("The save is being accessed from another location, aborting"); - } - } finally { - datainputstream.close(); - } - } catch (IOException ioexception) { - throw new ExceptionWorldConflict("Failed to check session lock, aborting"); - } - } - - public IChunkLoader createChunkLoader(WorldProvider worldprovider) { - throw new RuntimeException("Old Chunk Storage is no longer supported."); - } - - public WorldData getWorldData() { - File file1 = new File(this.baseDir, "level.dat"); - NBTTagCompound nbttagcompound; - NBTTagCompound nbttagcompound1; - - if (file1.exists()) { - try { - nbttagcompound = NBTCompressedStreamTools.a((InputStream) (new FileInputStream(file1))); - nbttagcompound1 = nbttagcompound.getCompound("Data"); - return new WorldData(nbttagcompound1); - } catch (Exception exception) { - exception.printStackTrace(); - } - } - - file1 = new File(this.baseDir, "level.dat_old"); - if (file1.exists()) { - try { - nbttagcompound = NBTCompressedStreamTools.a((InputStream) (new FileInputStream(file1))); - nbttagcompound1 = nbttagcompound.getCompound("Data"); - return new WorldData(nbttagcompound1); - } catch (Exception exception1) { - exception1.printStackTrace(); - } - } - - return null; - } - - public void saveWorldData(WorldData worlddata, NBTTagCompound nbttagcompound) { - NBTTagCompound nbttagcompound1 = worlddata.a(nbttagcompound); - NBTTagCompound nbttagcompound2 = new NBTTagCompound(); - - nbttagcompound2.set("Data", nbttagcompound1); - - try { - File file1 = new File(this.baseDir, "level.dat_new"); - File file2 = new File(this.baseDir, "level.dat_old"); - File file3 = new File(this.baseDir, "level.dat"); - - NBTCompressedStreamTools.a(nbttagcompound2, (OutputStream) (new FileOutputStream(file1))); - if (file2.exists()) { - file2.delete(); - } - - file3.renameTo(file2); - if (file3.exists()) { - file3.delete(); - } - - file1.renameTo(file3); - if (file1.exists()) { - file1.delete(); - } - } catch (Exception exception) { - exception.printStackTrace(); - } - } - - public void saveWorldData(WorldData worlddata) { - NBTTagCompound nbttagcompound = worlddata.a(); - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - - nbttagcompound1.set("Data", nbttagcompound); - - try { - File file1 = new File(this.baseDir, "level.dat_new"); - File file2 = new File(this.baseDir, "level.dat_old"); - File file3 = new File(this.baseDir, "level.dat"); - - NBTCompressedStreamTools.a(nbttagcompound1, (OutputStream) (new FileOutputStream(file1))); - if (file2.exists()) { - file2.delete(); - } - - file3.renameTo(file2); - if (file3.exists()) { - file3.delete(); - } - - file1.renameTo(file3); - if (file1.exists()) { - file1.delete(); - } - } catch (Exception exception) { - exception.printStackTrace(); - } - } - - public void save(EntityHuman entityhuman) { - try { - NBTTagCompound nbttagcompound = new NBTTagCompound(); - - entityhuman.e(nbttagcompound); - File file1 = new File(this.playerDir, entityhuman.getUniqueID().toString() + ".dat.tmp"); - File file2 = new File(this.playerDir, entityhuman.getUniqueID().toString() + ".dat"); - - NBTCompressedStreamTools.a(nbttagcompound, (OutputStream) (new FileOutputStream(file1))); - if (file2.exists()) { - file2.delete(); - } - - file1.renameTo(file2); - } catch (Exception exception) { - a.warn("Failed to save player data for " + entityhuman.getName()); - } - } - - public NBTTagCompound load(EntityHuman entityhuman) { - NBTTagCompound nbttagcompound = null; - - try { - File file1 = new File(this.playerDir, entityhuman.getUniqueID().toString() + ".dat"); - - if (file1.exists() && file1.isFile()) { - nbttagcompound = NBTCompressedStreamTools.a((InputStream) (new FileInputStream(file1))); - } - } catch (Exception exception) { - a.warn("Failed to load player data for " + entityhuman.getName()); - } - - if (nbttagcompound != null) { - // CraftBukkit start - if (entityhuman instanceof EntityPlayer) { - CraftPlayer player = (CraftPlayer) entityhuman.bukkitEntity; - // Only update first played if it is older than the one we have - long modified = new File(this.playerDir, entityhuman.getUniqueID().toString() + ".dat").lastModified(); - if (modified < player.getFirstPlayed()) { - player.setFirstPlayed(modified); - } - } - // CraftBukkit end - - entityhuman.f(nbttagcompound); - } - - return nbttagcompound; - } - - public NBTTagCompound getPlayerData(String s) { - try { - File file1 = new File(this.playerDir, s + ".dat"); - - if (file1.exists()) { - return NBTCompressedStreamTools.a((InputStream) (new FileInputStream(file1))); - } - } catch (Exception exception) { - a.warn("Failed to load player data for " + s); - } - - return null; - } - - public IPlayerFileData getPlayerFileData() { - return this; - } - - public String[] getSeenPlayers() { - String[] astring = this.playerDir.list(); - - for (int i = 0; i < astring.length; ++i) { - if (astring[i].endsWith(".dat")) { - astring[i] = astring[i].substring(0, astring[i].length() - 4); - } - } - - return astring; - } - - public void a() {} - - public File getDataFile(String s) { - return new File(this.dataDir, s + ".dat"); - } - - public String g() { - return this.f; - } - - // CraftBukkit start - public UUID getUUID() { - if (uuid != null) return uuid; - File file1 = new File(this.baseDir, "uid.dat"); - if (file1.exists()) { - DataInputStream dis = null; - try { - dis = new DataInputStream(new FileInputStream(file1)); - return uuid = new UUID(dis.readLong(), dis.readLong()); - } catch (IOException ex) { - a.warn("Failed to read " + file1 + ", generating new random UUID", ex); - } finally { - if (dis != null) { - try { - dis.close(); - } catch (IOException ex) { - // NOOP - } - } - } - } - uuid = UUID.randomUUID(); - DataOutputStream dos = null; - try { - dos = new DataOutputStream(new FileOutputStream(file1)); - dos.writeLong(uuid.getMostSignificantBits()); - dos.writeLong(uuid.getLeastSignificantBits()); - } catch (IOException ex) { - a.warn("Failed to write " + file1, ex); - } finally { - if (dos != null) { - try { - dos.close(); - } catch (IOException ex) { - // NOOP - } - } - } - return uuid; - } - - public File getPlayerDir() { - return playerDir; - } - // CraftBukkit end -} diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java deleted file mode 100644 index ba7965db..00000000 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ /dev/null @@ -1,1006 +0,0 @@ -package net.minecraft.server; - -import java.util.ArrayList; -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.TreeSet; - -import net.minecraft.util.com.google.common.collect.Lists; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -// CraftBukkit start -import org.bukkit.WeatherType; -import org.bukkit.block.BlockState; -import org.bukkit.craftbukkit.util.LongHash; - -import org.bukkit.event.block.BlockFormEvent; -import org.bukkit.event.weather.LightningStrikeEvent; -import org.bukkit.event.weather.ThunderChangeEvent; -import org.bukkit.event.weather.WeatherChangeEvent; -// CraftBukkit end - -public class WorldServer extends World { - - private static final Logger a = LogManager.getLogger(); - private final MinecraftServer server; - public EntityTracker tracker; // CraftBukkit - private final -> public - private final PlayerChunkMap manager; - private Set M; - private TreeSet N; - public ChunkProviderServer chunkProviderServer; - public boolean savingDisabled; - private boolean O; - private int emptyTime; - private final PortalTravelAgent Q; - private final SpawnerCreature R = new SpawnerCreature(); - private BlockActionDataList[] S = new BlockActionDataList[] { new BlockActionDataList((BananaAPI) null), new BlockActionDataList((BananaAPI) null)}; - private int T; - private static final StructurePieceTreasure[] U = new StructurePieceTreasure[] { new StructurePieceTreasure(Items.STICK, 0, 1, 3, 10), new StructurePieceTreasure(Item.getItemOf(Blocks.WOOD), 0, 1, 3, 10), new StructurePieceTreasure(Item.getItemOf(Blocks.LOG), 0, 1, 3, 10), new StructurePieceTreasure(Items.STONE_AXE, 0, 1, 1, 3), new StructurePieceTreasure(Items.WOOD_AXE, 0, 1, 1, 5), new StructurePieceTreasure(Items.STONE_PICKAXE, 0, 1, 1, 3), new StructurePieceTreasure(Items.WOOD_PICKAXE, 0, 1, 1, 5), new StructurePieceTreasure(Items.APPLE, 0, 2, 3, 5), new StructurePieceTreasure(Items.BREAD, 0, 2, 3, 3), new StructurePieceTreasure(Item.getItemOf(Blocks.LOG2), 0, 1, 3, 10)}; - private List V = new ArrayList(); - private IntHashMap entitiesById; - - // CraftBukkit start - public final int dimension; - - // Add env and gen to constructor - public WorldServer(MinecraftServer minecraftserver, IDataManager idatamanager, String s, int i, WorldSettings worldsettings, MethodProfiler methodprofiler, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen) { - super(idatamanager, s, worldsettings, WorldProvider.byDimension(env.getId()), methodprofiler, gen, env); - this.dimension = i; - this.pvpMode = minecraftserver.getPvP(); - // CraftBukkit end - this.server = minecraftserver; - this.tracker = new EntityTracker(this); - this.manager = new PlayerChunkMap(this); - if (this.entitiesById == null) { - this.entitiesById = new IntHashMap(); - } - - if (this.M == null) { - this.M = new HashSet(); - } - - if (this.N == null) { - this.N = new TreeSet(); - } - - this.Q = new org.bukkit.craftbukkit.CraftTravelAgent(this); // CraftBukkit - this.scoreboard = new ScoreboardServer(minecraftserver); - PersistentScoreboard persistentscoreboard = (PersistentScoreboard) this.worldMaps.get(PersistentScoreboard.class, "scoreboard"); - - if (persistentscoreboard == null) { - persistentscoreboard = new PersistentScoreboard(); - this.worldMaps.a("scoreboard", persistentscoreboard); - } - - persistentscoreboard.a(this.scoreboard); - ((ScoreboardServer) this.scoreboard).a(persistentscoreboard); - } - - // CraftBukkit start - @Override - public TileEntity getTileEntity(int i, int j, int k) { - TileEntity result = super.getTileEntity(i, j, k); - Block type = getType(i, j, k); - - if (type == Blocks.CHEST) { - if (!(result instanceof TileEntityChest)) { - result = fixTileEntity(i, j, k, type, result); - } - } else if (type == Blocks.FURNACE) { - if (!(result instanceof TileEntityFurnace)) { - result = fixTileEntity(i, j, k, type, result); - } - } else if (type == Blocks.DROPPER) { - if (!(result instanceof TileEntityDropper)) { - result = fixTileEntity(i, j, k, type, result); - } - } else if (type == Blocks.DISPENSER) { - if (!(result instanceof TileEntityDispenser)) { - result = fixTileEntity(i, j, k, type, result); - } - } else if (type == Blocks.JUKEBOX) { - if (!(result instanceof TileEntityRecordPlayer)) { - result = fixTileEntity(i, j, k, type, result); - } - } else if (type == Blocks.NOTE_BLOCK) { - if (!(result instanceof TileEntityNote)) { - result = fixTileEntity(i, j, k, type, result); - } - } else if (type == Blocks.MOB_SPAWNER) { - if (!(result instanceof TileEntityMobSpawner)) { - result = fixTileEntity(i, j, k, type, result); - } - } else if ((type == Blocks.SIGN_POST) || (type == Blocks.WALL_SIGN)) { - if (!(result instanceof TileEntitySign)) { - result = fixTileEntity(i, j, k, type, result); - } - } else if (type == Blocks.ENDER_CHEST) { - if (!(result instanceof TileEntityEnderChest)) { - result = fixTileEntity(i, j, k, type, result); - } - } else if (type == Blocks.BREWING_STAND) { - if (!(result instanceof TileEntityBrewingStand)) { - result = fixTileEntity(i, j, k, type, result); - } - } else if (type == Blocks.BEACON) { - if (!(result instanceof TileEntityBeacon)) { - result = fixTileEntity(i, j, k, type, result); - } - } else if (type == Blocks.HOPPER) { - if (!(result instanceof TileEntityHopper)) { - result = fixTileEntity(i, j, k, type, result); - } - } - - return result; - } - - private TileEntity fixTileEntity(int x, int y, int z, Block type, TileEntity found) { - this.getServer().getLogger().severe("Block at " + x + "," + y + "," + z + " is " + org.bukkit.Material.getMaterial(Block.getId(type)).toString() + " but has " + found + ". " - + "Bukkit will attempt to fix this, but there may be additional damage that we cannot recover."); - - if (type instanceof IContainer) { - TileEntity replacement = ((IContainer) type).a(this, this.getData(x, y, z)); - replacement.world = this; - this.setTileEntity(x, y, z, replacement); - return replacement; - } else { - this.getServer().getLogger().severe("Don't know how to fix for this type... Can't do anything! :("); - return found; - } - } - - private boolean canSpawn(int x, int z) { - if (this.generator != null) { - return this.generator.canSpawn(this.getWorld(), x, z); - } else { - return this.worldProvider.canSpawn(x, z); - } - } - // CraftBukkit end - - public void doTick() { - super.doTick(); - if (this.getWorldData().isHardcore() && this.difficulty != EnumDifficulty.HARD) { - this.difficulty = EnumDifficulty.HARD; - } - - this.worldProvider.e.b(); - if (this.everyoneDeeplySleeping()) { - if (this.getGameRules().getBoolean("doDaylightCycle")) { - long i = this.worldData.getDayTime() + 24000L; - - this.worldData.setDayTime(i - i % 24000L); - } - - this.d(); - } - - 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.getGameRules().getBoolean("doMobSpawning") && (this.allowMonsters || this.allowAnimals) && (this instanceof WorldServer && this.players.size() > 0)) { - this.R.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.j) { - this.j = j; - } - - this.worldData.setTime(this.worldData.getTime() + 1L); - if (this.getGameRules().getBoolean("doDaylightCycle")) { - this.worldData.setDayTime(this.worldData.getDayTime() + 1L); - } - - this.methodProfiler.c("tickPending"); - this.a(false); - this.methodProfiler.c("tickBlocks"); - this.g(); - this.methodProfiler.c("chunkMap"); - this.manager.flush(); - this.methodProfiler.c("village"); - this.villages.tick(); - this.siegeManager.a(); - this.methodProfiler.c("portalForcer"); - this.Q.a(this.getTime()); - this.methodProfiler.b(); - this.Z(); - - this.getWorld().processChunkGC(); // CraftBukkit - } - - public BiomeMeta a(EnumCreatureType enumcreaturetype, int i, int j, int k) { - List list = this.L().getMobsFor(enumcreaturetype, i, j, k); - - return list != null && !list.isEmpty() ? (BiomeMeta) WeightedRandom.a(this.random, (Collection) list) : null; - } - - public void everyoneSleeping() { - 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.O = false; - break; - } - } - } - - protected void d() { - this.O = false; - Iterator iterator = this.players.iterator(); - - while (iterator.hasNext()) { - EntityHuman entityhuman = (EntityHuman) iterator.next(); - - if (entityhuman.isSleeping()) { - entityhuman.a(false, false, true); - } - } - - this.Y(); - } - - private void Y() { - // CraftBukkit start - WeatherChangeEvent weather = new WeatherChangeEvent(this.getWorld(), false); - this.getServer().getPluginManager().callEvent(weather); - - ThunderChangeEvent thunder = new ThunderChangeEvent(this.getWorld(), false); - this.getServer().getPluginManager().callEvent(thunder); - if (!weather.isCancelled()) { - this.worldData.setWeatherDuration(0); - this.worldData.setStorm(false); - } - if (!thunder.isCancelled()) { - this.worldData.setThunderDuration(0); - this.worldData.setThundering(false); - } - // CraftBukkit end - } - - public boolean everyoneDeeplySleeping() { - 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 - boolean foundActualSleepers = false; - - EntityHuman entityhuman; - - do { - if (!iterator.hasNext()) { - return foundActualSleepers; // CraftBukkit - } - - entityhuman = (EntityHuman) iterator.next(); - // CraftBukkit start - if (entityhuman.isDeeplySleeping()) { - foundActualSleepers = true; - } - } while (entityhuman.isDeeplySleeping() || entityhuman.fauxSleeping); - // CraftBukkit end - - return false; - } else { - return false; - } - } - - protected void g() { - super.g(); - int i = 0; - int j = 0; - // CraftBukkit start - // Iterator iterator = this.chunkTickList.iterator(); - - for (long chunkCoord : this.chunkTickList.popAll()) { - // ChunkCoordIntPair chunkcoordintpair = (ChunkCoordIntPair) iterator.next(); - int chunkX = LongHash.msw(chunkCoord); - int chunkZ = LongHash.lsw(chunkCoord); - int k = chunkX * 16; - int l = chunkZ * 16; - - this.methodProfiler.a("getChunk"); - Chunk chunk = this.getChunkAt(chunkX, chunkZ); - // CraftBukkit end - - this.a(k, l, chunk); - this.methodProfiler.c("tickChunk"); - chunk.b(false); - this.methodProfiler.c("thunder"); - int i1; - int j1; - int k1; - int l1; - - if (this.random.nextInt(100000) == 0 && this.Q() && this.P()) { - this.k = this.k * 3 + 1013904223; - i1 = this.k >> 2; - j1 = k + (i1 & 15); - k1 = l + (i1 >> 8 & 15); - l1 = this.h(j1, k1); - if (this.isRainingAt(j1, l1, k1)) { - this.strikeLightning(new EntityLightning(this, (double) j1, (double) l1, (double) k1)); - } - } - - this.methodProfiler.c("iceandsnow"); - if (this.random.nextInt(16) == 0) { - this.k = this.k * 3 + 1013904223; - i1 = this.k >> 2; - j1 = i1 & 15; - k1 = i1 >> 8 & 15; - l1 = this.h(j1 + k, k1 + l); - if (this.s(j1 + k, l1 - 1, k1 + l)) { - // CraftBukkit start - BlockState blockState = this.getWorld().getBlockAt(j1 + k, l1 - 1, k1 + l).getState(); - blockState.setTypeId(Block.getId(Blocks.ICE)); - - BlockFormEvent iceBlockForm = new BlockFormEvent(blockState.getBlock(), blockState); - this.getServer().getPluginManager().callEvent(iceBlockForm); - if (!iceBlockForm.isCancelled()) { - blockState.update(true); - } - // CraftBukkit end - } - - if (this.Q() && this.e(j1 + k, l1, k1 + l, true)) { - // CraftBukkit start - BlockState blockState = this.getWorld().getBlockAt(j1 + k, l1, k1 + l).getState(); - blockState.setTypeId(Block.getId(Blocks.SNOW)); - - BlockFormEvent snow = new BlockFormEvent(blockState.getBlock(), blockState); - this.getServer().getPluginManager().callEvent(snow); - if (!snow.isCancelled()) { - blockState.update(true); - } - // CraftBukkit end - } - - if (this.Q()) { - BiomeBase biomebase = this.getBiome(j1 + k, k1 + l); - - if (biomebase.e()) { - this.getType(j1 + k, l1 - 1, k1 + l).l(this, j1 + k, l1 - 1, k1 + l); - } - } - } - - this.methodProfiler.c("tickBlocks"); - ChunkSection[] achunksection = chunk.getSections(); - - j1 = achunksection.length; - - for (k1 = 0; k1 < j1; ++k1) { - ChunkSection chunksection = achunksection[k1]; - - if (chunksection != null && chunksection.shouldTick()) { - for (int i2 = 0; i2 < 3; ++i2) { - this.k = this.k * 3 + 1013904223; - int j2 = this.k >> 2; - int k2 = j2 & 15; - int l2 = j2 >> 8 & 15; - int i3 = j2 >> 16 & 15; - - ++j; - Block block = chunksection.getTypeId(k2, i3, l2); - - if (block.isTicking()) { - ++i; - block.a(this, k2 + k, i3 + chunksection.getYPosition(), l2 + l, this.random); - } - } - } - } - - this.methodProfiler.b(); - } - } - - public boolean a(int i, int j, int k, Block block) { - NextTickListEntry nextticklistentry = new NextTickListEntry(i, j, k, block); - - return this.V.contains(nextticklistentry); - } - - public void a(int i, int j, int k, Block block, int l) { - this.a(i, j, k, block, l, 0); - } - - public void a(int i, int j, int k, Block block, int l, int i1) { - NextTickListEntry nextticklistentry = new NextTickListEntry(i, j, k, block); - byte b0 = 0; - - if (this.d && block.getMaterial() != Material.AIR) { - if (block.L()) { - b0 = 8; - if (this.b(nextticklistentry.a - b0, nextticklistentry.b - b0, nextticklistentry.c - b0, nextticklistentry.a + b0, nextticklistentry.b + b0, nextticklistentry.c + b0)) { - Block block1 = this.getType(nextticklistentry.a, nextticklistentry.b, nextticklistentry.c); - - if (block1.getMaterial() != Material.AIR && block1 == nextticklistentry.a()) { - block1.a(this, nextticklistentry.a, nextticklistentry.b, nextticklistentry.c, this.random); - } - } - - return; - } - - l = 1; - } - - if (this.b(i - b0, j - b0, k - b0, i + b0, j + b0, k + b0)) { - if (block.getMaterial() != Material.AIR) { - nextticklistentry.a((long) l + this.worldData.getTime()); - nextticklistentry.a(i1); - } - - if (!this.M.contains(nextticklistentry)) { - this.M.add(nextticklistentry); - this.N.add(nextticklistentry); - } - } - } - - public void b(int i, int j, int k, Block block, int l, int i1) { - NextTickListEntry nextticklistentry = new NextTickListEntry(i, j, k, block); - - nextticklistentry.a(i1); - if (block.getMaterial() != Material.AIR) { - nextticklistentry.a((long) l + this.worldData.getTime()); - } - - if (!this.M.contains(nextticklistentry)) { - this.M.add(nextticklistentry); - this.N.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++ >= 1200) { - return; - } - } else { - this.i(); - } - - super.tickEntities(); - } - - public void i() { - this.emptyTime = 0; - } - - public boolean a(boolean flag) { - int i = this.N.size(); - - if (i != this.M.size()) { - throw new IllegalStateException("TickNextTick list out of synch"); - } else { - if (i > 1000) { - // CraftBukkit start - If the server has too much to process over time, try to alleviate that - if (i > 20 * 1000) { - i = i / 20; - } else { - i = 1000; - } - // CraftBukkit end - } - - this.methodProfiler.a("cleaning"); - - NextTickListEntry nextticklistentry; - - for (int j = 0; j < i; ++j) { - nextticklistentry = (NextTickListEntry) this.N.first(); - if (!flag && nextticklistentry.d > this.worldData.getTime()) { - break; - } - - this.N.remove(nextticklistentry); - this.M.remove(nextticklistentry); - this.V.add(nextticklistentry); - } - - this.methodProfiler.b(); - this.methodProfiler.a("ticking"); - Iterator iterator = this.V.iterator(); - - while (iterator.hasNext()) { - nextticklistentry = (NextTickListEntry) iterator.next(); - iterator.remove(); - byte b0 = 0; - - if (this.b(nextticklistentry.a - b0, nextticklistentry.b - b0, nextticklistentry.c - b0, nextticklistentry.a + b0, nextticklistentry.b + b0, nextticklistentry.c + b0)) { - Block block = this.getType(nextticklistentry.a, nextticklistentry.b, nextticklistentry.c); - - if (block.getMaterial() != Material.AIR && Block.a(block, nextticklistentry.a())) { - try { - block.a(this, nextticklistentry.a, nextticklistentry.b, nextticklistentry.c, this.random); - } catch (Throwable throwable) { - CrashReport crashreport = CrashReport.a(throwable, "Exception while ticking a block"); - CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Block being ticked"); - - int k; - - try { - k = this.getData(nextticklistentry.a, nextticklistentry.b, nextticklistentry.c); - } catch (Throwable throwable1) { - k = -1; - } - - CrashReportSystemDetails.a(crashreportsystemdetails, nextticklistentry.a, nextticklistentry.b, nextticklistentry.c, block, k); - throw new ReportedException(crashreport); - } - } - } else { - this.a(nextticklistentry.a, nextticklistentry.b, nextticklistentry.c, nextticklistentry.a(), 0); - } - } - - this.methodProfiler.b(); - this.V.clear(); - return !this.N.isEmpty(); - } - } - - public List a(Chunk chunk, boolean flag) { - ArrayList arraylist = null; - ChunkCoordIntPair chunkcoordintpair = chunk.l(); - int i = (chunkcoordintpair.x << 4) - 2; - int j = i + 16 + 2; - int k = (chunkcoordintpair.z << 4) - 2; - int l = k + 16 + 2; - - for (int i1 = 0; i1 < 2; ++i1) { - Iterator iterator; - - if (i1 == 0) { - iterator = this.N.iterator(); - } else { - iterator = this.V.iterator(); - if (!this.V.isEmpty()) { - a.debug("toBeTicked = " + this.V.size()); - } - } - - while (iterator.hasNext()) { - NextTickListEntry nextticklistentry = (NextTickListEntry) iterator.next(); - - if (nextticklistentry.a >= i && nextticklistentry.a < j && nextticklistentry.c >= k && nextticklistentry.c < l) { - if (flag) { - this.M.remove(nextticklistentry); - iterator.remove(); - } - - if (arraylist == null) { - arraylist = new ArrayList(); - } - - arraylist.add(nextticklistentry); - } - } - } - - return arraylist; - } - - /* CraftBukkit start - We prevent spawning in general, so this butchering is not needed - public void entityJoinedWorld(Entity entity, boolean flag) { - if (!this.server.getSpawnAnimals() && (entity instanceof EntityAnimal || entity instanceof EntityWaterAnimal)) { - entity.die(); - } - - if (!this.server.getSpawnNPCs() && entity instanceof NPC) { - entity.die(); - } - - super.entityJoinedWorld(entity, flag); - } - // CraftBukkit end */ - - protected IChunkProvider j() { - IChunkLoader ichunkloader = this.dataManager.createChunkLoader(this.worldProvider); - - // CraftBukkit start - org.bukkit.craftbukkit.generator.InternalChunkGenerator gen; - - if (this.generator != null) { - gen = new org.bukkit.craftbukkit.generator.CustomChunkGenerator(this, this.getSeed(), this.generator); - } else if (this.worldProvider instanceof WorldProviderHell) { - gen = new org.bukkit.craftbukkit.generator.NetherChunkGenerator(this, this.getSeed()); - } else if (this.worldProvider instanceof WorldProviderTheEnd) { - gen = new org.bukkit.craftbukkit.generator.SkyLandsChunkGenerator(this, this.getSeed()); - } else { - gen = new org.bukkit.craftbukkit.generator.NormalChunkGenerator(this, this.getSeed()); - } - - this.chunkProviderServer = new ChunkProviderServer(this, ichunkloader, gen); - // CraftBukkit end - - return this.chunkProviderServer; - } - - public List getTileEntities(int i, int j, int k, int l, int i1, int j1) { - ArrayList arraylist = new ArrayList(); - - // CraftBukkit start - Get tile entities from chunks instead of world - for (int chunkX = (i >> 4); chunkX <= ((l - 1) >> 4); chunkX++) { - for (int chunkZ = (k >> 4); chunkZ <= ((j1 - 1) >> 4); chunkZ++) { - Chunk chunk = getChunkAt(chunkX, chunkZ); - if (chunk == null) { - continue; - } - - for (Object te : chunk.tileEntities.values()) { - TileEntity tileentity = (TileEntity) te; - if ((tileentity.x >= i) && (tileentity.y >= j) && (tileentity.z >= k) && (tileentity.x < l) && (tileentity.y < i1) && (tileentity.z < j1)) { - arraylist.add(tileentity); - } - } - } - } - // CraftBukkit end - - return arraylist; - } - - public boolean a(EntityHuman entityhuman, int i, int j, int k) { - return !this.server.a(this, i, j, k, entityhuman); - } - - protected void a(WorldSettings worldsettings) { - if (this.entitiesById == null) { - this.entitiesById = new IntHashMap(); - } - - if (this.M == null) { - this.M = new HashSet(); - } - - if (this.N == null) { - this.N = new TreeSet(); - } - - this.b(worldsettings); - super.a(worldsettings); - } - - protected void b(WorldSettings worldsettings) { - if (!this.worldProvider.e()) { - this.worldData.setSpawn(0, this.worldProvider.getSeaLevel(), 0); - } else { - this.isLoading = true; - WorldChunkManager worldchunkmanager = this.worldProvider.e; - List list = worldchunkmanager.a(); - Random random = new Random(this.getSeed()); - ChunkPosition chunkposition = worldchunkmanager.a(0, 0, 256, list, random); - int i = 0; - int j = this.worldProvider.getSeaLevel(); - int k = 0; - - // CraftBukkit start - if (this.generator != null) { - Random rand = new Random(this.getSeed()); - org.bukkit.Location spawn = this.generator.getFixedSpawnLocation(((WorldServer) this).getWorld(), rand); - - if (spawn != null) { - if (spawn.getWorld() != ((WorldServer) this).getWorld()) { - throw new IllegalStateException("Cannot set spawn point for " + this.worldData.getName() + " to be in another world (" + spawn.getWorld().getName() + ")"); - } else { - this.worldData.setSpawn(spawn.getBlockX(), spawn.getBlockY(), spawn.getBlockZ()); - this.isLoading = false; - return; - } - } - } - // CraftBukkit end - - if (chunkposition != null) { - i = chunkposition.x; - k = chunkposition.z; - } else { - a.warn("Unable to find spawn biome"); - } - - int l = 0; - - 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; - if (l == 1000) { - break; - } - } - - this.worldData.setSpawn(i, j, k); - this.isLoading = false; - if (worldsettings.c()) { - this.k(); - } - } - } - - protected void k() { - WorldGenBonusChest worldgenbonuschest = new WorldGenBonusChest(U, 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.i(j, k) + 1; - - if (worldgenbonuschest.generate(this, this.random, j, l, k)) { - break; - } - } - } - - public ChunkCoordinates getDimensionSpawn() { - return this.worldProvider.h(); - } - - public void save(boolean flag, IProgressUpdate iprogressupdate) throws ExceptionWorldConflict { // CraftBukkit - added throws - if (this.chunkProvider.canSave()) { - if (iprogressupdate != null) { - iprogressupdate.a("Saving level"); - } - - this.a(); - if (iprogressupdate != null) { - iprogressupdate.c("Saving chunks"); - } - - this.chunkProvider.saveChunks(flag, iprogressupdate); - // CraftBukkit - ArrayList -> Collection - Collection arraylist = this.chunkProviderServer.a(); - Iterator iterator = arraylist.iterator(); - - while (iterator.hasNext()) { - Chunk chunk = (Chunk) iterator.next(); - - if (chunk != null && !this.manager.a(chunk.locX, chunk.locZ)) { - this.chunkProviderServer.queueUnload(chunk.locX, chunk.locZ); - } - } - } - } - - public void flushSave() { - if (this.chunkProvider.canSave()) { - this.chunkProvider.c(); - } - } - - protected void a() throws ExceptionWorldConflict { // CraftBukkit - added throws - this.G(); - this.dataManager.saveWorldData(this.worldData, this.server.getPlayerList().t()); - // CraftBukkit start - save worldMaps once, rather than once per shared world - if (!(this instanceof SecondaryWorldServer)) { - this.worldMaps.a(); - } - // CraftBukkit end - } - - protected void a(Entity entity) { - super.a(entity); - this.entitiesById.a(entity.getId(), entity); - Entity[] aentity = entity.at(); - - if (aentity != null) { - for (int i = 0; i < aentity.length; ++i) { - this.entitiesById.a(aentity[i].getId(), aentity[i]); - } - } - } - - protected void b(Entity entity) { - super.b(entity); - this.entitiesById.d(entity.getId()); - Entity[] aentity = entity.at(); - - if (aentity != null) { - for (int i = 0; i < aentity.length; ++i) { - this.entitiesById.d(aentity[i].getId()); - } - } - } - - public Entity getEntity(int i) { - return (Entity) this.entitiesById.get(i); - } - - public boolean strikeLightning(Entity entity) { - // CraftBukkit start - LightningStrikeEvent lightning = new LightningStrikeEvent(this.getWorld(), (org.bukkit.entity.LightningStrike) entity.getBukkitEntity()); - this.getServer().getPluginManager().callEvent(lightning); - - if (lightning.isCancelled()) { - return false; - } - - if (super.strikeLightning(entity)) { - this.server.getPlayerList().sendPacketNearby(entity.locX, entity.locY, entity.locZ, 512.0D, this.dimension, new PacketPlayOutSpawnEntityWeather(entity)); - // CraftBukkit end - return true; - } else { - return false; - } - } - - public void broadcastEntityEffect(Entity entity, byte b0) { - this.getTracker().sendPacketToEntity(entity, new PacketPlayOutEntityStatus(entity, b0)); - } - - 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, flag1); - - if (explosion.wasCanceled) { - return explosion; - } - - /* Remove - explosion.a = flag; - explosion.b = flag1; - explosion.a(); - explosion.a(false); - */ - // CraftBukkit end - TODO: Check if explosions are still properly implemented - - if (!flag1) { - explosion.blocks.clear(); - } - - Iterator iterator = this.players.iterator(); - - while (iterator.hasNext()) { - EntityHuman entityhuman = (EntityHuman) iterator.next(); - - if (entityhuman.e(d0, d1, d2) < 4096.0D) { - ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutExplosion(d0, d1, d2, f, explosion.blocks, (Vec3D) explosion.b().get(entityhuman))); - } - } - - return explosion; - } - - public void playBlockAction(int i, int j, int k, Block block, int l, int i1) { - BlockActionData blockactiondata = new BlockActionData(i, j, k, block, l, i1); - Iterator iterator = this.S[this.T].iterator(); - - BlockActionData blockactiondata1; - - do { - if (!iterator.hasNext()) { - this.S[this.T].add(blockactiondata); - return; - } - - blockactiondata1 = (BlockActionData) iterator.next(); - } while (!blockactiondata1.equals(blockactiondata)); - - } - - private void Z() { - while (!this.S[this.T].isEmpty()) { - int i = this.T; - - this.T ^= 1; - Iterator iterator = this.S[i].iterator(); - - while (iterator.hasNext()) { - BlockActionData blockactiondata = (BlockActionData) iterator.next(); - - if (this.a(blockactiondata)) { - // CraftBukkit - this.worldProvider.dimension -> this.dimension - this.server.getPlayerList().sendPacketNearby((double) blockactiondata.a(), (double) blockactiondata.b(), (double) blockactiondata.c(), 64.0D, this.dimension, new PacketPlayOutBlockAction(blockactiondata.a(), blockactiondata.b(), blockactiondata.c(), blockactiondata.f(), blockactiondata.d(), blockactiondata.e())); - } - } - - this.S[i].clear(); - } - } - - private boolean a(BlockActionData blockactiondata) { - Block block = this.getType(blockactiondata.a(), blockactiondata.b(), blockactiondata.c()); - - return block == blockactiondata.f() ? block.a(this, blockactiondata.a(), blockactiondata.b(), blockactiondata.c(), blockactiondata.d(), blockactiondata.e()) : false; - } - - public void saveLevel() { - this.dataManager.a(); - } - - protected void o() { - boolean flag = this.Q(); - - super.o(); - /* CraftBukkit start - if (this.m != this.n) { - this.server.getPlayerList().a(new PacketPlayOutGameStateChange(7, this.n), this.worldProvider.dimension); - } - - if (this.o != this.p) { - this.server.getPlayerList().a(new PacketPlayOutGameStateChange(8, this.p), this.worldProvider.dimension); - } - - if (flag != this.Q()) { - if (flag) { - this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(2, 0.0F)); - } else { - this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(1, 0.0F)); - } - - this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(7, this.n)); - this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(8, this.p)); - } - // */ - if (flag != this.Q()) { - // Only send weather packets to those affected - for (int i = 0; i < this.players.size(); ++i) { - if (((EntityPlayer) this.players.get(i)).world == this) { - ((EntityPlayer) this.players.get(i)).setPlayerWeather((!flag ? WeatherType.DOWNFALL : WeatherType.CLEAR), false); - } - } - // CraftBukkit end - } - } - - protected int p() { - return this.server.getPlayerList().s(); - } - - public MinecraftServer getMinecraftServer() { - return this.server; - } - - public EntityTracker getTracker() { - return this.tracker; - } - - public PlayerChunkMap getPlayerChunkMap() { - return this.manager; - } - - public PortalTravelAgent getTravelAgent() { - return this.Q; - } - - public void a(String s, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6) { - PacketPlayOutWorldParticles packetplayoutworldparticles = new PacketPlayOutWorldParticles(s, (float) d0, (float) d1, (float) d2, (float) d3, (float) d4, (float) d5, (float) d6, i); - - for (int j = 0; j < this.players.size(); ++j) { - EntityPlayer entityplayer = (EntityPlayer) this.players.get(j); - ChunkCoordinates chunkcoordinates = entityplayer.getChunkCoordinates(); - double d7 = d0 - (double) chunkcoordinates.x; - double d8 = d1 - (double) chunkcoordinates.y; - double d9 = d2 - (double) chunkcoordinates.z; - double d10 = d7 * d7 + d8 * d8 + d9 * d9; - - if (d10 <= 256.0D) { - entityplayer.playerConnection.sendPacket(packetplayoutworldparticles); - } - } - } - - // CraftBukkit start - Helper method - public int getTypeId(int x, int y, int z) { - return Block.getId(getType(x, y, z)); - } - // CraftBukkit end -} |