Skip to content
Open
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions generated/item/VanillaItems.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ final class VanillaItems{
private static CoralFan $_mCORAL_FAN;
private static HangingSign $_mCRIMSON_HANGING_SIGN;
private static ItemBlockWallOrFloor $_mCRIMSON_SIGN;
private static Crossbow $_mCROSSBOW;
private static Boat $_mDARK_OAK_BOAT;
private static HangingSign $_mDARK_OAK_HANGING_SIGN;
private static ItemBlockWallOrFloor $_mDARK_OAK_SIGN;
Expand Down Expand Up @@ -500,6 +501,7 @@ private static function getInitAssigners() : array{
"coral_fan" => fn(CoralFan $v) => self::$_mCORAL_FAN = $v,
"crimson_hanging_sign" => fn(HangingSign $v) => self::$_mCRIMSON_HANGING_SIGN = $v,
"crimson_sign" => fn(ItemBlockWallOrFloor $v) => self::$_mCRIMSON_SIGN = $v,
"crossbow" => fn(Crossbow $v) => self::$_mCROSSBOW = $v,
"dark_oak_boat" => fn(Boat $v) => self::$_mDARK_OAK_BOAT = $v,
"dark_oak_hanging_sign" => fn(HangingSign $v) => self::$_mDARK_OAK_HANGING_SIGN = $v,
"dark_oak_sign" => fn(ItemBlockWallOrFloor $v) => self::$_mDARK_OAK_SIGN = $v,
Expand Down Expand Up @@ -1278,6 +1280,11 @@ public static function CRIMSON_SIGN() : ItemBlockWallOrFloor{
return clone self::$_mCRIMSON_SIGN;
}

public static function CROSSBOW() : Crossbow{
if(!isset(self::$_mCROSSBOW)){ self::init(); }
return clone self::$_mCROSSBOW;
}

public static function DARK_OAK_BOAT() : Boat{
if(!isset(self::$_mDARK_OAK_BOAT)){ self::init(); }
return clone self::$_mDARK_OAK_BOAT;
Expand Down
14 changes: 14 additions & 0 deletions generated/item/enchantment/VanillaEnchantments.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,12 @@ final class VanillaEnchantments{
private static Enchantment $_mINFINITY;
private static KnockbackEnchantment $_mKNOCKBACK;
private static Enchantment $_mMENDING;
private static Enchantment $_mMULTISHOT;
private static Enchantment $_mPOWER;
private static ProtectionEnchantment $_mPROJECTILE_PROTECTION;
private static ProtectionEnchantment $_mPROTECTION;
private static Enchantment $_mPUNCH;
private static Enchantment $_mQUICK_CHARGE;
private static Enchantment $_mRESPIRATION;
private static SharpnessEnchantment $_mSHARPNESS;
private static Enchantment $_mSILK_TOUCH;
Expand Down Expand Up @@ -105,10 +107,12 @@ private static function getInitAssigners() : array{
"INFINITY" => fn(Enchantment $v) => self::$_mINFINITY = $v,
"KNOCKBACK" => fn(KnockbackEnchantment $v) => self::$_mKNOCKBACK = $v,
"MENDING" => fn(Enchantment $v) => self::$_mMENDING = $v,
"MULTISHOT" => fn(Enchantment $v) => self::$_mMULTISHOT = $v,
"POWER" => fn(Enchantment $v) => self::$_mPOWER = $v,
"PROJECTILE_PROTECTION" => fn(ProtectionEnchantment $v) => self::$_mPROJECTILE_PROTECTION = $v,
"PROTECTION" => fn(ProtectionEnchantment $v) => self::$_mPROTECTION = $v,
"PUNCH" => fn(Enchantment $v) => self::$_mPUNCH = $v,
"QUICK_CHARGE" => fn(Enchantment $v) => self::$_mQUICK_CHARGE = $v,
"RESPIRATION" => fn(Enchantment $v) => self::$_mRESPIRATION = $v,
"SHARPNESS" => fn(SharpnessEnchantment $v) => self::$_mSHARPNESS = $v,
"SILK_TOUCH" => fn(Enchantment $v) => self::$_mSILK_TOUCH = $v,
Expand Down Expand Up @@ -214,6 +218,11 @@ public static function MENDING() : Enchantment{
return self::$_mMENDING;
}

public static function MULTISHOT() : Enchantment{
if(!isset(self::$_mMULTISHOT)){ self::init(); }
return self::$_mMULTISHOT;
}

public static function POWER() : Enchantment{
if(!isset(self::$_mPOWER)){ self::init(); }
return self::$_mPOWER;
Expand All @@ -234,6 +243,11 @@ public static function PUNCH() : Enchantment{
return self::$_mPUNCH;
}

public static function QUICK_CHARGE() : Enchantment{
if(!isset(self::$_mQUICK_CHARGE)){ self::init(); }
return self::$_mQUICK_CHARGE;
}

public static function RESPIRATION() : Enchantment{
if(!isset(self::$_mRESPIRATION)){ self::init(); }
return self::$_mRESPIRATION;
Expand Down
3 changes: 3 additions & 0 deletions src/data/bedrock/EnchantmentIdMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,8 @@ private function __construct(){
$this->register(EnchantmentIds::SWIFT_SNEAK, VanillaEnchantments::SWIFT_SNEAK());

$this->register(EnchantmentIds::FROST_WALKER, VanillaEnchantments::FROST_WALKER());

$this->register(EnchantmentIds::MULTISHOT, VanillaEnchantments::MULTISHOT());
$this->register(EnchantmentIds::QUICK_CHARGE, VanillaEnchantments::QUICK_CHARGE());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ private function register1to1ItemMappings() : void{
$this->map1to1Item(Ids::COPPER_SWORD, Items::COPPER_SWORD());
$this->map1to1Item(Ids::CRIMSON_HANGING_SIGN, Items::CRIMSON_HANGING_SIGN());
$this->map1to1Item(Ids::CRIMSON_SIGN, Items::CRIMSON_SIGN());
$this->map1to1Item(Ids::CROSSBOW, Items::CROSSBOW());
$this->map1to1Item(Ids::DARK_OAK_BOAT, Items::DARK_OAK_BOAT());
$this->map1to1Item(Ids::DARK_OAK_HANGING_SIGN, Items::DARK_OAK_HANGING_SIGN());
$this->map1to1Item(Ids::DARK_OAK_SIGN, Items::DARK_OAK_SIGN());
Expand Down
77 changes: 77 additions & 0 deletions src/event/entity/EntityShootCrossbowEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?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/
*
*
*/

declare(strict_types=1);

namespace pocketmine\event\entity;

use pocketmine\entity\Entity;
use pocketmine\entity\Living;
use pocketmine\event\Cancellable;
use pocketmine\event\CancellableTrait;
use pocketmine\item\Item;
use pocketmine\utils\Utils;
use function count;

/**
* @phpstan-extends EntityEvent<Living>
*/
final class EntityShootCrossbowEvent extends EntityEvent implements Cancellable{
use CancellableTrait;

/** @phpstan-param non-empty-list<Entity> $projectiles */
public function __construct(
Living $shooter,
private Item $crossbow,
private array $projectiles
){
$this->entity = $shooter;
}

public function getCrossbow() : Item{
return $this->crossbow;
}

/**
* Returns projectiles shot by crossbow.
* Can be more than 1 if multishot enchantment has applied.
*
* Note: This might not return a Projectile if a plugin modified the target entity.
*
* @return Entity[]
* @phpstan-return non-empty-list<Entity>
*/
public function getProjectiles() : array{
return $this->projectiles;
}

/**
* @param Entity[] $projectiles
* @phpstan-param non-empty-list<Entity> $projectiles
*/
public function setProjectiles(array $projectiles) : void{
Utils::validateArrayValueType($projectiles, function(Entity $_) : void{});
if(count($projectiles) === 0){
throw new \LogicException("Must have at least one projectile");
}
$this->projectiles = $projectiles;
}
}
38 changes: 38 additions & 0 deletions src/item/Chargeable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?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/
*
*
*/

declare(strict_types=1);

namespace pocketmine\item;

/**
* Interface implemented by objects that can be charged.
*/
interface Chargeable extends Releasable{
/**
* Returns an amount of ticks that this item should be in charge.
*/
public function getChargeDuration() : int;

public function setCharged(?Item $item) : void;

public function isCharged() : bool;
}
Loading