mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-15 18:29:46 +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";
|
||||
}
|
||||
|
||||
public function canPassThrough(){
|
||||
return true;
|
||||
}
|
||||
|
||||
public function isBreakable(Item $item){
|
||||
return false;
|
||||
}
|
||||
|
@ -175,7 +175,8 @@ class Block extends Position implements Metadatable{
|
||||
const BRICK_STAIRS = 108;
|
||||
const STONE_BRICK_STAIRS = 109;
|
||||
const MYCELIUM = 110;
|
||||
|
||||
const WATER_LILY = 111;
|
||||
const LILY_PAD = 111;
|
||||
const NETHER_BRICKS = 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::MYCELIUM] = Mycelium::class;
|
||||
self::$list[self::WATER_LILY] = WaterLily::class;
|
||||
self::$list[self::NETHER_BRICKS] = NetherBrick::class;
|
||||
|
||||
self::$list[self::NETHER_BRICKS_STAIRS] = NetherBrickStairs::class;
|
||||
@ -671,6 +673,10 @@ class Block extends Position implements Metadatable{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function canPassThrough(){
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
|
@ -25,6 +25,7 @@ use pocketmine\item\Item;
|
||||
use pocketmine\level\Level;
|
||||
use pocketmine\level\sound\DoorSound;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\network\protocol\LevelEventPacket;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\Server;
|
||||
@ -42,19 +43,19 @@ abstract class Door extends Transparent{
|
||||
|
||||
private function getFullDamage(){
|
||||
$damage = $this->getDamage();
|
||||
$flag = ($damage & 0x08) > 0;
|
||||
$isUp = ($damage & 0x08) > 0;
|
||||
|
||||
if($flag){
|
||||
$first = $this->getSide(0)->getDamage();
|
||||
$second = $damage;
|
||||
if($isUp){
|
||||
$down = $this->getSide(Vector3::SIDE_DOWN)->getDamage();
|
||||
$up = $damage;
|
||||
}else{
|
||||
$first = $damage;
|
||||
$second = $this->getSide(1)->getDamage();
|
||||
$down = $damage;
|
||||
$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(){
|
||||
@ -72,12 +73,12 @@ abstract class Door extends Transparent{
|
||||
);
|
||||
|
||||
$j = $damage & 0x03;
|
||||
$flag = (($damage & 0x04) > 0);
|
||||
$flag1 = (($damage & 0x10) > 0);
|
||||
$isOpen = (($damage & 0x04) > 0);
|
||||
$isRight = (($damage & 0x10) > 0);
|
||||
|
||||
if($j === 0){
|
||||
if($flag){
|
||||
if(!$flag1){
|
||||
if($isOpen){
|
||||
if(!$isRight){
|
||||
$bb->setBounds(
|
||||
$this->x,
|
||||
$this->y,
|
||||
@ -107,8 +108,8 @@ abstract class Door extends Transparent{
|
||||
);
|
||||
}
|
||||
}elseif($j === 1){
|
||||
if($flag){
|
||||
if(!$flag1){
|
||||
if($isOpen){
|
||||
if(!$isRight){
|
||||
$bb->setBounds(
|
||||
$this->x + 1 - $f,
|
||||
$this->y,
|
||||
@ -138,8 +139,8 @@ abstract class Door extends Transparent{
|
||||
);
|
||||
}
|
||||
}elseif($j === 2){
|
||||
if($flag){
|
||||
if(!$flag1){
|
||||
if($isOpen){
|
||||
if(!$isRight){
|
||||
$bb->setBounds(
|
||||
$this->x,
|
||||
$this->y,
|
||||
@ -169,8 +170,8 @@ abstract class Door extends Transparent{
|
||||
);
|
||||
}
|
||||
}elseif($j === 3){
|
||||
if($flag){
|
||||
if(!$flag1){
|
||||
if($isOpen){
|
||||
if(!$isRight){
|
||||
$bb->setBounds(
|
||||
$this->x,
|
||||
$this->y,
|
||||
|
@ -40,7 +40,7 @@ class PumpkinStem extends Crops{
|
||||
|
||||
public function onUpdate($type){
|
||||
if($type === Level::BLOCK_UPDATE_NORMAL){
|
||||
if($this->getSide(0)->isTransparent() === true){
|
||||
if($this->getSide(0)->isTransparent()){
|
||||
$this->getLevel()->useBreakOn($this);
|
||||
return Level::BLOCK_UPDATE_NORMAL;
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ namespace pocketmine\block;
|
||||
|
||||
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Vector3;
|
||||
|
||||
class StoneWall extends Transparent{
|
||||
|
||||
@ -50,36 +51,36 @@ class StoneWall extends Transparent{
|
||||
|
||||
protected function recalculateBoundingBox(){
|
||||
|
||||
$flag = $this->canConnect($this->getSide(2));
|
||||
$flag1 = $this->canConnect($this->getSide(3));
|
||||
$flag2 = $this->canConnect($this->getSide(4));
|
||||
$flag3 = $this->canConnect($this->getSide(5));
|
||||
$north = $this->canConnect($this->getSide(Vector3::SIDE_NORTH));
|
||||
$south = $this->canConnect($this->getSide(Vector3::SIDE_SOUTH));
|
||||
$west = $this->canConnect($this->getSide(Vector3::SIDE_WEST));
|
||||
$east = $this->canConnect($this->getSide(Vector3::SIDE_EAST));
|
||||
|
||||
$f = $flag2 ? 0 : 0.25;
|
||||
$f1 = $flag3 ? 1 : 0.75;
|
||||
$f2 = $flag ? 0 : 0.25;
|
||||
$f3 = $flag1 ? 1 : 0.75;
|
||||
$n = $north ? 0 : 0.25;
|
||||
$s = $south ? 1 : 0.75;
|
||||
$w = $west ? 0 : 0.25;
|
||||
$e = $east ? 1 : 0.75;
|
||||
|
||||
if($flag and $flag1 and !$flag2 and !$flag3){
|
||||
$f = 0.3125;
|
||||
$f1 = 0.6875;
|
||||
}elseif(!$flag and !$flag1 and $flag2 and $flag3){
|
||||
$f2 = 0.3125;
|
||||
$f3 = 0.6875;
|
||||
if($north and $south and !$west and !$east){
|
||||
$w = 0.3125;
|
||||
$e = 0.6875;
|
||||
}elseif(!$north and !$south and $west and $east){
|
||||
$n = 0.3125;
|
||||
$s = 0.6875;
|
||||
}
|
||||
|
||||
return new AxisAlignedBB(
|
||||
$this->x + $f,
|
||||
$this->x + $w,
|
||||
$this->y,
|
||||
$this->z + $f2,
|
||||
$this->x + $f1,
|
||||
$this->z + $n,
|
||||
$this->x + $e,
|
||||
$this->y + 1.5,
|
||||
$this->z + $f3
|
||||
$this->z + $s
|
||||
);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public function canPassThrough(){
|
||||
return true;
|
||||
}
|
||||
|
||||
public function hasEntityCollision(){
|
||||
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){
|
||||
if($target->isSolid()){
|
||||
if(!$target->isTransparent() and $target->isSolid()){
|
||||
$faces = [
|
||||
0 => 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 STONE_BRICK_STAIRS = 109;
|
||||
const MYCELIUM = 110;
|
||||
|
||||
const WATER_LILY = 111;
|
||||
const LILY_PAD = 111;
|
||||
const NETHER_BRICKS = 112;
|
||||
const NETHER_BRICK_BLOCK = 112;
|
||||
|
||||
@ -606,7 +607,7 @@ class Item{
|
||||
//Decoration
|
||||
self::addCreativeItem(Item::get(Item::COBBLESTONE_WALL, 0));
|
||||
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::IRON_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($y = $minY; $y <= $maxY; ++$y){
|
||||
$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();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user