mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-19 15:35:52 +00:00
Removed a bunch of TODO and fixed item drops on block update
This commit is contained in:
parent
1eec333501
commit
b26ee09f76
@ -906,46 +906,6 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
return;
|
||||
}
|
||||
|
||||
/*public function eventHandler($data, $event){
|
||||
switch($event){
|
||||
//TODO, obsolete
|
||||
case "tile.update":
|
||||
if($data->getLevel() === $this->getLevel()){
|
||||
if($data instanceof Furnace){
|
||||
foreach($this->windows as $id => $w){
|
||||
if($w === $data){
|
||||
$pk = new ContainerSetDataPacket;
|
||||
$pk->windowid = $id;
|
||||
$pk->property = 0; //Smelting
|
||||
$pk->value = floor($data->namedtag->CookTime);
|
||||
$this->dataPacket($pk);
|
||||
|
||||
$pk = new ContainerSetDataPacket;
|
||||
$pk->windowid = $id;
|
||||
$pk->property = 1; //Fire icon
|
||||
$pk->value = $data->namedtag->BurnTicks;
|
||||
$this->dataPacket($pk);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "entity.metadata":
|
||||
if($data->getID() === $this->id){
|
||||
$eid = 0;
|
||||
}else{
|
||||
$eid = $data->getID();
|
||||
}
|
||||
if($data->getLevel() === $this->getLevel()){
|
||||
$pk = new SetEntityDataPacket;
|
||||
$pk->eid = $eid;
|
||||
$pk->metadata = $data->getDamage();
|
||||
$this->dataPacket($pk);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
|
||||
/**
|
||||
* @param string $achievementId
|
||||
*
|
||||
@ -2152,7 +2112,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
$this->awardAchievement("makeBread");
|
||||
break;
|
||||
case Item::CAKE:
|
||||
//TODO: detect complex recipes like cake that leave remainings
|
||||
//TODO: detect complex recipes like cake that leave remains
|
||||
$this->awardAchievement("bakeCake");
|
||||
$this->inventory->addItem(Item::get(Item::BUCKET, 0, 3));
|
||||
break;
|
||||
@ -2611,56 +2571,4 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* TODO death reasons
|
||||
if(is_numeric($data["cause"])){
|
||||
$e = Entity::get($data["cause"]);
|
||||
if($e instanceof Entity){
|
||||
switch($e->class){
|
||||
case ENTITY_PLAYER:
|
||||
$message = " was killed by " . $e->name;
|
||||
break;
|
||||
default:
|
||||
$message = " was killed";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
switch($data["cause"]){
|
||||
case "cactus":
|
||||
$message = " was pricked to death";
|
||||
break;
|
||||
case "lava":
|
||||
$message = " tried to swim in lava";
|
||||
break;
|
||||
case "fire":
|
||||
$message = " went up in flames";
|
||||
break;
|
||||
case "burning":
|
||||
$message = " burned to death";
|
||||
break;
|
||||
case "suffocation":
|
||||
$message = " suffocated in a wall";
|
||||
break;
|
||||
case "water":
|
||||
$message = " drowned";
|
||||
break;
|
||||
case "void":
|
||||
$message = " fell out of the world";
|
||||
break;
|
||||
case "fall":
|
||||
$message = " hit the ground too hard";
|
||||
break;
|
||||
case "explosion":
|
||||
$message = " blew up";
|
||||
break;
|
||||
default:
|
||||
$message = " died";
|
||||
break;
|
||||
}
|
||||
}
|
||||
Player::broadcastMessage($data["player"]->getName() . $message);
|
||||
*/
|
||||
}
|
@ -363,7 +363,6 @@ class Block extends Position implements Metadatable{
|
||||
[Item::STONECUTTER, 0],
|
||||
[Item::CHEST, 0],
|
||||
[Item::FURNACE, 0],
|
||||
//TODO: End Portal
|
||||
[Item::END_PORTAL, 0],
|
||||
[Item::DANDELION, 0],
|
||||
[Item::POPPY, 0],
|
||||
|
@ -81,9 +81,8 @@ class Carpet extends Flowable{
|
||||
|
||||
public function onUpdate($type){
|
||||
if($type === Level::BLOCK_UPDATE_NORMAL){
|
||||
if($this->getSide(0)->getID() === self::AIR){ //TODO: Replace with common break method
|
||||
$this->getLevel()->dropItem($this, Item::get($this->id, $this->meta, 1));
|
||||
$this->getLevel()->setBlock($this, new Air(), true);
|
||||
if($this->getSide(0)->getID() === self::AIR){
|
||||
$this->getLevel()->useBreakOn($this);
|
||||
|
||||
return Level::BLOCK_UPDATE_NORMAL;
|
||||
}
|
||||
|
@ -49,9 +49,8 @@ class CyanFlower extends Flowable{
|
||||
|
||||
public function onUpdate($type){
|
||||
if($type === Level::BLOCK_UPDATE_NORMAL){
|
||||
if($this->getSide(0)->isTransparent === true){ //TODO: Replace with common break method
|
||||
$this->getLevel()->dropItem($this, Item::get($this->id, 0, 1));
|
||||
$this->getLevel()->setBlock($this, new Air(), false, false, true);
|
||||
if($this->getSide(0)->isTransparent === true){
|
||||
$this->getLevel()->useBreakOn($this);
|
||||
|
||||
return Level::BLOCK_UPDATE_NORMAL;
|
||||
}
|
||||
|
@ -49,10 +49,8 @@ class Dandelion extends Flowable{
|
||||
|
||||
public function onUpdate($type){
|
||||
if($type === Level::BLOCK_UPDATE_NORMAL){
|
||||
if($this->getSide(0)->isTransparent === true){ //Replace with common break method
|
||||
//TODO
|
||||
//Server::getInstance()->api->entity->drop($this, Item::get($this->id));
|
||||
$this->getLevel()->setBlock($this, new Air(), false, false, true);
|
||||
if($this->getSide(0)->isTransparent === true){
|
||||
$this->getLevel()->useBreakOn($this);
|
||||
|
||||
return Level::BLOCK_UPDATE_NORMAL;
|
||||
}
|
||||
|
@ -38,10 +38,8 @@ class RedMushroom extends Flowable{
|
||||
|
||||
public function onUpdate($type){
|
||||
if($type === Level::BLOCK_UPDATE_NORMAL){
|
||||
if($this->getSide(0)->isTransparent === true){ //Replace with common break method
|
||||
//TODO
|
||||
//Server::getInstance()->api->entity->drop($this, Item::get($this->id));
|
||||
$this->getLevel()->setBlock($this, new Air(), false);
|
||||
if($this->getSide(0)->isTransparent === true){
|
||||
$this->getLevel()->useBreakOn($this);
|
||||
|
||||
return Level::BLOCK_UPDATE_NORMAL;
|
||||
}
|
||||
|
@ -81,10 +81,8 @@ class Sapling extends Flowable{
|
||||
|
||||
public function onUpdate($type){
|
||||
if($type === Level::BLOCK_UPDATE_NORMAL){
|
||||
if($this->getSide(0)->isTransparent === true){ //Replace with common break method
|
||||
//TODO
|
||||
//Server::getInstance()->api->entity->drop($this, Item::get($this->id));
|
||||
$this->getLevel()->setBlock($this, new Air(), false, false, true);
|
||||
if($this->getSide(0)->isTransparent === true){
|
||||
$this->getLevel()->useBreakOn($this);
|
||||
|
||||
return Level::BLOCK_UPDATE_NORMAL;
|
||||
}
|
||||
|
@ -64,10 +64,8 @@ class SignPost extends Transparent{
|
||||
|
||||
public function onUpdate($type){
|
||||
if($type === Level::BLOCK_UPDATE_NORMAL){
|
||||
if($this->getSide(0)->getID() === self::AIR){ //Replace with common break method
|
||||
//TODO
|
||||
//Server::getInstance()->api->entity->drop($this, Item::get(SIGN, 0, 1));
|
||||
$this->getLevel()->setBlock($this, new Air(), true, true, true);
|
||||
if($this->getSide(0)->getID() === self::AIR){
|
||||
$this->getLevel()->useBreakOn($this);
|
||||
|
||||
return Level::BLOCK_UPDATE_NORMAL;
|
||||
}
|
||||
|
@ -74,10 +74,8 @@ class Sugarcane extends Flowable{
|
||||
public function onUpdate($type){
|
||||
if($type === Level::BLOCK_UPDATE_NORMAL){
|
||||
$down = $this->getSide(0);
|
||||
if($down->isTransparent === true and $down->getID() !== self::SUGARCANE_BLOCK){ //Replace with common break method
|
||||
//TODO
|
||||
//Server::getInstance()->api->entity->drop($this, Item::get(SUGARCANE));
|
||||
$this->getLevel()->setBlock($this, new Air(), false, false, true);
|
||||
if($down->isTransparent === true and $down->getID() !== self::SUGARCANE_BLOCK){
|
||||
$this->getLevel()->useBreakOn($this);
|
||||
|
||||
return Level::BLOCK_UPDATE_NORMAL;
|
||||
}
|
||||
|
@ -45,9 +45,7 @@ class KillCommand extends VanillaCommand{
|
||||
}
|
||||
|
||||
if($sender instanceof Player){
|
||||
//TODO: EntityDamageEvent
|
||||
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = new EntityDamageEvent($sender, EntityDamageEvent::CAUSE_SUICIDE, 1000));
|
||||
$sender->getServer()->getPluginManager()->callEvent($ev = new EntityDamageEvent($sender, EntityDamageEvent::CAUSE_SUICIDE, 1000));
|
||||
|
||||
if($ev->isCancelled()){
|
||||
return true;
|
||||
|
@ -1151,7 +1151,7 @@ abstract class Entity extends Position implements Metadatable{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getID(){
|
||||
public function getId(){
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
|
@ -34,19 +34,21 @@ use pocketmine\entity\Vehicle;
|
||||
class EntityDespawnEvent extends EntityEvent{
|
||||
public static $handlerList = null;
|
||||
|
||||
private $entityType;
|
||||
|
||||
/**
|
||||
* @param Entity $entity
|
||||
*/
|
||||
public function __construct(Entity $entity){
|
||||
$this->entity = $entity;
|
||||
$this->entityType = $entity::NETWORK_ID;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getType(){
|
||||
//TODO: implement Entity types
|
||||
return -1;
|
||||
return $this->entityType;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -34,11 +34,14 @@ use pocketmine\entity\Vehicle;
|
||||
class EntitySpawnEvent extends EntityEvent{
|
||||
public static $handlerList = null;
|
||||
|
||||
private $entityType;
|
||||
|
||||
/**
|
||||
* @param Entity $entity
|
||||
*/
|
||||
public function __construct(Entity $entity){
|
||||
$this->entity = $entity;
|
||||
$this->entityType = $entity::NETWORK_ID;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -52,8 +55,7 @@ class EntitySpawnEvent extends EntityEvent{
|
||||
* @return int
|
||||
*/
|
||||
public function getType(){
|
||||
//TODO: implement Entity types
|
||||
return -1;
|
||||
return $this->entityType;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -38,8 +38,6 @@ abstract class Tile extends Position{
|
||||
const CHEST = "Chest";
|
||||
const FURNACE = "Furnace";
|
||||
|
||||
//TODO: pre-close step NBT data saving method
|
||||
|
||||
public static $tileCount = 1;
|
||||
|
||||
/** @var Chunk */
|
||||
|
Loading…
x
Reference in New Issue
Block a user