mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-16 10:49:10 +00:00
Merge branch 'next-major' into modern-world-support
This commit is contained in:
commit
f97c22c341
@ -41,7 +41,7 @@ class DoubleChestInventory extends BaseInventory implements BlockInventory, Inve
|
|||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInventory(){
|
public function getInventory() : self{
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,17 +56,11 @@ class Barrel extends Spawnable implements Container, Nameable{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function getInventory() : BarrelInventory{
|
||||||
* @return BarrelInventory
|
|
||||||
*/
|
|
||||||
public function getInventory(){
|
|
||||||
return $this->inventory;
|
return $this->inventory;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function getRealInventory() : BarrelInventory{
|
||||||
* @return BarrelInventory
|
|
||||||
*/
|
|
||||||
public function getRealInventory(){
|
|
||||||
return $this->inventory;
|
return $this->inventory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,17 +112,11 @@ class BrewingStand extends Spawnable implements Container, Nameable{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function getInventory() : BrewingStandInventory{
|
||||||
* @return BrewingStandInventory
|
|
||||||
*/
|
|
||||||
public function getInventory(){
|
|
||||||
return $this->inventory;
|
return $this->inventory;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function getRealInventory() : BrewingStandInventory{
|
||||||
* @return BrewingStandInventory
|
|
||||||
*/
|
|
||||||
public function getRealInventory(){
|
|
||||||
return $this->inventory;
|
return $this->inventory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,20 +114,14 @@ class Chest extends Spawnable implements Container, Nameable{
|
|||||||
$this->containerTraitBlockDestroyedHook();
|
$this->containerTraitBlockDestroyedHook();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function getInventory() : ChestInventory|DoubleChestInventory{
|
||||||
* @return ChestInventory|DoubleChestInventory
|
|
||||||
*/
|
|
||||||
public function getInventory(){
|
|
||||||
if($this->isPaired() && $this->doubleInventory === null){
|
if($this->isPaired() && $this->doubleInventory === null){
|
||||||
$this->checkPairing();
|
$this->checkPairing();
|
||||||
}
|
}
|
||||||
return $this->doubleInventory instanceof DoubleChestInventory ? $this->doubleInventory : $this->inventory;
|
return $this->doubleInventory instanceof DoubleChestInventory ? $this->doubleInventory : $this->inventory;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function getRealInventory() : ChestInventory{
|
||||||
* @return ChestInventory
|
|
||||||
*/
|
|
||||||
public function getRealInventory(){
|
|
||||||
return $this->inventory;
|
return $this->inventory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,10 +30,7 @@ interface Container extends InventoryHolder{
|
|||||||
public const TAG_ITEMS = "Items";
|
public const TAG_ITEMS = "Items";
|
||||||
public const TAG_LOCK = "Lock";
|
public const TAG_LOCK = "Lock";
|
||||||
|
|
||||||
/**
|
public function getRealInventory() : Inventory;
|
||||||
* @return Inventory
|
|
||||||
*/
|
|
||||||
public function getRealInventory();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether this container can be opened by an item with the given custom name.
|
* Returns whether this container can be opened by an item with the given custom name.
|
||||||
|
@ -38,10 +38,7 @@ trait ContainerTrait{
|
|||||||
/** @var string|null */
|
/** @var string|null */
|
||||||
private $lock = null;
|
private $lock = null;
|
||||||
|
|
||||||
/**
|
abstract public function getRealInventory() : Inventory;
|
||||||
* @return Inventory
|
|
||||||
*/
|
|
||||||
abstract public function getRealInventory();
|
|
||||||
|
|
||||||
protected function loadItems(CompoundTag $tag) : void{
|
protected function loadItems(CompoundTag $tag) : void{
|
||||||
if(($inventoryTag = $tag->getTag(Container::TAG_ITEMS)) instanceof ListTag && $inventoryTag->getTagType() === NBT::TAG_Compound){
|
if(($inventoryTag = $tag->getTag(Container::TAG_ITEMS)) instanceof ListTag && $inventoryTag->getTagType() === NBT::TAG_Compound){
|
||||||
|
@ -104,17 +104,11 @@ abstract class Furnace extends Spawnable implements Container, Nameable{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function getInventory() : FurnaceInventory{
|
||||||
* @return FurnaceInventory
|
|
||||||
*/
|
|
||||||
public function getInventory(){
|
|
||||||
return $this->inventory;
|
return $this->inventory;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function getRealInventory() : FurnaceInventory{
|
||||||
* @return FurnaceInventory
|
|
||||||
*/
|
|
||||||
public function getRealInventory(){
|
|
||||||
return $this->getInventory();
|
return $this->getInventory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,17 +69,11 @@ class Hopper extends Spawnable implements Container, Nameable{
|
|||||||
return "Hopper";
|
return "Hopper";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function getInventory() : HopperInventory{
|
||||||
* @return HopperInventory
|
|
||||||
*/
|
|
||||||
public function getInventory(){
|
|
||||||
return $this->inventory;
|
return $this->inventory;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function getRealInventory() : HopperInventory{
|
||||||
* @return HopperInventory
|
|
||||||
*/
|
|
||||||
public function getRealInventory(){
|
|
||||||
return $this->inventory;
|
return $this->inventory;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -93,17 +93,11 @@ class ShulkerBox extends Spawnable implements Container, Nameable{
|
|||||||
$this->facing = $facing;
|
$this->facing = $facing;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function getInventory() : ShulkerBoxInventory{
|
||||||
* @return ShulkerBoxInventory
|
|
||||||
*/
|
|
||||||
public function getInventory(){
|
|
||||||
return $this->inventory;
|
return $this->inventory;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function getRealInventory() : ShulkerBoxInventory{
|
||||||
* @return ShulkerBoxInventory
|
|
||||||
*/
|
|
||||||
public function getRealInventory(){
|
|
||||||
return $this->inventory;
|
return $this->inventory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,11 +23,11 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pocketmine\command\defaults;
|
namespace pocketmine\command\defaults;
|
||||||
|
|
||||||
use pocketmine\block\BlockFactory;
|
use pocketmine\block\BlockLegacyIds;
|
||||||
use pocketmine\color\Color;
|
use pocketmine\color\Color;
|
||||||
use pocketmine\command\CommandSender;
|
use pocketmine\command\CommandSender;
|
||||||
use pocketmine\command\utils\InvalidCommandSyntaxException;
|
use pocketmine\command\utils\InvalidCommandSyntaxException;
|
||||||
use pocketmine\item\ItemFactory;
|
use pocketmine\item\StringToItemParser;
|
||||||
use pocketmine\item\VanillaItems;
|
use pocketmine\item\VanillaItems;
|
||||||
use pocketmine\lang\KnownTranslationFactory;
|
use pocketmine\lang\KnownTranslationFactory;
|
||||||
use pocketmine\math\Vector3;
|
use pocketmine\math\Vector3;
|
||||||
@ -70,7 +70,6 @@ use function explode;
|
|||||||
use function max;
|
use function max;
|
||||||
use function microtime;
|
use function microtime;
|
||||||
use function mt_rand;
|
use function mt_rand;
|
||||||
use function strpos;
|
|
||||||
use function strtolower;
|
use function strtolower;
|
||||||
|
|
||||||
class ParticleCommand extends VanillaCommand{
|
class ParticleCommand extends VanillaCommand{
|
||||||
@ -114,7 +113,7 @@ class ParticleCommand extends VanillaCommand{
|
|||||||
|
|
||||||
$count = isset($args[7]) ? max(1, (int) $args[7]) : 1;
|
$count = isset($args[7]) ? max(1, (int) $args[7]) : 1;
|
||||||
|
|
||||||
$data = isset($args[8]) ? (int) $args[8] : null;
|
$data = $args[8] ?? null;
|
||||||
|
|
||||||
$particle = $this->getParticle($name, $data);
|
$particle = $this->getParticle($name, $data);
|
||||||
|
|
||||||
@ -138,7 +137,7 @@ class ParticleCommand extends VanillaCommand{
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getParticle(string $name, ?int $data = null) : ?Particle{
|
private function getParticle(string $name, ?string $data = null) : ?Particle{
|
||||||
switch($name){
|
switch($name){
|
||||||
case "explode":
|
case "explode":
|
||||||
return new ExplodeParticle();
|
return new ExplodeParticle();
|
||||||
@ -156,7 +155,7 @@ class ParticleCommand extends VanillaCommand{
|
|||||||
case "crit":
|
case "crit":
|
||||||
return new CriticalParticle();
|
return new CriticalParticle();
|
||||||
case "smoke":
|
case "smoke":
|
||||||
return new SmokeParticle($data ?? 0);
|
return new SmokeParticle((int) ($data ?? 0));
|
||||||
case "spell":
|
case "spell":
|
||||||
return new EnchantParticle(new Color(0, 0, 0, 255)); //TODO: colour support
|
return new EnchantParticle(new Color(0, 0, 0, 255)); //TODO: colour support
|
||||||
case "instantspell":
|
case "instantspell":
|
||||||
@ -175,25 +174,31 @@ class ParticleCommand extends VanillaCommand{
|
|||||||
case "lava":
|
case "lava":
|
||||||
return new LavaParticle();
|
return new LavaParticle();
|
||||||
case "reddust":
|
case "reddust":
|
||||||
return new RedstoneParticle($data ?? 1);
|
return new RedstoneParticle((int) ($data ?? 1));
|
||||||
case "snowballpoof":
|
case "snowballpoof":
|
||||||
return new ItemBreakParticle(VanillaItems::SNOWBALL());
|
return new ItemBreakParticle(VanillaItems::SNOWBALL());
|
||||||
case "slime":
|
case "slime":
|
||||||
return new ItemBreakParticle(VanillaItems::SLIMEBALL());
|
return new ItemBreakParticle(VanillaItems::SLIMEBALL());
|
||||||
case "itembreak":
|
case "itembreak":
|
||||||
if($data !== null && $data !== 0){
|
if($data !== null){
|
||||||
return new ItemBreakParticle(ItemFactory::getInstance()->get($data));
|
$item = StringToItemParser::getInstance()->parse($data);
|
||||||
|
if($item !== null && !$item->isNull()){
|
||||||
|
return new ItemBreakParticle($item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "terrain":
|
case "terrain":
|
||||||
if($data !== null && $data !== 0){
|
if($data !== null){
|
||||||
return new TerrainParticle(BlockFactory::getInstance()->get($data, 0));
|
$block = StringToItemParser::getInstance()->parse($data)?->getBlock();
|
||||||
|
if($block !== null && $block->getId() !== BlockLegacyIds::AIR){
|
||||||
|
return new TerrainParticle($block);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "heart":
|
case "heart":
|
||||||
return new HeartParticle($data ?? 0);
|
return new HeartParticle((int) ($data ?? 0));
|
||||||
case "ink":
|
case "ink":
|
||||||
return new InkParticle($data ?? 0);
|
return new InkParticle((int) ($data ?? 0));
|
||||||
case "droplet":
|
case "droplet":
|
||||||
return new RainSplashParticle();
|
return new RainSplashParticle();
|
||||||
case "enchantmenttable":
|
case "enchantmenttable":
|
||||||
@ -203,26 +208,32 @@ class ParticleCommand extends VanillaCommand{
|
|||||||
case "angryvillager":
|
case "angryvillager":
|
||||||
return new AngryVillagerParticle();
|
return new AngryVillagerParticle();
|
||||||
case "forcefield":
|
case "forcefield":
|
||||||
return new BlockForceFieldParticle($data ?? 0);
|
return new BlockForceFieldParticle((int) ($data ?? 0));
|
||||||
case "mobflame":
|
case "mobflame":
|
||||||
return new EntityFlameParticle();
|
return new EntityFlameParticle();
|
||||||
|
case "iconcrack":
|
||||||
|
if($data !== null && ($item = StringToItemParser::getInstance()->parse($data)) !== null && !$item->isNull()){
|
||||||
|
return new ItemBreakParticle($item);
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
if(strpos($name, "iconcrack_") === 0){
|
case "blockcrack":
|
||||||
$d = explode("_", $name);
|
if($data !== null && ($block = StringToItemParser::getInstance()->parse($data)?->getBlock()) !== null && $block->getId() !== BlockLegacyIds::AIR){
|
||||||
if(count($d) === 3){
|
return new TerrainParticle($block);
|
||||||
return new ItemBreakParticle(ItemFactory::getInstance()->get((int) $d[1], (int) $d[2]));
|
|
||||||
}
|
}
|
||||||
}elseif(strpos($name, "blockcrack_") === 0){
|
break;
|
||||||
$d = explode("_", $name);
|
case "blockdust":
|
||||||
if(count($d) === 2){
|
if($data !== null){
|
||||||
return new TerrainParticle(BlockFactory::getInstance()->get(((int) $d[1]) & 0xff, ((int) $d[1]) >> 12));
|
$d = explode("_", $data);
|
||||||
|
if(count($d) >= 3){
|
||||||
|
return new DustParticle(new Color(
|
||||||
|
((int) $d[0]) & 0xff,
|
||||||
|
((int) $d[1]) & 0xff,
|
||||||
|
((int) $d[2]) & 0xff,
|
||||||
|
((int) ($d[3] ?? 255)) & 0xff
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}elseif(strpos($name, "blockdust_") === 0){
|
|
||||||
$d = explode("_", $name);
|
|
||||||
if(count($d) >= 4){
|
|
||||||
return new DustParticle(new Color(((int) $d[1]) & 0xff, ((int) $d[2]) & 0xff, ((int) $d[3]) & 0xff, isset($d[4]) ? ((int) $d[4]) & 0xff : 255));
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -189,10 +189,7 @@ class Human extends Living implements ProjectileSource, InventoryHolder{
|
|||||||
return min(100, 7 * $this->xpManager->getXpLevel());
|
return min(100, 7 * $this->xpManager->getXpLevel());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function getInventory() : PlayerInventory{
|
||||||
* @return PlayerInventory
|
|
||||||
*/
|
|
||||||
public function getInventory(){
|
|
||||||
return $this->inventory;
|
return $this->inventory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,10 +25,5 @@ namespace pocketmine\inventory;
|
|||||||
|
|
||||||
interface InventoryHolder{
|
interface InventoryHolder{
|
||||||
|
|
||||||
/**
|
public function getInventory() : Inventory;
|
||||||
* Get the object related inventory
|
|
||||||
*
|
|
||||||
* @return Inventory
|
|
||||||
*/
|
|
||||||
public function getInventory();
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user