mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 02:08:21 +00:00
Merge branch 'master' into 0.10
This commit is contained in:
@ -36,7 +36,7 @@ class Bed extends Transparent{
|
||||
}
|
||||
|
||||
protected function recalculateBoundingBox(){
|
||||
return AxisAlignedBB::getBoundingBoxFromPool(
|
||||
return new AxisAlignedBB(
|
||||
$this->x,
|
||||
$this->y,
|
||||
$this->z,
|
||||
@ -53,7 +53,7 @@ class Bed extends Transparent{
|
||||
$isNight = ($time >= Level::TIME_NIGHT and $time < Level::TIME_SUNRISE);
|
||||
|
||||
if($player instanceof Player and !$isNight){
|
||||
$pk = ChatPacket::getFromPool();
|
||||
$pk = new ChatPacket();
|
||||
$pk->message = "You can only sleep at night";
|
||||
$player->dataPacket($pk);
|
||||
|
||||
@ -77,7 +77,7 @@ class Bed extends Transparent{
|
||||
$b = $blockWest;
|
||||
}else{
|
||||
if($player instanceof Player){
|
||||
$pk = ChatPacket::getFromPool();
|
||||
$pk = new ChatPacket();
|
||||
$pk->message = "This bed is incomplete";
|
||||
$player->dataPacket($pk);
|
||||
}
|
||||
@ -87,7 +87,7 @@ class Bed extends Transparent{
|
||||
}
|
||||
|
||||
if($player instanceof Player and $player->sleepOn($b) === false){
|
||||
$pk = ChatPacket::getFromPool();
|
||||
$pk = new ChatPacket();
|
||||
$pk->message = "This bed is occupied";
|
||||
$player->dataPacket($pk);
|
||||
}
|
||||
|
@ -526,8 +526,8 @@ class Block extends Position implements Metadatable{
|
||||
|
||||
];
|
||||
|
||||
/** @var Block[] */
|
||||
public static $list = [];
|
||||
/** @var \SplFixedArray */
|
||||
public static $list = null;
|
||||
protected $id;
|
||||
protected $meta;
|
||||
protected $name = "Unknown";
|
||||
@ -553,156 +553,155 @@ class Block extends Position implements Metadatable{
|
||||
protected $boundingBox = null;
|
||||
|
||||
public static function init(){
|
||||
if(count(self::$list) === 0){
|
||||
self::$list = [
|
||||
self::AIR => Air::class,
|
||||
self::STONE => Stone::class,
|
||||
self::GRASS => Grass::class,
|
||||
self::DIRT => Dirt::class,
|
||||
self::COBBLESTONE => Cobblestone::class,
|
||||
self::PLANKS => Planks::class,
|
||||
self::SAPLING => Sapling::class,
|
||||
self::BEDROCK => Bedrock::class,
|
||||
self::WATER => Water::class,
|
||||
self::STILL_WATER => StillWater::class,
|
||||
self::LAVA => Lava::class,
|
||||
self::STILL_LAVA => StillLava::class,
|
||||
self::SAND => Sand::class,
|
||||
self::GRAVEL => Gravel::class,
|
||||
self::GOLD_ORE => GoldOre::class,
|
||||
self::IRON_ORE => IronOre::class,
|
||||
self::COAL_ORE => CoalOre::class,
|
||||
self::WOOD => Wood::class,
|
||||
self::LEAVES => Leaves::class,
|
||||
self::SPONGE => Sponge::class,
|
||||
self::GLASS => Glass::class,
|
||||
self::LAPIS_ORE => LapisOre::class,
|
||||
self::LAPIS_BLOCK => Lapis::class,
|
||||
self::SANDSTONE => Sandstone::class,
|
||||
self::BED_BLOCK => Bed::class,
|
||||
self::COBWEB => Cobweb::class,
|
||||
self::TALL_GRASS => TallGrass::class,
|
||||
self::DEAD_BUSH => DeadBush::class,
|
||||
self::WOOL => Wool::class,
|
||||
self::DANDELION => Dandelion::class,
|
||||
self::POPPY => CyanFlower::class,
|
||||
self::BROWN_MUSHROOM => BrownMushroom::class,
|
||||
self::RED_MUSHROOM => RedMushroom::class,
|
||||
self::GOLD_BLOCK => Gold::class,
|
||||
self::IRON_BLOCK => Iron::class,
|
||||
self::DOUBLE_SLAB => DoubleSlab::class,
|
||||
self::SLAB => Slab::class,
|
||||
self::BRICKS_BLOCK => Bricks::class,
|
||||
self::TNT => TNT::class,
|
||||
self::BOOKSHELF => Bookshelf::class,
|
||||
self::MOSS_STONE => MossStone::class,
|
||||
self::OBSIDIAN => Obsidian::class,
|
||||
self::TORCH => Torch::class,
|
||||
self::FIRE => Fire::class,
|
||||
self::MONSTER_SPAWNER => MonsterSpawner::class,
|
||||
self::WOOD_STAIRS => WoodStairs::class,
|
||||
self::CHEST => Chest::class,
|
||||
if(self::$list === null){
|
||||
self::$list = new \SplFixedArray(256);
|
||||
self::$list[self::AIR] = Air::class;;
|
||||
self::$list[self::STONE] = Stone::class;;
|
||||
self::$list[self::GRASS] = Grass::class;;
|
||||
self::$list[self::DIRT] = Dirt::class;;
|
||||
self::$list[self::COBBLESTONE] = Cobblestone::class;;
|
||||
self::$list[self::PLANKS] = Planks::class;;
|
||||
self::$list[self::SAPLING] = Sapling::class;;
|
||||
self::$list[self::BEDROCK] = Bedrock::class;;
|
||||
self::$list[self::WATER] = Water::class;;
|
||||
self::$list[self::STILL_WATER] = StillWater::class;;
|
||||
self::$list[self::LAVA] = Lava::class;;
|
||||
self::$list[self::STILL_LAVA] = StillLava::class;;
|
||||
self::$list[self::SAND] = Sand::class;;
|
||||
self::$list[self::GRAVEL] = Gravel::class;;
|
||||
self::$list[self::GOLD_ORE] = GoldOre::class;;
|
||||
self::$list[self::IRON_ORE] = IronOre::class;;
|
||||
self::$list[self::COAL_ORE] = CoalOre::class;;
|
||||
self::$list[self::WOOD] = Wood::class;;
|
||||
self::$list[self::LEAVES] = Leaves::class;;
|
||||
self::$list[self::SPONGE] = Sponge::class;;
|
||||
self::$list[self::GLASS] = Glass::class;;
|
||||
self::$list[self::LAPIS_ORE] = LapisOre::class;;
|
||||
self::$list[self::LAPIS_BLOCK] = Lapis::class;;
|
||||
self::$list[self::SANDSTONE] = Sandstone::class;;
|
||||
self::$list[self::BED_BLOCK] = Bed::class;;
|
||||
self::$list[self::COBWEB] = Cobweb::class;;
|
||||
self::$list[self::TALL_GRASS] = TallGrass::class;;
|
||||
self::$list[self::DEAD_BUSH] = DeadBush::class;;
|
||||
self::$list[self::WOOL] = Wool::class;;
|
||||
self::$list[self::DANDELION] = Dandelion::class;;
|
||||
self::$list[self::POPPY] = CyanFlower::class;;
|
||||
self::$list[self::BROWN_MUSHROOM] = BrownMushroom::class;;
|
||||
self::$list[self::RED_MUSHROOM] = RedMushroom::class;;
|
||||
self::$list[self::GOLD_BLOCK] = Gold::class;;
|
||||
self::$list[self::IRON_BLOCK] = Iron::class;;
|
||||
self::$list[self::DOUBLE_SLAB] = DoubleSlab::class;;
|
||||
self::$list[self::SLAB] = Slab::class;;
|
||||
self::$list[self::BRICKS_BLOCK] = Bricks::class;;
|
||||
self::$list[self::TNT] = TNT::class;;
|
||||
self::$list[self::BOOKSHELF] = Bookshelf::class;;
|
||||
self::$list[self::MOSS_STONE] = MossStone::class;;
|
||||
self::$list[self::OBSIDIAN] = Obsidian::class;;
|
||||
self::$list[self::TORCH] = Torch::class;;
|
||||
self::$list[self::FIRE] = Fire::class;;
|
||||
self::$list[self::MONSTER_SPAWNER] = MonsterSpawner::class;;
|
||||
self::$list[self::WOOD_STAIRS] = WoodStairs::class;;
|
||||
self::$list[self::CHEST] = Chest::class;;
|
||||
|
||||
self::DIAMOND_ORE => DiamondOre::class,
|
||||
self::DIAMOND_BLOCK => Diamond::class,
|
||||
self::WORKBENCH => Workbench::class,
|
||||
self::WHEAT_BLOCK => Wheat::class,
|
||||
self::FARMLAND => Farmland::class,
|
||||
self::FURNACE => Furnace::class,
|
||||
self::BURNING_FURNACE => BurningFurnace::class,
|
||||
self::SIGN_POST => SignPost::class,
|
||||
self::WOOD_DOOR_BLOCK => WoodDoor::class,
|
||||
self::LADDER => Ladder::class,
|
||||
self::$list[self::DIAMOND_ORE] = DiamondOre::class;;
|
||||
self::$list[self::DIAMOND_BLOCK] = Diamond::class;;
|
||||
self::$list[self::WORKBENCH] = Workbench::class;;
|
||||
self::$list[self::WHEAT_BLOCK] = Wheat::class;;
|
||||
self::$list[self::FARMLAND] = Farmland::class;;
|
||||
self::$list[self::FURNACE] = Furnace::class;;
|
||||
self::$list[self::BURNING_FURNACE] = BurningFurnace::class;;
|
||||
self::$list[self::SIGN_POST] = SignPost::class;;
|
||||
self::$list[self::WOOD_DOOR_BLOCK] = WoodDoor::class;;
|
||||
self::$list[self::LADDER] = Ladder::class;;
|
||||
|
||||
self::COBBLESTONE_STAIRS => CobblestoneStairs::class,
|
||||
self::WALL_SIGN => WallSign::class,
|
||||
self::$list[self::COBBLESTONE_STAIRS] = CobblestoneStairs::class;;
|
||||
self::$list[self::WALL_SIGN] = WallSign::class;;
|
||||
|
||||
self::IRON_DOOR_BLOCK => IronDoor::class,
|
||||
self::REDSTONE_ORE => RedstoneOre::class,
|
||||
self::GLOWING_REDSTONE_ORE => GlowingRedstoneOre::class,
|
||||
self::$list[self::IRON_DOOR_BLOCK] = IronDoor::class;;
|
||||
self::$list[self::REDSTONE_ORE] = RedstoneOre::class;;
|
||||
self::$list[self::GLOWING_REDSTONE_ORE] = GlowingRedstoneOre::class;;
|
||||
|
||||
self::SNOW_LAYER => SnowLayer::class,
|
||||
self::ICE => Ice::class,
|
||||
self::SNOW_BLOCK => Snow::class,
|
||||
self::CACTUS => Cactus::class,
|
||||
self::CLAY_BLOCK => Clay::class,
|
||||
self::SUGARCANE_BLOCK => Sugarcane::class,
|
||||
self::$list[self::SNOW_LAYER] = SnowLayer::class;;
|
||||
self::$list[self::ICE] = Ice::class;;
|
||||
self::$list[self::SNOW_BLOCK] = Snow::class;;
|
||||
self::$list[self::CACTUS] = Cactus::class;;
|
||||
self::$list[self::CLAY_BLOCK] = Clay::class;;
|
||||
self::$list[self::SUGARCANE_BLOCK] = Sugarcane::class;;
|
||||
|
||||
self::FENCE => Fence::class,
|
||||
self::PUMPKIN => Pumpkin::class,
|
||||
self::NETHERRACK => Netherrack::class,
|
||||
self::SOUL_SAND => SoulSand::class,
|
||||
self::GLOWSTONE_BLOCK => Glowstone::class,
|
||||
self::$list[self::FENCE] = Fence::class;;
|
||||
self::$list[self::PUMPKIN] = Pumpkin::class;;
|
||||
self::$list[self::NETHERRACK] = Netherrack::class;;
|
||||
self::$list[self::SOUL_SAND] = SoulSand::class;;
|
||||
self::$list[self::GLOWSTONE_BLOCK] = Glowstone::class;;
|
||||
|
||||
self::LIT_PUMPKIN => LitPumpkin::class,
|
||||
self::CAKE_BLOCK => Cake::class,
|
||||
self::$list[self::LIT_PUMPKIN] = LitPumpkin::class;;
|
||||
self::$list[self::CAKE_BLOCK] = Cake::class;;
|
||||
|
||||
self::TRAPDOOR => Trapdoor::class,
|
||||
self::$list[self::TRAPDOOR] = Trapdoor::class;;
|
||||
|
||||
self::STONE_BRICKS => StoneBricks::class,
|
||||
self::$list[self::STONE_BRICKS] = StoneBricks::class;;
|
||||
|
||||
self::IRON_BARS => IronBars::class,
|
||||
self::GLASS_PANE => GlassPane::class,
|
||||
self::MELON_BLOCK => Melon::class,
|
||||
self::PUMPKIN_STEM => PumpkinStem::class,
|
||||
self::MELON_STEM => MelonStem::class,
|
||||
self::VINE => Vine::class,
|
||||
self::FENCE_GATE => FenceGate::class,
|
||||
self::BRICK_STAIRS => BrickStairs::class,
|
||||
self::STONE_BRICK_STAIRS => StoneBrickStairs::class,
|
||||
self::$list[self::IRON_BARS] = IronBars::class;;
|
||||
self::$list[self::GLASS_PANE] = GlassPane::class;;
|
||||
self::$list[self::MELON_BLOCK] = Melon::class;;
|
||||
self::$list[self::PUMPKIN_STEM] = PumpkinStem::class;;
|
||||
self::$list[self::MELON_STEM] = MelonStem::class;;
|
||||
self::$list[self::VINE] = Vine::class;;
|
||||
self::$list[self::FENCE_GATE] = FenceGate::class;;
|
||||
self::$list[self::BRICK_STAIRS] = BrickStairs::class;;
|
||||
self::$list[self::STONE_BRICK_STAIRS] = StoneBrickStairs::class;;
|
||||
|
||||
self::MYCELIUM => Mycelium::class,
|
||||
self::NETHER_BRICKS => NetherBrick::class,
|
||||
self::$list[self::MYCELIUM] = Mycelium::class;;
|
||||
self::$list[self::NETHER_BRICKS] = NetherBrick::class;;
|
||||
|
||||
self::NETHER_BRICKS_STAIRS => NetherBrickStairs::class,
|
||||
self::$list[self::NETHER_BRICKS_STAIRS] = NetherBrickStairs::class;;
|
||||
|
||||
self::END_PORTAL => EndPortal::class,
|
||||
self::END_STONE => EndStone::class,
|
||||
self::SANDSTONE_STAIRS => SandstoneStairs::class,
|
||||
self::EMERALD_ORE => EmeraldOre::class,
|
||||
self::$list[self::END_PORTAL] = EndPortal::class;;
|
||||
self::$list[self::END_STONE] = EndStone::class;;
|
||||
self::$list[self::SANDSTONE_STAIRS] = SandstoneStairs::class;;
|
||||
self::$list[self::EMERALD_ORE] = EmeraldOre::class;;
|
||||
|
||||
self::EMERALD_BLOCK => Emerald::class,
|
||||
self::SPRUCE_WOOD_STAIRS => SpruceWoodStairs::class,
|
||||
self::BIRCH_WOOD_STAIRS => BirchWoodStairs::class,
|
||||
self::JUNGLE_WOOD_STAIRS => JungleWoodStairs::class,
|
||||
self::STONE_WALL => StoneWall::class,
|
||||
self::$list[self::EMERALD_BLOCK] = Emerald::class;;
|
||||
self::$list[self::SPRUCE_WOOD_STAIRS] = SpruceWoodStairs::class;;
|
||||
self::$list[self::BIRCH_WOOD_STAIRS] = BirchWoodStairs::class;;
|
||||
self::$list[self::JUNGLE_WOOD_STAIRS] = JungleWoodStairs::class;;
|
||||
self::$list[self::STONE_WALL] = StoneWall::class;;
|
||||
|
||||
self::CARROT_BLOCK => Carrot::class,
|
||||
self::POTATO_BLOCK => Potato::class,
|
||||
self::$list[self::CARROT_BLOCK] = Carrot::class;;
|
||||
self::$list[self::POTATO_BLOCK] = Potato::class;;
|
||||
|
||||
self::QUARTZ_BLOCK => Quartz::class,
|
||||
self::QUARTZ_STAIRS => QuartzStairs::class,
|
||||
self::DOUBLE_WOOD_SLAB => DoubleWoodSlab::class,
|
||||
self::WOOD_SLAB => WoodSlab::class,
|
||||
self::STAINED_CLAY => StainedClay::class,
|
||||
self::$list[self::QUARTZ_BLOCK] = Quartz::class;;
|
||||
self::$list[self::QUARTZ_STAIRS] = QuartzStairs::class;;
|
||||
self::$list[self::DOUBLE_WOOD_SLAB] = DoubleWoodSlab::class;;
|
||||
self::$list[self::WOOD_SLAB] = WoodSlab::class;;
|
||||
self::$list[self::STAINED_CLAY] = StainedClay::class;;
|
||||
|
||||
self::LEAVES2 => Leaves2::class,
|
||||
self::WOOD2 => Wood2::class,
|
||||
self::ACACIA_WOOD_STAIRS => AcaciaWoodStairs::class,
|
||||
self::DARK_OAK_WOOD_STAIRS => DarkOakWoodStairs::class,
|
||||
self::$list[self::LEAVES2] = Leaves2::class;;
|
||||
self::$list[self::WOOD2] = Wood2::class;;
|
||||
self::$list[self::ACACIA_WOOD_STAIRS] = AcaciaWoodStairs::class;;
|
||||
self::$list[self::DARK_OAK_WOOD_STAIRS] = DarkOakWoodStairs::class;;
|
||||
|
||||
self::HAY_BALE => HayBale::class,
|
||||
self::CARPET => Carpet::class,
|
||||
self::HARDENED_CLAY => HardenedClay::class,
|
||||
self::COAL_BLOCK => Coal::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::FENCE_GATE_SPRUCE => FenceGateSpruce::class,
|
||||
self::FENCE_GATE_BIRCH => FenceGateBirch::class,
|
||||
self::FENCE_GATE_JUNGLE => FenceGateJungle::class,
|
||||
self::FENCE_GATE_DARK_OAK => FenceGateDarkOak::class,
|
||||
self::FENCE_GATE_ACACIA => FenceGateAcacia::class,
|
||||
self::FENCE_SPRUCE => FenceSpruce::class,
|
||||
self::FENCE_BIRCH => FenceBirch::class,
|
||||
self::FENCE_DARK_OAK => FenceDarkOak::class,
|
||||
self::FENCE_JUNGLE => FenceJungle::class,
|
||||
self::FENCE_ACACIA => FenceAcacia::class,
|
||||
self::$list[self::FENCE_GATE_SPRUCE] = FenceGateSpruce::class;
|
||||
self::$list[self::FENCE_GATE_BIRCH] = FenceGateBirch::class;
|
||||
self::$list[self::FENCE_GATE_JUNGLE] = FenceGateJungle::class;
|
||||
self::$list[self::FENCE_GATE_DARK_OAK] = FenceGateDarkOak::class;
|
||||
self::$list[self::FENCE_GATE_ACACIA] = FenceGateAcacia::class;
|
||||
self::$list[self::FENCE_SPRUCE] = FenceSpruce::class;
|
||||
self::$list[self::FENCE_BIRCH] = FenceBirch::class;
|
||||
self::$list[self::FENCE_DARK_OAK] = FenceDarkOak::class;
|
||||
self::$list[self::FENCE_JUNGLE] = FenceJungle::class;
|
||||
self::$list[self::FENCE_ACACIA] = FenceAcacia::class;
|
||||
|
||||
self::PODZOL => Podzol::class,
|
||||
self::BEETROOT_BLOCK => Beetroot::class,
|
||||
self::STONECUTTER => Stonecutter::class,
|
||||
self::GLOWING_OBSIDIAN => GlowingObsidian::class,
|
||||
self::NETHER_REACTOR => NetherReactor::class,
|
||||
];
|
||||
self::$list[self::PODZOL] = Podzol::class;;
|
||||
self::$list[self::BEETROOT_BLOCK] = Beetroot::class;;
|
||||
self::$list[self::STONECUTTER] = Stonecutter::class;;
|
||||
self::$list[self::GLOWING_OBSIDIAN] = GlowingObsidian::class;;
|
||||
self::$list[self::NETHER_REACTOR] = NetherReactor::class;;
|
||||
}
|
||||
}
|
||||
|
||||
@ -714,10 +713,14 @@ class Block extends Position implements Metadatable{
|
||||
* @return Block
|
||||
*/
|
||||
public static function get($id, $meta = 0, Position $pos = null){
|
||||
if(isset(self::$list[$id])){
|
||||
try{
|
||||
$block = self::$list[$id];
|
||||
$block = new $block($meta);
|
||||
}else{
|
||||
if($block !== null){
|
||||
$block = new $block($meta);
|
||||
}else{
|
||||
$block = new Block($id, $meta);
|
||||
}
|
||||
}catch(\RuntimeException $e){
|
||||
$block = new Block($id, $meta);
|
||||
}
|
||||
|
||||
@ -822,7 +825,7 @@ class Block extends Position implements Metadatable{
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
final public function getID(){
|
||||
final public function getId(){
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
@ -943,7 +946,7 @@ class Block extends Position implements Metadatable{
|
||||
* @return AxisAlignedBB
|
||||
*/
|
||||
protected function recalculateBoundingBox(){
|
||||
return AxisAlignedBB::getBoundingBoxFromPool(
|
||||
return new AxisAlignedBB(
|
||||
$this->x,
|
||||
$this->y,
|
||||
$this->z,
|
||||
|
@ -44,7 +44,7 @@ class Cactus extends Transparent{
|
||||
|
||||
protected function recalculateBoundingBox(){
|
||||
|
||||
return AxisAlignedBB::getBoundingBoxFromPool(
|
||||
return new AxisAlignedBB(
|
||||
$this->x + 0.0625,
|
||||
$this->y,
|
||||
$this->z + 0.0625,
|
||||
@ -55,7 +55,7 @@ class Cactus extends Transparent{
|
||||
}
|
||||
|
||||
public function onEntityCollide(Entity $entity){
|
||||
$ev = EntityDamageByBlockEvent::createEvent($this, $entity, EntityDamageEvent::CAUSE_CONTACT, 1);
|
||||
$ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_CONTACT, 1);
|
||||
$entity->attack($ev->getFinalDamage(), $ev);
|
||||
}
|
||||
|
||||
@ -76,9 +76,9 @@ class Cactus extends Transparent{
|
||||
if($this->getSide(0)->getID() !== self::CACTUS){
|
||||
if($this->meta == 0x0F){
|
||||
for($y = 1; $y < 3; ++$y){
|
||||
$b = $this->getLevel()->getBlock(Vector3::createVector($this->x, $this->y + $y, $this->z));
|
||||
$b = $this->getLevel()->getBlock(new Vector3($this->x, $this->y + $y, $this->z));
|
||||
if($b->getID() === self::AIR){
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = BlockGrowEvent::createEvent($b, new Cactus()));
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($b, new Cactus()));
|
||||
if(!$ev->isCancelled()){
|
||||
$this->getLevel()->setBlock($b, $ev->getNewState(), true);
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ class Cake extends Transparent{
|
||||
|
||||
$f = (1 + $this->getDamage() * 2) / 16;
|
||||
|
||||
return AxisAlignedBB::getBoundingBoxFromPool(
|
||||
return new AxisAlignedBB(
|
||||
$this->x + $f,
|
||||
$this->y,
|
||||
$this->z + 0.0625,
|
||||
@ -81,7 +81,7 @@ class Cake extends Transparent{
|
||||
public function onActivate(Item $item, Player $player = null){
|
||||
if($player instanceof Player and $player->getHealth() < 20){
|
||||
++$this->meta;
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = EntityRegainHealthEvent::createEvent($player, 3, EntityRegainHealthEvent::CAUSE_EATING));
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = new EntityRegainHealthEvent($player, 3, EntityRegainHealthEvent::CAUSE_EATING));
|
||||
if(!$ev->isCancelled()){
|
||||
$player->heal($ev->getAmount(), $ev);
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ class Carpet extends Flowable{
|
||||
|
||||
protected function recalculateBoundingBox(){
|
||||
|
||||
return AxisAlignedBB::getBoundingBoxFromPool(
|
||||
return new AxisAlignedBB(
|
||||
$this->x,
|
||||
$this->y,
|
||||
$this->z,
|
||||
|
@ -44,7 +44,7 @@ class Chest extends Transparent{
|
||||
|
||||
protected function recalculateBoundingBox(){
|
||||
|
||||
return AxisAlignedBB::getBoundingBoxFromPool(
|
||||
return new AxisAlignedBB(
|
||||
$this->x + 0.0625,
|
||||
$this->y,
|
||||
$this->z + 0.0625,
|
||||
|
@ -57,7 +57,7 @@ abstract class Crops extends Flowable{
|
||||
$block->meta = 7;
|
||||
}
|
||||
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = BlockGrowEvent::createEvent($this, $block));
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($this, $block));
|
||||
|
||||
if(!$ev->isCancelled()){
|
||||
$this->getLevel()->setBlock($this, $ev->getNewState(), true, true);
|
||||
@ -82,7 +82,7 @@ abstract class Crops extends Flowable{
|
||||
if($this->meta < 0x07){
|
||||
$block = clone $this;
|
||||
++$block->meta;
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = BlockGrowEvent::createEvent($this, $block));
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($this, $block));
|
||||
|
||||
if(!$ev->isCancelled()){
|
||||
$this->getLevel()->setBlock($this, $ev->getNewState(), true, true);
|
||||
|
@ -57,7 +57,7 @@ abstract class Door extends Transparent{
|
||||
$f = 0.1875;
|
||||
$damage = $this->getFullDamage();
|
||||
|
||||
$bb = AxisAlignedBB::getBoundingBoxFromPool(
|
||||
$bb = new AxisAlignedBB(
|
||||
$this->x,
|
||||
$this->y,
|
||||
$this->z,
|
||||
@ -271,7 +271,7 @@ abstract class Door extends Transparent{
|
||||
if($player instanceof Player){
|
||||
unset($players[$player->getID()]);
|
||||
}
|
||||
$pk = LevelEventPacket::getFromPool();
|
||||
$pk = new LevelEventPacket();
|
||||
$pk->x = $this->x;
|
||||
$pk->y = $this->y;
|
||||
$pk->z = $this->z;
|
||||
@ -290,7 +290,7 @@ abstract class Door extends Transparent{
|
||||
if($player instanceof Player){
|
||||
unset($players[$player->getID()]);
|
||||
}
|
||||
$pk = LevelEventPacket::getFromPool();
|
||||
$pk = new LevelEventPacket();
|
||||
$pk->x = $this->x;
|
||||
$pk->y = $this->y;
|
||||
$pk->z = $this->z;
|
||||
|
@ -31,7 +31,7 @@ class EndPortal extends Solid{
|
||||
|
||||
protected function recalculateBoundingBox(){
|
||||
|
||||
return AxisAlignedBB::getBoundingBoxFromPool(
|
||||
return new AxisAlignedBB(
|
||||
$this->x,
|
||||
$this->y,
|
||||
$this->z,
|
||||
|
@ -32,7 +32,7 @@ class Farmland extends Solid{
|
||||
|
||||
protected function recalculateBoundingBox(){
|
||||
|
||||
return AxisAlignedBB::getBoundingBoxFromPool(
|
||||
return new AxisAlignedBB(
|
||||
$this->x,
|
||||
$this->y,
|
||||
$this->z,
|
||||
|
@ -42,7 +42,7 @@ class Fence extends Transparent{
|
||||
$f2 = $flag ? 0 : 0.375;
|
||||
$f3 = $flag1 ? 1 : 0.625;
|
||||
|
||||
return AxisAlignedBB::getBoundingBoxFromPool(
|
||||
return new AxisAlignedBB(
|
||||
$this->x + $f,
|
||||
$this->y,
|
||||
$this->z + $f2,
|
||||
|
@ -46,7 +46,7 @@ class FenceGate extends Transparent{
|
||||
|
||||
$i = ($this->getDamage() & 0x03);
|
||||
if($i === 2 and $i === 0){
|
||||
return AxisAlignedBB::getBoundingBoxFromPool(
|
||||
return new AxisAlignedBB(
|
||||
$this->x,
|
||||
$this->y,
|
||||
$this->z + 0.375,
|
||||
@ -55,7 +55,7 @@ class FenceGate extends Transparent{
|
||||
$this->z + 0.625
|
||||
);
|
||||
}else{
|
||||
return AxisAlignedBB::getBoundingBoxFromPool(
|
||||
return new AxisAlignedBB(
|
||||
$this->x + 0.375,
|
||||
$this->y,
|
||||
$this->z,
|
||||
|
@ -46,10 +46,10 @@ class Fire extends Flowable{
|
||||
}
|
||||
|
||||
public function onEntityCollide(Entity $entity){
|
||||
$ev = EntityDamageByBlockEvent::createEvent($this, $entity, EntityDamageEvent::CAUSE_FIRE, 1);
|
||||
$ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_FIRE, 1);
|
||||
$entity->attack($ev->getFinalDamage(), $ev);
|
||||
|
||||
$ev = EntityCombustByBlockEvent::createEvent($this, $entity, 8);
|
||||
$ev = new EntityCombustByBlockEvent($this, $entity, 8);
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev);
|
||||
if(!$ev->isCancelled()){
|
||||
$entity->setOnFire($ev->getDuration());
|
||||
|
@ -25,7 +25,6 @@ use pocketmine\event\block\BlockSpreadEvent;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\level\generator\object\TallGrass as TallGrassObject;
|
||||
use pocketmine\level\Level;
|
||||
use pocketmine\level\Position;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\Server;
|
||||
@ -55,10 +54,10 @@ class Grass extends Solid{
|
||||
$x = mt_rand($this->x - 1, $this->x + 1);
|
||||
$y = mt_rand($this->y - 2, $this->y + 2);
|
||||
$z = mt_rand($this->z - 1, $this->z + 1);
|
||||
$block = $this->getLevel()->getBlock(Vector3::createVector($x, $y, $z));
|
||||
$block = $this->getLevel()->getBlock(new Vector3($x, $y, $z));
|
||||
if($block->getID() === Block::DIRT){
|
||||
if($block->getSide(1) instanceof Transparent){
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = BlockSpreadEvent::createEvent($block, $this, new Grass()));
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = new BlockSpreadEvent($block, $this, new Grass()));
|
||||
if(!$ev->isCancelled()){
|
||||
$this->getLevel()->setBlock($block, $ev->getNewState());
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ class Ladder extends Transparent{
|
||||
$f = 0.125;
|
||||
|
||||
if($this->meta === 2){
|
||||
return AxisAlignedBB::getBoundingBoxFromPool(
|
||||
return new AxisAlignedBB(
|
||||
$this->x,
|
||||
$this->y,
|
||||
$this->z + 1 - $f,
|
||||
@ -57,7 +57,7 @@ class Ladder extends Transparent{
|
||||
$this->z + 1
|
||||
);
|
||||
}elseif($this->meta === 3){
|
||||
return AxisAlignedBB::getBoundingBoxFromPool(
|
||||
return new AxisAlignedBB(
|
||||
$this->x,
|
||||
$this->y,
|
||||
$this->z,
|
||||
@ -66,7 +66,7 @@ class Ladder extends Transparent{
|
||||
$this->z + $f
|
||||
);
|
||||
}elseif($this->meta === 4){
|
||||
return AxisAlignedBB::getBoundingBoxFromPool(
|
||||
return new AxisAlignedBB(
|
||||
$this->x + 1 - $f,
|
||||
$this->y,
|
||||
$this->z,
|
||||
@ -75,7 +75,7 @@ class Ladder extends Transparent{
|
||||
$this->z + 1
|
||||
);
|
||||
}elseif($this->meta === 5){
|
||||
return AxisAlignedBB::getBoundingBoxFromPool(
|
||||
return new AxisAlignedBB(
|
||||
$this->x,
|
||||
$this->y,
|
||||
$this->z,
|
||||
|
@ -38,10 +38,10 @@ class Lava extends Liquid{
|
||||
|
||||
public function onEntityCollide(Entity $entity){
|
||||
$entity->fallDistance *= 0.5;
|
||||
$ev = EntityDamageByBlockEvent::createEvent($this, $entity, EntityDamageEvent::CAUSE_LAVA, 4);
|
||||
$ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_LAVA, 4);
|
||||
$entity->attack($ev->getFinalDamage(), $ev);
|
||||
|
||||
$ev = EntityCombustByBlockEvent::createEvent($this, $entity, 15);
|
||||
$ev = new EntityCombustByBlockEvent($this, $entity, 15);
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev);
|
||||
if(!$ev->isCancelled()){
|
||||
$entity->setOnFire($ev->getDuration());
|
||||
|
@ -124,7 +124,7 @@ class Leaves extends Transparent{
|
||||
$visited = [];
|
||||
$check = 0;
|
||||
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = LeavesDecayEvent::createEvent($this));
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = new LeavesDecayEvent($this));
|
||||
|
||||
if($ev->isCancelled() or $this->findLog($this, $visited, 0, $check) === true){
|
||||
$this->getLevel()->setBlock($this, $this, false, false);
|
||||
|
@ -116,7 +116,7 @@ class Leaves2 extends Leaves{
|
||||
$visited = [];
|
||||
$check = 0;
|
||||
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = LeavesDecayEvent::createEvent($this));
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = new LeavesDecayEvent($this));
|
||||
|
||||
if($ev->isCancelled() or $this->findLog($this, $visited, 0, $check) === true){
|
||||
$this->getLevel()->setBlock($this, $this, false, false);
|
||||
|
@ -80,7 +80,7 @@ abstract class Liquid extends Transparent{
|
||||
}
|
||||
|
||||
public function getFlowVector(){
|
||||
$vector = Vector3::createVector(0, 0, 0);
|
||||
$vector = new Vector3(0, 0, 0);
|
||||
|
||||
$decay = $this->getEffectiveFlowDecay($this);
|
||||
|
||||
@ -99,7 +99,7 @@ abstract class Liquid extends Transparent{
|
||||
}elseif($j === 3){
|
||||
++$z;
|
||||
}
|
||||
$sideBlock = $this->getLevel()->getBlock(Vector3::createVector($x, $y, $z));
|
||||
$sideBlock = $this->getLevel()->getBlock(new Vector3($x, $y, $z));
|
||||
$blockDecay = $this->getEffectiveFlowDecay($sideBlock);
|
||||
|
||||
if($blockDecay < 0){
|
||||
@ -314,7 +314,7 @@ abstract class Liquid extends Transparent{
|
||||
}elseif($j === 3){
|
||||
++$z;
|
||||
}
|
||||
$blockSide = $this->getLevel()->getBlock(Vector3::createVector($x, $y, $z));
|
||||
$blockSide = $this->getLevel()->getBlock(new Vector3($x, $y, $z));
|
||||
|
||||
if(!$blockSide->isFlowable and !($blockSide instanceof Liquid)){
|
||||
continue;
|
||||
@ -356,7 +356,7 @@ abstract class Liquid extends Transparent{
|
||||
}elseif($j === 3){
|
||||
++$z;
|
||||
}
|
||||
$block = $this->getLevel()->getBlock(Vector3::createVector($x, $y, $z));
|
||||
$block = $this->getLevel()->getBlock(new Vector3($x, $y, $z));
|
||||
|
||||
if(!$block->isFlowable and !($block instanceof Liquid)){
|
||||
continue;
|
||||
|
@ -42,7 +42,7 @@ class MelonStem extends Crops{
|
||||
if($this->meta < 0x07){
|
||||
$block = clone $this;
|
||||
++$block->meta;
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = BlockGrowEvent::createEvent($this, $block));
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($this, $block));
|
||||
if(!$ev->isCancelled()){
|
||||
$this->getLevel()->setBlock($this, $ev->getNewState(), true);
|
||||
}
|
||||
@ -58,7 +58,7 @@ class MelonStem extends Crops{
|
||||
$side = $this->getSide(mt_rand(2, 5));
|
||||
$d = $side->getSide(0);
|
||||
if($side->getID() === self::AIR and ($d->getID() === self::FARMLAND or $d->getID() === self::GRASS or $d->getID() === self::DIRT)){
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = BlockGrowEvent::createEvent($side, new Melon()));
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($side, new Melon()));
|
||||
if(!$ev->isCancelled()){
|
||||
$this->getLevel()->setBlock($side, $ev->getNewState(), true);
|
||||
}
|
||||
|
@ -24,7 +24,6 @@ namespace pocketmine\block;
|
||||
use pocketmine\event\block\BlockSpreadEvent;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\level\Level;
|
||||
use pocketmine\level\Position;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\Server;
|
||||
|
||||
@ -46,10 +45,10 @@ class Mycelium extends Solid{
|
||||
$x = mt_rand($this->x - 1, $this->x + 1);
|
||||
$y = mt_rand($this->y - 2, $this->y + 2);
|
||||
$z = mt_rand($this->z - 1, $this->z + 1);
|
||||
$block = $this->getLevel()->getBlock(Vector3::createVector($x, $y, $z));
|
||||
$block = $this->getLevel()->getBlock(new Vector3($x, $y, $z));
|
||||
if($block->getID() === Block::DIRT){
|
||||
if($block->getSide(1) instanceof Transparent){
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = BlockSpreadEvent::createEvent($block, $this, new Mycelium()));
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = new BlockSpreadEvent($block, $this, new Mycelium()));
|
||||
if(!$ev->isCancelled()){
|
||||
$this->getLevel()->setBlock($block, $ev->getNewState());
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ class PumpkinStem extends Crops{
|
||||
if($this->meta < 0x07){
|
||||
$block = clone $this;
|
||||
++$block->meta;
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = BlockGrowEvent::createEvent($this, $block));
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($this, $block));
|
||||
if(!$ev->isCancelled()){
|
||||
$this->getLevel()->setBlock($this, $ev->getNewState(), true);
|
||||
}
|
||||
@ -58,7 +58,7 @@ class PumpkinStem extends Crops{
|
||||
$side = $this->getSide(mt_rand(2, 5));
|
||||
$d = $side->getSide(0);
|
||||
if($side->getID() === self::AIR and ($d->getID() === self::FARMLAND or $d->getID() === self::GRASS or $d->getID() === self::DIRT)){
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = BlockGrowEvent::createEvent($side, new Pumpkin()));
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($side, new Pumpkin()));
|
||||
if(!$ev->isCancelled()){
|
||||
$this->getLevel()->setBlock($side, $ev->getNewState(), true);
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ class Slab extends Transparent{
|
||||
protected function recalculateBoundingBox(){
|
||||
|
||||
if(($this->meta & 0x08) > 0){
|
||||
return AxisAlignedBB::getBoundingBoxFromPool(
|
||||
return new AxisAlignedBB(
|
||||
$this->x,
|
||||
$this->y + 0.5,
|
||||
$this->z,
|
||||
@ -59,7 +59,7 @@ class Slab extends Transparent{
|
||||
$this->z + 1
|
||||
);
|
||||
}else{
|
||||
return AxisAlignedBB::getBoundingBoxFromPool(
|
||||
return new AxisAlignedBB(
|
||||
$this->x,
|
||||
$this->y,
|
||||
$this->z,
|
||||
|
@ -32,7 +32,7 @@ class SoulSand extends Solid{
|
||||
|
||||
protected function recalculateBoundingBox(){
|
||||
|
||||
return AxisAlignedBB::getBoundingBoxFromPool(
|
||||
return new AxisAlignedBB(
|
||||
$this->x,
|
||||
$this->y,
|
||||
$this->z,
|
||||
|
@ -116,7 +116,7 @@ abstract class Stair extends Transparent{
|
||||
protected function recalculateBoundingBox(){
|
||||
|
||||
if(($this->getDamage() & 0x04) > 0){
|
||||
return AxisAlignedBB::getBoundingBoxFromPool(
|
||||
return new AxisAlignedBB(
|
||||
$this->x,
|
||||
$this->y + 0.5,
|
||||
$this->z,
|
||||
@ -125,7 +125,7 @@ abstract class Stair extends Transparent{
|
||||
$this->z + 1
|
||||
);
|
||||
}else{
|
||||
return AxisAlignedBB::getBoundingBoxFromPool(
|
||||
return new AxisAlignedBB(
|
||||
$this->x,
|
||||
$this->y,
|
||||
$this->z,
|
||||
|
@ -22,6 +22,7 @@
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class Stone extends Solid{
|
||||
const NORMAL = 0;
|
||||
@ -45,6 +46,7 @@ class Stone extends Solid{
|
||||
self::POLISHED_DIORITE => "Polished Diorite",
|
||||
self::ANDESITE => "Andesite",
|
||||
self::POLISHED_ANDESITE => "Polished Andesite",
|
||||
7 => "Unknown Stone",
|
||||
];
|
||||
$this->name = $names[$this->meta & 0x07];
|
||||
}
|
||||
@ -67,7 +69,7 @@ class Stone extends Solid{
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
if($item->isPickaxe() >= 1){
|
||||
if($item->isPickaxe() >= Tool::TIER_WOODEN){
|
||||
return [
|
||||
[Item::COBBLESTONE, 0, 1],
|
||||
];
|
||||
|
@ -59,7 +59,7 @@ class StoneWall extends Transparent{
|
||||
$f3 = 0.6875;
|
||||
}
|
||||
|
||||
return AxisAlignedBB::getBoundingBoxFromPool(
|
||||
return new AxisAlignedBB(
|
||||
$this->x + $f,
|
||||
$this->y,
|
||||
$this->z + $f2,
|
||||
|
@ -49,9 +49,9 @@ class Sugarcane extends Flowable{
|
||||
if($item->getID() === Item::DYE and $item->getDamage() === 0x0F){ //Bonemeal
|
||||
if($this->getSide(0)->getID() !== self::SUGARCANE_BLOCK){
|
||||
for($y = 1; $y < 3; ++$y){
|
||||
$b = $this->getLevel()->getBlock(Vector3::createVector($this->x, $this->y + $y, $this->z));
|
||||
$b = $this->getLevel()->getBlock(new Vector3($this->x, $this->y + $y, $this->z));
|
||||
if($b->getID() === self::AIR){
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = BlockGrowEvent::createEvent($b, new Sugarcane()));
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($b, new Sugarcane()));
|
||||
if(!$ev->isCancelled()){
|
||||
$this->getLevel()->setBlock($b, $ev->getNewState(), true);
|
||||
}
|
||||
@ -83,7 +83,7 @@ class Sugarcane extends Flowable{
|
||||
if($this->getSide(0)->getID() !== self::SUGARCANE_BLOCK){
|
||||
if($this->meta === 0x0F){
|
||||
for($y = 1; $y < 3; ++$y){
|
||||
$b = $this->getLevel()->getBlock(Vector3::createVector($this->x, $this->y + $y, $this->z));
|
||||
$b = $this->getLevel()->getBlock(new Vector3($this->x, $this->y + $y, $this->z));
|
||||
if($b->getID() === self::AIR){
|
||||
$this->getLevel()->setBlock($b, new Sugarcane(), true);
|
||||
break;
|
||||
|
@ -63,7 +63,7 @@ abstract class Thin extends Transparent{
|
||||
$f3 = 1;
|
||||
}
|
||||
|
||||
return AxisAlignedBB::getBoundingBoxFromPool(
|
||||
return new AxisAlignedBB(
|
||||
$this->x + $f,
|
||||
$this->y,
|
||||
$this->z + $f2,
|
||||
|
@ -44,7 +44,7 @@ class Trapdoor extends Transparent{
|
||||
$f = 0.1875;
|
||||
|
||||
if(($damage & 0x08) > 0){
|
||||
$bb = AxisAlignedBB::getBoundingBoxFromPool(
|
||||
$bb = new AxisAlignedBB(
|
||||
$this->x,
|
||||
$this->y + 1 - $f,
|
||||
$this->z,
|
||||
@ -53,7 +53,7 @@ class Trapdoor extends Transparent{
|
||||
$this->z + 1
|
||||
);
|
||||
}else{
|
||||
$bb = AxisAlignedBB::getBoundingBoxFromPool(
|
||||
$bb = new AxisAlignedBB(
|
||||
$this->x,
|
||||
$this->y,
|
||||
$this->z,
|
||||
|
@ -93,7 +93,7 @@ class Vine extends Transparent{
|
||||
$f6 = 1;
|
||||
}
|
||||
|
||||
return AxisAlignedBB::getBoundingBoxFromPool(
|
||||
return new AxisAlignedBB(
|
||||
$this->x + $f1,
|
||||
$this->y + $f2,
|
||||
$this->z + $f3,
|
||||
|
@ -48,7 +48,7 @@ class WoodSlab extends Transparent{
|
||||
protected function recalculateBoundingBox(){
|
||||
|
||||
if(($this->meta & 0x08) > 0){
|
||||
return AxisAlignedBB::getBoundingBoxFromPool(
|
||||
return new AxisAlignedBB(
|
||||
$this->x,
|
||||
$this->y + 0.5,
|
||||
$this->z,
|
||||
@ -57,7 +57,7 @@ class WoodSlab extends Transparent{
|
||||
$this->z + 1
|
||||
);
|
||||
}else{
|
||||
return AxisAlignedBB::getBoundingBoxFromPool(
|
||||
return new AxisAlignedBB(
|
||||
$this->x,
|
||||
$this->y,
|
||||
$this->z,
|
||||
|
Reference in New Issue
Block a user