mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-20 15:41:33 +00:00
Added Error -> Exception handling
This commit is contained in:
@@ -26,7 +26,7 @@ use pocketmine\block\Block;
|
||||
use pocketmine\event\entity\EntityBlockChangeEvent;
|
||||
use pocketmine\event\entity\EntityDamageEvent;
|
||||
use pocketmine\event\entity\EntityRegainHealthEvent;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Item as ItemItem;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\nbt\tag\Byte;
|
||||
use pocketmine\nbt\tag\Int;
|
||||
@@ -58,8 +58,8 @@ class FallingSand extends Entity{
|
||||
$this->namedtag["TileID"] = new Int("TileID", $this->blockId);
|
||||
}
|
||||
|
||||
if(isset($this->namedtag->TileData)){
|
||||
$this->damage = $this->namedtag["TileData"];
|
||||
if(isset($this->namedtag->Data)){
|
||||
$this->damage = $this->namedtag["Data"];
|
||||
}
|
||||
|
||||
if($this->blockId === 0){
|
||||
@@ -115,7 +115,7 @@ class FallingSand extends Entity{
|
||||
$this->kill();
|
||||
$block = $this->level->getBlock($pos);
|
||||
if(!$block->isFullBlock){
|
||||
$this->getLevel()->dropItem($this, Item::get($this->getBlock(), $this->getDamage(), 1));
|
||||
$this->getLevel()->dropItem($this, ItemItem::get($this->getBlock(), $this->getDamage(), 1));
|
||||
}else{
|
||||
$this->server->getPluginManager()->callEvent($ev = EntityBlockChangeEvent::createEvent($this, $block, Block::get($this->getBlock(), $this->getDamage())));
|
||||
if(!$ev->isCancelled()){
|
||||
|
@@ -23,7 +23,7 @@ namespace pocketmine\entity;
|
||||
|
||||
use pocketmine\inventory\InventoryHolder;
|
||||
use pocketmine\inventory\PlayerInventory;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Item as ItemItem;
|
||||
use pocketmine\nbt\NBT;
|
||||
use pocketmine\nbt\tag\Byte;
|
||||
use pocketmine\nbt\tag\Compound;
|
||||
@@ -67,9 +67,9 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
|
||||
if($item["Slot"] >= 0 and $item["Slot"] < 9){ //Hotbar
|
||||
$this->inventory->setHotbarSlotIndex($item["Slot"], isset($item["TrueSlot"]) ? $item["TrueSlot"] : -1);
|
||||
}elseif($item["Slot"] >= 100 and $item["Slot"] < 104){ //Armor
|
||||
$this->inventory->setItem($this->inventory->getSize() + $item["Slot"] - 100, Item::get($item["id"], $item["Damage"], $item["Count"]), $this);
|
||||
$this->inventory->setItem($this->inventory->getSize() + $item["Slot"] - 100, ItemItem::get($item["id"], $item["Damage"], $item["Count"]), $this);
|
||||
}else{
|
||||
$this->inventory->setItem($item["Slot"] - 9, Item::get($item["id"], $item["Damage"], $item["Count"]), $this);
|
||||
$this->inventory->setItem($item["Slot"] - 9, ItemItem::get($item["id"], $item["Damage"], $item["Count"]), $this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
|
||||
//Armor
|
||||
for($slot = 100; $slot < 104; ++$slot){
|
||||
$item = $this->inventory->getItem($this->inventory->getSize() + $slot - 100);
|
||||
if($item instanceof Item and $item->getID() !== Item::AIR){
|
||||
if($item instanceof ItemItem and $item->getID() !== ItemItem::AIR){
|
||||
$this->namedtag->Inventory[$slot] = new Compound(false, [
|
||||
new Byte("Count", $item->getCount()),
|
||||
new Short("Damage", $item->getDamage()),
|
||||
|
@@ -28,7 +28,7 @@ use pocketmine\event\entity\EntityDamageEvent;
|
||||
use pocketmine\event\entity\EntityDeathEvent;
|
||||
use pocketmine\event\entity\EntityRegainHealthEvent;
|
||||
use pocketmine\event\Timings;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Item as ItemItem;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\nbt\tag\Short;
|
||||
use pocketmine\network\protocol\EntityEventPacket;
|
||||
@@ -163,7 +163,7 @@ abstract class Living extends Entity implements Damageable{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Item[]
|
||||
* @return ItemItem[]
|
||||
*/
|
||||
public function getDrops(){
|
||||
return [];
|
||||
|
@@ -23,7 +23,7 @@ namespace pocketmine\entity;
|
||||
|
||||
|
||||
use pocketmine\event\entity\EntityDamageByEntityEvent;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Item as ItemItem;
|
||||
use pocketmine\nbt\tag\String;
|
||||
use pocketmine\network\protocol\AddMobPacket;
|
||||
use pocketmine\network\protocol\SetEntityMotionPacket;
|
||||
@@ -83,19 +83,19 @@ class Zombie extends Monster{
|
||||
|
||||
public function getDrops(){
|
||||
$drops = [
|
||||
Item::get(Item::FEATHER, 0, 1)
|
||||
ItemItem::get(Item::FEATHER, 0, 1)
|
||||
];
|
||||
if($this->lastDamageCause instanceof EntityDamageByEntityEvent and $this->lastDamageCause->getEntity() instanceof Player){
|
||||
if(mt_rand(0, 199) < 5){
|
||||
switch(mt_rand(0, 2)){
|
||||
case 0:
|
||||
$drops[] = Item::get(Item::IRON_INGOT, 0, 1);
|
||||
$drops[] = ItemItem::get(ItemItem::IRON_INGOT, 0, 1);
|
||||
break;
|
||||
case 1:
|
||||
$drops[] = Item::get(Item::CARROT, 0, 1);
|
||||
$drops[] = ItemItem::get(ItemItem::CARROT, 0, 1);
|
||||
break;
|
||||
case 2:
|
||||
$drops[] = Item::get(Item::POTATO, 0, 1);
|
||||
$drops[] = ItemItem::get(ItemItem::POTATO, 0, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user