mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-11 14:05:35 +00:00
Merge branch 'master' of github.com:PocketMine/PocketMine-MP
This commit is contained in:
commit
23d1532ff9
@ -29,6 +29,7 @@ use pocketmine\nbt\tag\Compound;
|
|||||||
use pocketmine\nbt\tag\Double;
|
use pocketmine\nbt\tag\Double;
|
||||||
use pocketmine\nbt\tag\Enum;
|
use pocketmine\nbt\tag\Enum;
|
||||||
use pocketmine\nbt\tag\Float;
|
use pocketmine\nbt\tag\Float;
|
||||||
|
use pocketmine\nbt\tag\Int;
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
|
|
||||||
abstract class Fallable extends Solid{
|
abstract class Fallable extends Solid{
|
||||||
@ -60,7 +61,8 @@ abstract class Fallable extends Solid{
|
|||||||
new Float("", 0),
|
new Float("", 0),
|
||||||
new Float("", 0)
|
new Float("", 0)
|
||||||
]),
|
]),
|
||||||
"Tile" => new Byte("Tile", $this->getID())
|
"TileID" => new Int("TileID", $this->getID()),
|
||||||
|
"Data" => new Byte("Data", $this->getDamage()),
|
||||||
]));
|
]));
|
||||||
|
|
||||||
$fall->spawnToAll();
|
$fall->spawnToAll();
|
||||||
|
@ -29,6 +29,7 @@ use pocketmine\event\entity\EntityRegainHealthEvent;
|
|||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
use pocketmine\math\Vector3;
|
use pocketmine\math\Vector3;
|
||||||
use pocketmine\nbt\tag\Byte;
|
use pocketmine\nbt\tag\Byte;
|
||||||
|
use pocketmine\nbt\tag\Int;
|
||||||
use pocketmine\nbt\tag\String;
|
use pocketmine\nbt\tag\String;
|
||||||
use pocketmine\network\protocol\AddEntityPacket;
|
use pocketmine\network\protocol\AddEntityPacket;
|
||||||
use pocketmine\network\protocol\SetEntityMotionPacket;
|
use pocketmine\network\protocol\SetEntityMotionPacket;
|
||||||
@ -45,13 +46,18 @@ class FallingBlock extends Entity{
|
|||||||
protected $gravity = 0.04;
|
protected $gravity = 0.04;
|
||||||
protected $drag = 0.02;
|
protected $drag = 0.02;
|
||||||
protected $blockId = 0;
|
protected $blockId = 0;
|
||||||
|
protected $damage;
|
||||||
|
|
||||||
public $canCollide = false;
|
public $canCollide = false;
|
||||||
|
|
||||||
protected function initEntity(){
|
protected function initEntity(){
|
||||||
$this->namedtag->id = new String("id", "FallingSand");
|
$this->namedtag->id = new String("id", "FallingSand");
|
||||||
if(isset($this->namedtag->Tile)){
|
if(isset($this->namedtag->TileID)){
|
||||||
|
$this->blockId = $this->namedtag["TileID"];
|
||||||
|
}
|
||||||
|
elseif(isset($this->namedtag->Tile)){
|
||||||
$this->blockId = $this->namedtag["Tile"];
|
$this->blockId = $this->namedtag["Tile"];
|
||||||
|
$this->namedtag["TileID"] = new Int("TileID", $this->blockId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->blockId === 0){
|
if($this->blockId === 0){
|
||||||
@ -107,9 +113,9 @@ class FallingBlock extends Entity{
|
|||||||
$this->kill();
|
$this->kill();
|
||||||
$block = $this->level->getBlock($pos);
|
$block = $this->level->getBlock($pos);
|
||||||
if(!$block->isFullBlock){
|
if(!$block->isFullBlock){
|
||||||
$this->getLevel()->dropItem($this, Item::get($this->getBlock(), 0, 1));
|
$this->getLevel()->dropItem($this, Item::get($this->getBlock(), $this->getDamage(), 1));
|
||||||
}else{
|
}else{
|
||||||
$this->server->getPluginManager()->callEvent($ev = new EntityBlockChangeEvent($this, $block, Block::get($this->getBlock(), 0)));
|
$this->server->getPluginManager()->callEvent($ev = new EntityBlockChangeEvent($this, $block, Block::get($this->getBlock(), $this->getDamage())));
|
||||||
if(!$ev->isCancelled()){
|
if(!$ev->isCancelled()){
|
||||||
$this->getLevel()->setBlock($pos, $ev->getTo(), true);
|
$this->getLevel()->setBlock($pos, $ev->getTo(), true);
|
||||||
}
|
}
|
||||||
@ -126,9 +132,13 @@ class FallingBlock extends Entity{
|
|||||||
public function getBlock(){
|
public function getBlock(){
|
||||||
return $this->blockId;
|
return $this->blockId;
|
||||||
}
|
}
|
||||||
|
public function getDamage(){
|
||||||
|
return $this->damage;
|
||||||
|
}
|
||||||
|
|
||||||
public function saveNBT(){
|
public function saveNBT(){
|
||||||
$this->namedtag->Tile = new Byte("Tile", $this->blockId);
|
$this->namedtag->TileID = new Int("TileID", $this->blockId);
|
||||||
|
$this->namedtag->Data = new Byte("Data", $this->damage);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function attack($damage, $source = EntityDamageEvent::CAUSE_MAGIC){
|
public function attack($damage, $source = EntityDamageEvent::CAUSE_MAGIC){
|
||||||
@ -157,4 +167,4 @@ class FallingBlock extends Entity{
|
|||||||
|
|
||||||
parent::spawnTo($player);
|
parent::spawnTo($player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -126,6 +126,7 @@ abstract class BaseInventory implements Inventory{
|
|||||||
return false;
|
return false;
|
||||||
}elseif($item->getID() === 0 or $item->getCount() <= 0){
|
}elseif($item->getID() === 0 or $item->getCount() <= 0){
|
||||||
$this->clear($index, $source);
|
$this->clear($index, $source);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$holder = $this->getHolder();
|
$holder = $this->getHolder();
|
||||||
@ -426,4 +427,4 @@ abstract class BaseInventory implements Inventory{
|
|||||||
return $this->type;
|
return $this->type;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -166,35 +166,35 @@ class PlayerInventory extends BaseInventory{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getHelmet(){
|
public function getHelmet(){
|
||||||
return $this->getItem($this->getSize() + 3);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getChestplate(){
|
|
||||||
return $this->getItem($this->getSize() + 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getLeggings(){
|
|
||||||
return $this->getItem($this->getSize() + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getBoots(){
|
|
||||||
return $this->getItem($this->getSize());
|
return $this->getItem($this->getSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getChestplate(){
|
||||||
|
return $this->getItem($this->getSize() + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getLeggings(){
|
||||||
|
return $this->getItem($this->getSize() + 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getBoots(){
|
||||||
|
return $this->getItem($this->getSize() + 3);
|
||||||
|
}
|
||||||
|
|
||||||
public function setHelmet(Item $helmet){
|
public function setHelmet(Item $helmet){
|
||||||
return $this->setItem($this->getSize() + 3, $helmet);
|
return $this->setItem($this->getSize(), $helmet);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setChestplate(Item $chestplate){
|
public function setChestplate(Item $chestplate){
|
||||||
return $this->setItem($this->getSize() + 2, $chestplate);
|
return $this->setItem($this->getSize() + 1, $chestplate);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setLeggings(Item $leggings){
|
public function setLeggings(Item $leggings){
|
||||||
return $this->setItem($this->getSize() + 1, $leggings);
|
return $this->setItem($this->getSize() + 2, $leggings);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setBoots(Item $boots){
|
public function setBoots(Item $boots){
|
||||||
return $this->setItem($this->getSize(), $boots);
|
return $this->setItem($this->getSize() + 3, $boots);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setItem($index, Item $item, $source = null){
|
public function setItem($index, Item $item, $source = null){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user