Skip to content

Commit

Permalink
Merge branch 'major-next' into implement-icebomb
Browse files Browse the repository at this point in the history
  • Loading branch information
zSALLAZAR authored Aug 5, 2023
2 parents 1563f63 + 9997b61 commit fc2a2f8
Show file tree
Hide file tree
Showing 32 changed files with 644 additions and 222 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/discord-release-notify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v3

- name: Setup PHP and tools
uses: shivammathur/[email protected].4
uses: shivammathur/[email protected].5
with:
php-version: 8.1

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/draft-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
submodules: true

- name: Setup PHP
uses: shivammathur/[email protected].4
uses: shivammathur/[email protected].5
with:
php-version: 8.1

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ jobs:
- uses: actions/checkout@v3

- name: Setup PHP and tools
uses: shivammathur/[email protected].4
uses: shivammathur/[email protected].5
with:
php-version: 8.1
tools: php-cs-fixer:3.17
Expand Down
19 changes: 19 additions & 0 deletions changelogs/4.23.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,22 @@ Released 18th July 2023.

## Fixes
- Fixed login errors due to a new `sandboxId` field appearing in the Xbox Live authentication data in `LoginPacket`. All clients, regardless of version, are affected by this change.

# 4.23.3
Released 24th July 2023.

## Documentation
- Fixed typo in `ChunkSelector::selectChunks()` documentation.

## Fixes
- Fixed the server not stopping properly during crash conditions on *nix platforms.
- Fixed `HORSE_EQUIP` and `SMITHING_TABLE_TEMPLATE` container UI types not being handled by `ItemStackContainerIdTranslator`. This bug prevented plugins from implementing missing inventory types.
- Player emotes no longer broadcast messages to other players. This was unintended behaviour caused by a client-side behavioural change.
- Shulker boxes no longer support the placement of torches or other similar blocks.
- Fire can now be placed on upper slabs and the top of upside-down stairs.

# 4.23.4
Released 1st August 2023.

## Fixes
- Fixed exponentially increasing lag when many hundreds of non-mergeable dropped items occupied the same space. This disproportionately affected SkyBlock servers due to large cactus farms using water to collect items together.
32 changes: 32 additions & 0 deletions changelogs/5.3.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,35 @@ Released 18th July 2023.

## Internals
- Armor pieces are no longer set back into the armor inventory if no change was made. This reduces the number of slot updates sent to clients, as well as avoiding unnecessary updates for armor pieces which have Unbreaking enchantments.

# 5.3.3
Released 24th July 2023.

## Included releases
**This release includes changes from the following releases:**
- [4.23.3](https://github.com/pmmp/PocketMine-MP/blob/4.23.3/changelogs/4.23.md#4233) - Various bug fixes

## Fixes
- Added a workaround for PM4 worlds with chunks corrupted by [Refaltor77/CustomItemAPI](https://github.com/Refaltor77/CustomItemAPI).
- While this was not the fault of PocketMine-MP itself, a significant number of users were affected by this problem.
- This error was not detected by PM4 due to missing validation of certain data which should not have existed in 1.12.
- An error will now be logged when this corruption is detected, but the affected chunks should otherwise load normally.
- Relaxed validation of expected 3D biome array counts per chunk in LevelDB worlds.
- Vanilla Bedrock currently saves 24 palettes (and only 24 are required), but it saved 25, 32, or 64 biome palettes per chunk in older versions.
- Core validation for these padding biomes was very strict, enforcing exact compliance with vanilla.
- Since only 24 palettes are actually required, the remaining palettes may now be omitted irrespective of the chunk version.
- An error will still be logged when this mistake is detected, but the affected chunks will otherwise load normally.
- Fixed `/kill` not working on players who had (re)spawned in the 3 seconds immediately after (re)spawning (due to `noDamageTicks`).
- Fixed `/kill` not working correctly for players with high levels of Health Boost or other health-altering effects.
- Fixed netherite items being destroyed by lava.
- Fireproof entities no longer display the burning animation when in fire or lava. This does not apply to creative players, who are immortal rather than being fireproof.
- Fixed frosted ice melting in certain conditions which didn't match vanilla Bedrock.

# 5.3.4
Released 1st August 2023.

## Included releases
This release includes changes from the following releases:
- [4.23.4](https://github.com/pmmp/PocketMine-MP/blob/4.23.4/changelogs/4.23.md#4234) - Item entity lag fix

This release contains no other significant changes.
83 changes: 83 additions & 0 deletions changelogs/5.4.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# 5.4.0
Released 1st August 2023.

**For Minecraft: Bedrock Edition 1.20.10**

This is a minor feature update, including a handful of new gameplay features, new plugin APIs and improvements to error reporting.

**Plugin compatibility:** Plugins for previous 5.x versions will run unchanged on this release, unless they use internal APIs, reflection, or packages like the `pocketmine\network\mcpe` or `pocketmine\data` namespace.
Do not update plugin minimum API versions unless you need new features added in this release.

**WARNING: If your plugin uses the `pocketmine\network\mcpe` namespace, you're not shielded by API change constraints.**
Consider using the `mcpe-protocol` directive in `plugin.yml` as a constraint if you're using packets directly.

## General
- Improved error reporting for async task and thread crashes.
- Players may now have different creative inventories.

## Gameplay
### General
- Added support for 1.5-block height sneaking.
- Fixed missing player arm swing and sounds when punching the air.

### Blocks
- Implemented the following new blocks:
- Big Dripleaf Head
- Big Dripleaf Stem
- Small Dripleaf
- Acacia saplings now grow into acacia trees.
- Fixed melon and pumpkin stems not attaching to the correct block when growing.
- Various blocks now drop more items when mined with a compatible tool enchanted with Fortune.

### Items
- Implemented Strong Slowness potion.
- Implemented Fortune enchantment.

## API
### `pocketmine\block`
- The following new classes have been added:
- `utils\FortuneDropHelper` - utility methods for calculating the drop counts for Fortune-affected blocks
- The following new API methods have been added:
- `protected Block->getAdjacentSupportType(int $facing) : utils\SupportType` - returns the type of support provided by the block in the given direction on the adjacent face

### `pocketmine\entity`
- The following new API constants have been added:
- `Living::DEFAULT_KNOCKBACK_FORCE`
- `Living::DEFAULT_KNOCKBACK_VERTICAL_LIMIT`

### `pocketmine\entity\animation`
- `ConsumingItemAnimation` now accepts `Living` instances instead of just `Human`.

### `pocketmine\event`
- The following new classes have been added:
- `PlayerMissSwingEvent` - called when the player attempts the attack action (left click on desktop) without any target
- This is possible thanks to the introduction of new flags in `PlayerAuthInputPacket` in Bedrock 1.20.10
- The following new API methods have been added:
- `public EntityDamageByEntityEvent->getVerticalKnockBackLimit() : float`
- `public EntityDamageByEntityEvent->setVerticalKnockBackLimit(float $verticalKnockBackLimit) : void` - sets the max vertical velocity that can result from the victim being knocked back

### `pocketmine\player`
- The following new API methods have been added:
- `public Player->getCreativeInventory() : pocketmine\inventory\CreativeInventory`
- `public Player->setCreativeInventory(pocketmine\inventory\CreativeInventory $inventory) : void`
- `public Player->missSwing() : void` - performs actions associated with the attack action when there is no target (see `PlayerMissSwingEvent`)

### `pocketmine\scheduler`
- Cancellation functionality has been removed from `AsyncTask`, as it didn't make any sense and wasn't used by anything for what it was intended for.
- It broke sequential task execution - later tasks might depend on state from earlier tasks
- It didn't actually cancel the task anyway - at best, it prevented it from running, but couldn't interrupt it (though interrupting a task does not make sense either)
- The following API methods have been deprecated, and their functionality has been removed:
- `AsyncTask->hasCancelledRun()`
- `AsyncTask->cancelRun()`

## Internals
- Uncaught exceptions and fatal errors in `AsyncTask`, threads extending `pocketmine\thread\Thread`, and `pocketmine\thread\Worker` are now recorded in crashdumps, making it significantly easier to debug errors in these areas.
- JWT signature DER <-> raw conversions are now handled in-house using code in `JwtUtils`
- Due to the simplicity of the conversion and only requiring a tiny subset of the ASN.1 spec, it didn't make much sense to introduce another dependency.
- `fgrosse/phpasn1` is no longer required. This package was abandoned by its author and only used by PocketMine-MP for this one purpose.
- Various usages of `Closure::fromCallable()` have been replaced by PHP 8.1 first-class callable syntax.
- Blocks requiring support shifted to a "can be supported at" model, rather than "can be supported by".
- This model reduces repeated logic when placing and performing nearby block updates (no need to hardcode facing everywhere).
- In addition, this change facilitates the use of the newly introduced `Block->getAdjacentSupportType()` API method, reducing boilerplate support-type checking code.
- Bell block code has been simplified and cleaned up.
- `TallGrass` and `DoubleTallGrass` now use a shared `TallGrassTrait` to reduce code duplication.
48 changes: 27 additions & 21 deletions src/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@
use pocketmine\player\PlayerInfo;
use pocketmine\plugin\FolderPluginLoader;
use pocketmine\plugin\PharPluginLoader;
use pocketmine\plugin\Plugin;
use pocketmine\plugin\PluginEnableOrder;
use pocketmine\plugin\PluginGraylist;
use pocketmine\plugin\PluginManager;
Expand All @@ -94,6 +93,7 @@
use pocketmine\snooze\SleeperHandler;
use pocketmine\stats\SendUsageTask;
use pocketmine\thread\log\AttachableThreadSafeLogger;
use pocketmine\thread\ThreadCrashException;
use pocketmine\thread\ThreadSafeClassLoader;
use pocketmine\timings\Timings;
use pocketmine\timings\TimingsHandler;
Expand Down Expand Up @@ -1518,23 +1518,38 @@ public function exceptionHandler(\Throwable $e, ?array $trace = null) : void{
$trace = $e->getTrace();
}

$errstr = $e->getMessage();
$errfile = $e->getFile();
$errline = $e->getLine();

$errstr = preg_replace('/\s+/', ' ', trim($errstr));
//If this is a thread crash, this logs where the exception came from on the main thread, as opposed to the
//crashed thread. This is intentional, and might be useful for debugging
//Assume that the thread already logged the original exception with the correct stack trace
$this->logger->logException($e, $trace);

$errfile = Filesystem::cleanPath($errfile);
if($e instanceof ThreadCrashException){
$info = $e->getCrashInfo();
$type = $info->getType();
$errstr = $info->getMessage();
$errfile = $info->getFile();
$errline = $info->getLine();
$printableTrace = $info->getTrace();
$thread = $info->getThreadName();
}else{
$type = get_class($e);
$errstr = $e->getMessage();
$errfile = $e->getFile();
$errline = $e->getLine();
$printableTrace = Utils::printableTraceWithMetadata($trace);
$thread = "Main";
}

$this->logger->logException($e, $trace);
$errstr = preg_replace('/\s+/', ' ', trim($errstr));

$lastError = [
"type" => get_class($e),
"type" => $type,
"message" => $errstr,
"fullFile" => $e->getFile(),
"file" => $errfile,
"fullFile" => $errfile,
"file" => Filesystem::cleanPath($errfile),
"line" => $errline,
"trace" => $trace
"trace" => $printableTrace,
"thread" => $thread
];

global $lastExceptionError, $lastError;
Expand Down Expand Up @@ -1592,15 +1607,6 @@ public function crashDump() : void{
}
@touch($stamp); //update file timestamp

$plugin = $dump->getData()->plugin;
if($plugin !== ""){
$p = $this->pluginManager->getPlugin($plugin);
if($p instanceof Plugin && !($p->getPluginLoader() instanceof PharPluginLoader)){
$this->logger->debug("Not sending crashdump due to caused by non-phar plugin");
$report = false;
}
}

if($dump->getData()->error["type"] === \ParseError::class){
$report = false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/VersionInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

final class VersionInfo{
public const NAME = "PocketMine-MP";
public const BASE_VERSION = "5.3.3";
public const BASE_VERSION = "5.4.1";
public const IS_DEVELOPMENT_BUILD = true;
public const BUILD_CHANNEL = "stable";

Expand Down
7 changes: 5 additions & 2 deletions src/block/DoubleTallGrass.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,21 @@

namespace pocketmine\block;

use pocketmine\block\utils\FortuneDropHelper;
use pocketmine\block\utils\TallGrassTrait;
use pocketmine\item\Item;

class DoubleTallGrass extends DoublePlant{
use TallGrassTrait {
getDropsForIncompatibleTool as traitGetDropsForIncompatibleTool;
}

public function canBeReplaced() : bool{
return true;
}

public function getDropsForIncompatibleTool(Item $item) : array{
if($this->top){
return FortuneDropHelper::grass($item);
return $this->traitGetDropsForIncompatibleTool($item);
}
return [];
}
Expand Down
19 changes: 2 additions & 17 deletions src/block/TallGrass.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,15 @@

namespace pocketmine\block;

use pocketmine\block\utils\FortuneDropHelper;
use pocketmine\block\utils\TallGrassTrait;
use pocketmine\item\Item;
use pocketmine\math\Facing;
use pocketmine\math\Vector3;
use pocketmine\player\Player;
use pocketmine\world\BlockTransaction;

class TallGrass extends Flowable{

public function canBeReplaced() : bool{
return true;
}
use TallGrassTrait;

private function canBeSupportedBy(Block $block) : bool{
return $block->hasTypeTag(BlockTypeTags::DIRT) || $block->hasTypeTag(BlockTypeTags::MUD);
Expand All @@ -53,16 +50,4 @@ public function onNearbyBlockChange() : void{
$this->position->getWorld()->useBreakOn($this->position);
}
}

public function getDropsForIncompatibleTool(Item $item) : array{
return FortuneDropHelper::grass($item);
}

public function getFlameEncouragement() : int{
return 60;
}

public function getFlammability() : int{
return 100;
}
}
21 changes: 0 additions & 21 deletions src/block/utils/FortuneDropHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

use pocketmine\item\enchantment\VanillaEnchantments;
use pocketmine\item\Item;
use pocketmine\item\VanillaItems;
use function max;
use function min;
use function mt_getrandmax;
Expand Down Expand Up @@ -85,26 +84,6 @@ public static function binomial(Item $usedItem, int $min, int $minRolls = 3, flo
return $count;
}

/**
* Grass have a fixed chance to drop wheat seed.
* Fortune level increases the maximum number of seeds that can be dropped.
* A discrete uniform distribution is used to determine the number of seeds dropped.
*
* TODO: I'm not sure this really belongs here, but it's preferable not to duplicate this code between grass and
* tall grass.
*
* @return Item[]
*/
public static function grass(Item $usedItem) : array{
if(FortuneDropHelper::bonusChanceDivisor($usedItem, 8, 2)){
return [
VanillaItems::WHEAT_SEEDS()
];
}

return [];
}

/**
* Adds the fortune level to the base max and picks a random number between the minimim and adjusted maximum.
* Each amount in the range has an equal chance of being picked.
Expand Down
Loading

0 comments on commit fc2a2f8

Please sign in to comment.