mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-04 17:20:02 +00:00
Added lily pad, checked some bounding boxes
This commit is contained in:
parent
6e69e15dfd
commit
ac4194eb3f
@ -40,6 +40,10 @@ class Air extends Transparent{
|
|||||||
return "Air";
|
return "Air";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function canPassThrough(){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public function isBreakable(Item $item){
|
public function isBreakable(Item $item){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -175,7 +175,8 @@ class Block extends Position implements Metadatable{
|
|||||||
const BRICK_STAIRS = 108;
|
const BRICK_STAIRS = 108;
|
||||||
const STONE_BRICK_STAIRS = 109;
|
const STONE_BRICK_STAIRS = 109;
|
||||||
const MYCELIUM = 110;
|
const MYCELIUM = 110;
|
||||||
|
const WATER_LILY = 111;
|
||||||
|
const LILY_PAD = 111;
|
||||||
const NETHER_BRICKS = 112;
|
const NETHER_BRICKS = 112;
|
||||||
const NETHER_BRICK_BLOCK = 112;
|
const NETHER_BRICK_BLOCK = 112;
|
||||||
|
|
||||||
@ -402,6 +403,7 @@ class Block extends Position implements Metadatable{
|
|||||||
self::$list[self::STONE_BRICK_STAIRS] = StoneBrickStairs::class;
|
self::$list[self::STONE_BRICK_STAIRS] = StoneBrickStairs::class;
|
||||||
|
|
||||||
self::$list[self::MYCELIUM] = Mycelium::class;
|
self::$list[self::MYCELIUM] = Mycelium::class;
|
||||||
|
self::$list[self::WATER_LILY] = WaterLily::class;
|
||||||
self::$list[self::NETHER_BRICKS] = NetherBrick::class;
|
self::$list[self::NETHER_BRICKS] = NetherBrick::class;
|
||||||
|
|
||||||
self::$list[self::NETHER_BRICKS_STAIRS] = NetherBrickStairs::class;
|
self::$list[self::NETHER_BRICKS_STAIRS] = NetherBrickStairs::class;
|
||||||
@ -671,6 +673,10 @@ class Block extends Position implements Metadatable{
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function canPassThrough(){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
@ -25,6 +25,7 @@ use pocketmine\item\Item;
|
|||||||
use pocketmine\level\Level;
|
use pocketmine\level\Level;
|
||||||
use pocketmine\level\sound\DoorSound;
|
use pocketmine\level\sound\DoorSound;
|
||||||
use pocketmine\math\AxisAlignedBB;
|
use pocketmine\math\AxisAlignedBB;
|
||||||
|
use pocketmine\math\Vector3;
|
||||||
use pocketmine\network\protocol\LevelEventPacket;
|
use pocketmine\network\protocol\LevelEventPacket;
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
use pocketmine\Server;
|
use pocketmine\Server;
|
||||||
@ -42,19 +43,19 @@ abstract class Door extends Transparent{
|
|||||||
|
|
||||||
private function getFullDamage(){
|
private function getFullDamage(){
|
||||||
$damage = $this->getDamage();
|
$damage = $this->getDamage();
|
||||||
$flag = ($damage & 0x08) > 0;
|
$isUp = ($damage & 0x08) > 0;
|
||||||
|
|
||||||
if($flag){
|
if($isUp){
|
||||||
$first = $this->getSide(0)->getDamage();
|
$down = $this->getSide(Vector3::SIDE_DOWN)->getDamage();
|
||||||
$second = $damage;
|
$up = $damage;
|
||||||
}else{
|
}else{
|
||||||
$first = $damage;
|
$down = $damage;
|
||||||
$second = $this->getSide(1)->getDamage();
|
$up = $this->getSide(Vector3::SIDE_UP)->getDamage();
|
||||||
}
|
}
|
||||||
|
|
||||||
$flag1 = ($second & 0x01) > 0;
|
$isRight = ($up & 0x01) > 0;
|
||||||
|
|
||||||
return $first & 0x07 | ($flag ? 8 : 0) | ($flag1 ? 0x10 : 0);
|
return $down & 0x07 | ($isUp ? 8 : 0) | ($isRight ? 0x10 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function recalculateBoundingBox(){
|
protected function recalculateBoundingBox(){
|
||||||
@ -72,12 +73,12 @@ abstract class Door extends Transparent{
|
|||||||
);
|
);
|
||||||
|
|
||||||
$j = $damage & 0x03;
|
$j = $damage & 0x03;
|
||||||
$flag = (($damage & 0x04) > 0);
|
$isOpen = (($damage & 0x04) > 0);
|
||||||
$flag1 = (($damage & 0x10) > 0);
|
$isRight = (($damage & 0x10) > 0);
|
||||||
|
|
||||||
if($j === 0){
|
if($j === 0){
|
||||||
if($flag){
|
if($isOpen){
|
||||||
if(!$flag1){
|
if(!$isRight){
|
||||||
$bb->setBounds(
|
$bb->setBounds(
|
||||||
$this->x,
|
$this->x,
|
||||||
$this->y,
|
$this->y,
|
||||||
@ -107,8 +108,8 @@ abstract class Door extends Transparent{
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}elseif($j === 1){
|
}elseif($j === 1){
|
||||||
if($flag){
|
if($isOpen){
|
||||||
if(!$flag1){
|
if(!$isRight){
|
||||||
$bb->setBounds(
|
$bb->setBounds(
|
||||||
$this->x + 1 - $f,
|
$this->x + 1 - $f,
|
||||||
$this->y,
|
$this->y,
|
||||||
@ -138,8 +139,8 @@ abstract class Door extends Transparent{
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}elseif($j === 2){
|
}elseif($j === 2){
|
||||||
if($flag){
|
if($isOpen){
|
||||||
if(!$flag1){
|
if(!$isRight){
|
||||||
$bb->setBounds(
|
$bb->setBounds(
|
||||||
$this->x,
|
$this->x,
|
||||||
$this->y,
|
$this->y,
|
||||||
@ -169,8 +170,8 @@ abstract class Door extends Transparent{
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}elseif($j === 3){
|
}elseif($j === 3){
|
||||||
if($flag){
|
if($isOpen){
|
||||||
if(!$flag1){
|
if(!$isRight){
|
||||||
$bb->setBounds(
|
$bb->setBounds(
|
||||||
$this->x,
|
$this->x,
|
||||||
$this->y,
|
$this->y,
|
||||||
|
@ -40,7 +40,7 @@ class PumpkinStem extends Crops{
|
|||||||
|
|
||||||
public function onUpdate($type){
|
public function onUpdate($type){
|
||||||
if($type === Level::BLOCK_UPDATE_NORMAL){
|
if($type === Level::BLOCK_UPDATE_NORMAL){
|
||||||
if($this->getSide(0)->isTransparent() === true){
|
if($this->getSide(0)->isTransparent()){
|
||||||
$this->getLevel()->useBreakOn($this);
|
$this->getLevel()->useBreakOn($this);
|
||||||
return Level::BLOCK_UPDATE_NORMAL;
|
return Level::BLOCK_UPDATE_NORMAL;
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ namespace pocketmine\block;
|
|||||||
|
|
||||||
|
|
||||||
use pocketmine\math\AxisAlignedBB;
|
use pocketmine\math\AxisAlignedBB;
|
||||||
|
use pocketmine\math\Vector3;
|
||||||
|
|
||||||
class StoneWall extends Transparent{
|
class StoneWall extends Transparent{
|
||||||
|
|
||||||
@ -50,36 +51,36 @@ class StoneWall extends Transparent{
|
|||||||
|
|
||||||
protected function recalculateBoundingBox(){
|
protected function recalculateBoundingBox(){
|
||||||
|
|
||||||
$flag = $this->canConnect($this->getSide(2));
|
$north = $this->canConnect($this->getSide(Vector3::SIDE_NORTH));
|
||||||
$flag1 = $this->canConnect($this->getSide(3));
|
$south = $this->canConnect($this->getSide(Vector3::SIDE_SOUTH));
|
||||||
$flag2 = $this->canConnect($this->getSide(4));
|
$west = $this->canConnect($this->getSide(Vector3::SIDE_WEST));
|
||||||
$flag3 = $this->canConnect($this->getSide(5));
|
$east = $this->canConnect($this->getSide(Vector3::SIDE_EAST));
|
||||||
|
|
||||||
$f = $flag2 ? 0 : 0.25;
|
$n = $north ? 0 : 0.25;
|
||||||
$f1 = $flag3 ? 1 : 0.75;
|
$s = $south ? 1 : 0.75;
|
||||||
$f2 = $flag ? 0 : 0.25;
|
$w = $west ? 0 : 0.25;
|
||||||
$f3 = $flag1 ? 1 : 0.75;
|
$e = $east ? 1 : 0.75;
|
||||||
|
|
||||||
if($flag and $flag1 and !$flag2 and !$flag3){
|
if($north and $south and !$west and !$east){
|
||||||
$f = 0.3125;
|
$w = 0.3125;
|
||||||
$f1 = 0.6875;
|
$e = 0.6875;
|
||||||
}elseif(!$flag and !$flag1 and $flag2 and $flag3){
|
}elseif(!$north and !$south and $west and $east){
|
||||||
$f2 = 0.3125;
|
$n = 0.3125;
|
||||||
$f3 = 0.6875;
|
$s = 0.6875;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new AxisAlignedBB(
|
return new AxisAlignedBB(
|
||||||
$this->x + $f,
|
$this->x + $w,
|
||||||
$this->y,
|
$this->y,
|
||||||
$this->z + $f2,
|
$this->z + $n,
|
||||||
$this->x + $f1,
|
$this->x + $e,
|
||||||
$this->y + 1.5,
|
$this->y + 1.5,
|
||||||
$this->z + $f3
|
$this->z + $s
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function canConnect(Block $block){
|
public function canConnect(Block $block){
|
||||||
return ($block->getId() !== self::COBBLE_WALL and $block->getId() !== self::FENCE_GATE) ? $block->isSolid() : true;
|
return ($block->getId() !== self::COBBLE_WALL and $block->getId() !== self::FENCE_GATE) ? $block->isSolid() and !$block->isTransparent() : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -48,6 +48,10 @@ class Vine extends Transparent{
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function canPassThrough(){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public function hasEntityCollision(){
|
public function hasEntityCollision(){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -118,7 +122,7 @@ class Vine extends Transparent{
|
|||||||
|
|
||||||
|
|
||||||
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
|
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
|
||||||
if($target->isSolid()){
|
if(!$target->isTransparent() and $target->isSolid()){
|
||||||
$faces = [
|
$faces = [
|
||||||
0 => 0,
|
0 => 0,
|
||||||
1 => 0,
|
1 => 0,
|
||||||
|
96
src/pocketmine/block/WaterLily.php
Normal file
96
src/pocketmine/block/WaterLily.php
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* ____ _ _ __ __ _ __ __ ____
|
||||||
|
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||||
|
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||||
|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||||
|
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* @author PocketMine Team
|
||||||
|
* @link http://www.pocketmine.net/
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace pocketmine\block;
|
||||||
|
|
||||||
|
use pocketmine\entity\Entity;
|
||||||
|
use pocketmine\item\Item;
|
||||||
|
use pocketmine\item\Tool;
|
||||||
|
use pocketmine\level\Level;
|
||||||
|
use pocketmine\math\AxisAlignedBB;
|
||||||
|
use pocketmine\math\Vector3;
|
||||||
|
use pocketmine\Player;
|
||||||
|
|
||||||
|
class WaterLily extends Flowable{
|
||||||
|
|
||||||
|
protected $id = self::WATER_LILY;
|
||||||
|
|
||||||
|
public function __construct($meta = 0){
|
||||||
|
$this->meta = $meta;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isSolid(){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName(){
|
||||||
|
return "Lily Pad";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getHardness(){
|
||||||
|
return 0.6;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function canPassThrough(){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function recalculateBoundingBox(){
|
||||||
|
return new AxisAlignedBB(
|
||||||
|
$this->x,
|
||||||
|
$this->y,
|
||||||
|
$this->z,
|
||||||
|
$this->x,
|
||||||
|
$this->y + 0.0625,
|
||||||
|
$this->z
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
|
||||||
|
if($target instanceof Water){
|
||||||
|
$up = $target->getSide(Vector3::SIDE_UP);
|
||||||
|
if($up->getId() === Block::AIR){
|
||||||
|
$this->getLevel()->setBlock($up, $this, true, true);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function onUpdate($type){
|
||||||
|
if($type === Level::BLOCK_UPDATE_NORMAL){
|
||||||
|
if(!($this->getSide(0) instanceof Water)){
|
||||||
|
$this->getLevel()->useBreakOn($this);
|
||||||
|
return Level::BLOCK_UPDATE_NORMAL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDrops(Item $item){
|
||||||
|
return [
|
||||||
|
[$this->id, 0, 1]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
@ -170,7 +170,8 @@ class Item{
|
|||||||
const BRICK_STAIRS = 108;
|
const BRICK_STAIRS = 108;
|
||||||
const STONE_BRICK_STAIRS = 109;
|
const STONE_BRICK_STAIRS = 109;
|
||||||
const MYCELIUM = 110;
|
const MYCELIUM = 110;
|
||||||
|
const WATER_LILY = 111;
|
||||||
|
const LILY_PAD = 111;
|
||||||
const NETHER_BRICKS = 112;
|
const NETHER_BRICKS = 112;
|
||||||
const NETHER_BRICK_BLOCK = 112;
|
const NETHER_BRICK_BLOCK = 112;
|
||||||
|
|
||||||
@ -606,7 +607,7 @@ class Item{
|
|||||||
//Decoration
|
//Decoration
|
||||||
self::addCreativeItem(Item::get(Item::COBBLESTONE_WALL, 0));
|
self::addCreativeItem(Item::get(Item::COBBLESTONE_WALL, 0));
|
||||||
self::addCreativeItem(Item::get(Item::COBBLESTONE_WALL, 1));
|
self::addCreativeItem(Item::get(Item::COBBLESTONE_WALL, 1));
|
||||||
//TODO: Lilly Pad
|
self::addCreativeItem(Item::get(Item::WATER_LILY, 0));
|
||||||
self::addCreativeItem(Item::get(Item::GOLD_BLOCK, 0));
|
self::addCreativeItem(Item::get(Item::GOLD_BLOCK, 0));
|
||||||
self::addCreativeItem(Item::get(Item::IRON_BLOCK, 0));
|
self::addCreativeItem(Item::get(Item::IRON_BLOCK, 0));
|
||||||
self::addCreativeItem(Item::get(Item::DIAMOND_BLOCK, 0));
|
self::addCreativeItem(Item::get(Item::DIAMOND_BLOCK, 0));
|
||||||
|
@ -1070,7 +1070,7 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
for($x = $minX; $x <= $maxX; ++$x){
|
for($x = $minX; $x <= $maxX; ++$x){
|
||||||
for($y = $minY; $y <= $maxY; ++$y){
|
for($y = $minY; $y <= $maxY; ++$y){
|
||||||
$block = $this->getBlock($this->temporalVector->setComponents($x, $y, $z));
|
$block = $this->getBlock($this->temporalVector->setComponents($x, $y, $z));
|
||||||
if($block->getId() !== 0 and $block->collidesWithBB($bb)){
|
if(!$block->canPassThrough() and $block->collidesWithBB($bb)){
|
||||||
$collides[] = $block->getBoundingBox();
|
$collides[] = $block->getBoundingBox();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user