diff --git a/src/pocketmine/block/Block.php b/src/pocketmine/block/Block.php index a1f574598..2bfc61b7d 100644 --- a/src/pocketmine/block/Block.php +++ b/src/pocketmine/block/Block.php @@ -187,7 +187,7 @@ class Block extends Position implements Metadatable{ const ENCHANTING_TABLE = 116; const ENCHANT_TABLE = 116; const ENCHANTMENT_TABLE = 116; - + const BREWING_STAND = 117; const END_PORTAL_FRAME = 120; const END_STONE = 121; @@ -205,11 +205,12 @@ class Block extends Position implements Metadatable{ const COBBLE_WALL = 139; const STONE_WALL = 139; const COBBLESTONE_WALL = 139; - + const FLOWER_POT_BLOCK = 140; const CARROT_BLOCK = 141; const POTATO_BLOCK = 142; const ANVIL = 145; + const TRAPPED_CHEST = 146; const REDSTONE_BLOCK = 152; @@ -236,11 +237,12 @@ class Block extends Position implements Metadatable{ const DARK_OAK_WOOD_STAIRS = 164; const DARK_OAK_WOODEN_STAIRS = 164; + const IRON_TRAPDOOR = 167; const HAY_BALE = 170; const CARPET = 171; const HARDENED_CLAY = 172; const COAL_BLOCK = 173; - + const PACKED_ICE = 174; const DOUBLE_PLANT = 175; const FENCE_GATE_SPRUCE = 183; @@ -416,7 +418,7 @@ class Block extends Position implements Metadatable{ self::$list[self::NETHER_BRICKS_STAIRS] = NetherBrickStairs::class; self::$list[self::ENCHANTING_TABLE] = EnchantingTable::class; - + self::$list[self::BREWING_STAND] = BrewingStand::class; self::$list[self::END_PORTAL_FRAME] = EndPortalFrame::class; self::$list[self::END_STONE] = EndStone::class; self::$list[self::SANDSTONE_STAIRS] = SandstoneStairs::class; @@ -427,11 +429,11 @@ class Block extends Position implements Metadatable{ self::$list[self::BIRCH_WOOD_STAIRS] = BirchWoodStairs::class; self::$list[self::JUNGLE_WOOD_STAIRS] = JungleWoodStairs::class; self::$list[self::STONE_WALL] = StoneWall::class; - + self::$list[self::FLOWER_POT_BLOCK] = FlowerPot::class; self::$list[self::CARROT_BLOCK] = Carrot::class; self::$list[self::POTATO_BLOCK] = Potato::class; self::$list[self::ANVIL] = Anvil::class; - + self::$list[self::TRAPPED_CHEST] = TrappedChest::class; self::$list[self::REDSTONE_BLOCK] = Redstone::class; self::$list[self::QUARTZ_BLOCK] = Quartz::class; @@ -445,11 +447,12 @@ class Block extends Position implements Metadatable{ self::$list[self::ACACIA_WOOD_STAIRS] = AcaciaWoodStairs::class; self::$list[self::DARK_OAK_WOOD_STAIRS] = DarkOakWoodStairs::class; + self::$list[self::IRON_TRAPDOOR] = IronTrapdoor::class; self::$list[self::HAY_BALE] = HayBale::class; self::$list[self::CARPET] = Carpet::class; self::$list[self::HARDENED_CLAY] = HardenedClay::class; self::$list[self::COAL_BLOCK] = Coal::class; - + self::$list[self::PACKED_ICE] = PackedIce::class; self::$list[self::DOUBLE_PLANT] = DoublePlant::class; self::$list[self::FENCE_GATE_SPRUCE] = FenceGateSpruce::class; diff --git a/src/pocketmine/block/BrewingStand.php b/src/pocketmine/block/BrewingStand.php new file mode 100644 index 000000000..e0e7aaa9a --- /dev/null +++ b/src/pocketmine/block/BrewingStand.php @@ -0,0 +1,46 @@ +meta = $meta; + } + + public function getName(){ + return "Flower Pot Block"; + } + +} \ No newline at end of file diff --git a/src/pocketmine/block/IronTrapdoor.php b/src/pocketmine/block/IronTrapdoor.php new file mode 100644 index 000000000..b23d2a225 --- /dev/null +++ b/src/pocketmine/block/IronTrapdoor.php @@ -0,0 +1,156 @@ +meta = $meta; + } + + public function getName(){ + return "Iron Trapdoor"; + } + + public function getHardness(){ + return 5; + } + + public function canBeActivated(){ + return true; + } + + protected function recalculateBoundingBox(){ + + $damage = $this->getDamage(); + + $f = 0.1875; + + if(($damage & 0x08) > 0){ + $bb = new AxisAlignedBB( + $this->x, + $this->y + 1 - $f, + $this->z, + $this->x + 1, + $this->y + 1, + $this->z + 1 + ); + }else{ + $bb = new AxisAlignedBB( + $this->x, + $this->y, + $this->z, + $this->x + 1, + $this->y + $f, + $this->z + 1 + ); + } + + if(($damage & 0x04) > 0){ + if(($damage & 0x03) === 0){ + $bb->setBounds( + $this->x, + $this->y, + $this->z + 1 - $f, + $this->x + 1, + $this->y + 1, + $this->z + 1 + ); + }elseif(($damage & 0x03) === 1){ + $bb->setBounds( + $this->x, + $this->y, + $this->z, + $this->x + 1, + $this->y + 1, + $this->z + $f + ); + } + if(($damage & 0x03) === 2){ + $bb->setBounds( + $this->x + 1 - $f, + $this->y, + $this->z, + $this->x + 1, + $this->y + 1, + $this->z + 1 + ); + } + if(($damage & 0x03) === 3){ + $bb->setBounds( + $this->x, + $this->y, + $this->z, + $this->x + $f, + $this->y + 1, + $this->z + 1 + ); + } + } + + return $bb; + } + + public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){ + if(($target->isTransparent() === false or $target->getId() === self::SLAB) and $face !== 0 and $face !== 1){ + $faces = [ + 2 => 0, + 3 => 1, + 4 => 2, + 5 => 3, + ]; + $this->meta = $faces[$face] & 0x03; + if($fy > 0.5){ + $this->meta |= 0x08; + } + $this->getLevel()->setBlock($block, $this, true, true); + + return true; + } + + return false; + } + + public function getDrops(Item $item){ + return [ + [$this->id, 0, 1], + ]; + } + + public function onActivate(Item $item, Player $player = null){ + $this->meta ^= 0x04; + $this->getLevel()->setBlock($this, $this, true); + $this->level->addSound(new DoorSound($this)); + return true; + } + + public function getToolType(){ + return Tool::TYPE_PICKAXE; + } +} \ No newline at end of file diff --git a/src/pocketmine/block/PackedIce.php b/src/pocketmine/block/PackedIce.php new file mode 100644 index 000000000..8d9e30a9d --- /dev/null +++ b/src/pocketmine/block/PackedIce.php @@ -0,0 +1,47 @@ +meta = $meta; + } + + public function canBeActivated(){ + return true; + } + + public function getHardness(){ + return 2.5; + } + + public function getName(){ + return "Trapped Chest"; + } + + public function getToolType(){ + return Tool::TYPE_AXE; + } + + protected function recalculateBoundingBox(){ + return new AxisAlignedBB( + $this->x + 0.0625, + $this->y, + $this->z + 0.0625, + $this->x + 0.9375, + $this->y + 0.9475, + $this->z + 0.9375 + ); + } + + public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){ + $faces = [ + 0 => 4, + 1 => 2, + 2 => 5, + 3 => 3, + ]; + + $chest = null; + $this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0]; + + for($side = 2; $side <= 5; ++$side){ + if(($this->meta === 4 or $this->meta === 5) and ($side === 4 or $side === 5)){ + continue; + }elseif(($this->meta === 3 or $this->meta === 2) and ($side === 2 or $side === 3)){ + continue; + } + $c = $this->getSide($side); + if($c instanceof Chest and $c->getDamage() === $this->meta){ + $tile = $this->getLevel()->getTile($c); + if($tile instanceof TileChest and !$tile->isPaired()){ + $chest = $tile; + break; + } + } + } + + $this->getLevel()->setBlock($block, $this, true, true); + $nbt = new Compound("", [ + new Enum("Items", []), + new String("id", Tile::CHEST), + new Int("x", $this->x), + new Int("y", $this->y), + new Int("z", $this->z) + ]); + $nbt->Items->setTagType(NBT::TAG_Compound); + + if($item->hasCustomName()){ + $nbt->CustomName = new String("CustomName", $item->getCustomName()); + } + + if($item->hasCustomBlockData()){ + foreach($item->getCustomBlockData() as $key => $v){ + $nbt->{$key} = $v; + } + } + + $tile = Tile::createTile("Chest", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt); + + if($chest instanceof TileChest and $tile instanceof TileChest){ + $chest->pairWith($tile); + $tile->pairWith($chest); + } + + return true; + } + + public function onBreak(Item $item){ + $t = $this->getLevel()->getTile($this); + if($t instanceof TileChest){ + $t->unpair(); + } + $this->getLevel()->setBlock($this, new Air(), true, true); + + return true; + } + + public function onActivate(Item $item, Player $player = null){ + if($player instanceof Player){ + $top = $this->getSide(1); + if($top->isTransparent() !== true){ + return true; + } + + $t = $this->getLevel()->getTile($this); + $chest = null; + if($t instanceof TileChest){ + $chest = $t; + }else{ + $nbt = new Compound("", [ + new Enum("Items", []), + new String("id", Tile::CHEST), + new Int("x", $this->x), + new Int("y", $this->y), + new Int("z", $this->z) + ]); + $nbt->Items->setTagType(NBT::TAG_Compound); + $chest = Tile::createTile("Chest", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt); + } + + if(isset($chest->namedtag->Lock) and $chest->namedtag->Lock instanceof String){ + if($chest->namedtag->Lock->getValue() !== $item->getCustomName()){ + return true; + } + } + + if($player->isCreative()){ + return true; + } + $player->addWindow($chest->getInventory()); + } + + return true; + } + + public function getDrops(Item $item){ + return [ + [$this->id, 0, 1], + ]; + } +} \ No newline at end of file diff --git a/src/pocketmine/item/FishingRod.php b/src/pocketmine/item/FishingRod.php new file mode 100644 index 000000000..26df171fc --- /dev/null +++ b/src/pocketmine/item/FishingRod.php @@ -0,0 +1,30 @@ +block = Block::get(Item::FLOWER_POT_BLOCK); + parent::__construct(self::FLOWER_POT, 0, $count, "Flower Pot"); + } +} \ No newline at end of file diff --git a/src/pocketmine/item/Item.php b/src/pocketmine/item/Item.php index c8a7b44fa..659a76a83 100644 --- a/src/pocketmine/item/Item.php +++ b/src/pocketmine/item/Item.php @@ -216,7 +216,7 @@ class Item{ const ENCHANTING_TABLE = 116; const ENCHANT_TABLE = 116; const ENCHANTMENT_TABLE = 116; - + const BREWING_STAND = 117; const END_PORTAL = 120; const END_STONE = 121; @@ -234,11 +234,12 @@ class Item{ const COBBLE_WALL = 139; const STONE_WALL = 139; const COBBLESTONE_WALL = 139; - + const FLOWER_POT_BLOCK = 140; const CARROT_BLOCK = 141; const POTATO_BLOCK = 142; const ANVIL = 145; + const TRAPPED_CHEST = 146; const REDSTONE_BLOCK = 152; @@ -265,11 +266,12 @@ class Item{ const DARK_OAK_WOOD_STAIRS = 164; const DARK_OAK_WOODEN_STAIRS = 164; + const IRON_TRAPDOOR = 167; const HAY_BALE = 170; const CARPET = 171; const HARDENED_CLAY = 172; const COAL_BLOCK = 173; - + const PACKED_ICE = 174; const DOUBLE_PLANT = 175; const FENCE_GATE_SPRUCE = 183; @@ -387,7 +389,7 @@ class Item{ const EGG = 344; const COMPASS = 345; - + const FISHING_ROD = 346; const CLOCK = 347; const GLOWSTONE_DUST = 348; const RAW_FISH = 349; @@ -421,6 +423,7 @@ class Item{ const EMERALD = 388; + const FLOWER_POT = 390; const CARROT = 391; const CARROTS = 391; const POTATO = 392; @@ -563,6 +566,7 @@ class Item{ self::$list[self::GOLD_NUGGET] = GoldNugget::class; self::$list[self::SPAWN_EGG] = SpawnEgg::class; self::$list[self::EMERALD] = Emerald::class; + self::$list[self::FLOWER_POT] = FlowerPot::class; self::$list[self::CARROT] = Carrot::class; self::$list[self::POTATO] = Potato::class; self::$list[self::BAKED_POTATO] = BakedPotato::class; @@ -673,7 +677,7 @@ class Item{ self::addCreativeItem(Item::get(Item::SLAB, 4)); self::addCreativeItem(Item::get(Item::SLAB, 5)); self::addCreativeItem(Item::get(Item::SLAB, 6)); - // TODO: Nether brick slab + self::addCreativeItem(Item::get(Item::SLAB, 7)); self::addCreativeItem(Item::get(Item::QUARTZ_BLOCK, 0)); self::addCreativeItem(Item::get(Item::QUARTZ_BLOCK, 1)); self::addCreativeItem(Item::get(Item::QUARTZ_BLOCK, 2)); @@ -686,7 +690,7 @@ class Item{ self::addCreativeItem(Item::get(Item::EMERALD_ORE, 0)); self::addCreativeItem(Item::get(Item::OBSIDIAN, 0)); self::addCreativeItem(Item::get(Item::ICE, 0)); - // TODO: Packed ice + self::addCreativeItem(Item::get(Item::PACKED_ICE, 0)); self::addCreativeItem(Item::get(Item::SNOW_BLOCK, 0)); self::addCreativeItem(Item::get(Item::END_STONE, 0)); @@ -714,9 +718,9 @@ class Item{ self::addCreativeItem(Item::get(Item::WOODEN_DOOR, 3)); // Jungle self::addCreativeItem(Item::get(Item::WOODEN_DOOR, 4)); // Acacia self::addCreativeItem(Item::get(Item::WOODEN_DOOR, 5)); // Dark oak - // TODO: Iron door + self::addCreativeItem(Item::get(Item::IRON_DOOR, 0)); self::addCreativeItem(Item::get(Item::TRAPDOOR, 0)); - // TODO: Iron trapdoor + self::addCreativeItem(Item::get(Item::IRON_TRAPDOOR, 0)); self::addCreativeItem(Item::get(Item::FENCE, Fence::FENCE_OAK)); self::addCreativeItem(Item::get(Item::FENCE, Fence::FENCE_SPRUCE)); self::addCreativeItem(Item::get(Item::FENCE, Fence::FENCE_BIRCH)); @@ -737,9 +741,9 @@ class Item{ self::addCreativeItem(Item::get(Item::WORKBENCH, 0)); self::addCreativeItem(Item::get(Item::STONECUTTER, 0)); self::addCreativeItem(Item::get(Item::CHEST, 0)); - // TODO: Trapped chest + self::addCreativeItem(Item::get(Item::TRAPPED_CHEST, 0)); self::addCreativeItem(Item::get(Item::FURNACE, 0)); - // TODO: Brewing stand + self::addCreativeItem(Item::get(Item::BREWING_STAND, 0)); // TODO: Note Block self::addCreativeItem(Item::get(Item::END_PORTAL, 0)); self::addCreativeItem(Item::get(Item::ANVIL, 0)); @@ -795,7 +799,7 @@ class Item{ // TODO: Head // TODO: Creeper head self::addCreativeItem(Item::get(Item::SIGN, 0)); - // TODO: flower pot + self::addCreativeItem(Item::get(Item::FLOWER_POT, 0)); self::addCreativeItem(Item::get(Item::MONSTER_SPAWNER, 0)); self::addCreativeItem(Item::get(Item::ENCHANTMENT_TABLE, 0)); self::addCreativeItem(Item::get(Item::WOOL, 0)); @@ -844,7 +848,7 @@ class Item{ self::addCreativeItem(Item::get(Item::TNT, 0)); self::addCreativeItem(Item::get(Item::REDSTONE, 0)); self::addCreativeItem(Item::get(Item::BOW, 0)); - // TODO: fishing rod + self::addCreativeItem(Item::get(Item::FISHING_ROD, 0)); self::addCreativeItem(Item::get(Item::FLINT_AND_STEEL, 0)); self::addCreativeItem(Item::get(Item::SHEARS, 0)); self::addCreativeItem(Item::get(Item::CLOCK, 0));