Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Monster Spawner functionality #6187

Open
wants to merge 25 commits into
base: minor-next
Choose a base branch
from

Conversation

diamond-gold
Copy link
Contributor

@diamond-gold diamond-gold commented Dec 4, 2023

Introduction

This PR implements the functionality of the Monster Spawner block

Changes

API changes

Added SpawnerAttemptSpawnEvent

Follow-up

TODO: spawn condition check (light level etc.)
TODO: spawnData, spawnPotentials

Tests

Not Tested

src/item/SpawnEgg.php Outdated Show resolved Hide resolved
src/block/tile/MonsterSpawner.php Outdated Show resolved Hide resolved
src/block/tile/MonsterSpawner.php Outdated Show resolved Hide resolved
src/block/tile/MonsterSpawner.php Outdated Show resolved Hide resolved
src/block/MonsterSpawner.php Outdated Show resolved Hide resolved
@ShockedPlot7560 ShockedPlot7560 added Category: API Related to the plugin API Category: Core Related to internal functionality Type: Enhancement Contributes features or other improvements to PocketMine-MP labels Dec 20, 2023
src/block/tile/MonsterSpawner.php Outdated Show resolved Hide resolved
src/item/SpawnEggEntityRegistry.php Outdated Show resolved Hide resolved
src/item/SpawnEggEntityRegistry.php Outdated Show resolved Hide resolved
Copy link
Member

@ShockedPlot7560 ShockedPlot7560 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By moving the logic to a block, I mean something like Noteblock where all the data is only read once and the tile is only used to store the data. At runtime, the block class is used, enough.

src/block/tile/SpawnerSpawnRangeRegistry.php Outdated Show resolved Hide resolved
src/block/tile/SpawnerSpawnRangeRegistry.php Outdated Show resolved Hide resolved
src/block/tile/SpawnerSpawnRangeRegistry.php Outdated Show resolved Hide resolved
use pocketmine\event\Cancellable;
use pocketmine\event\CancellableTrait;

class SpawnerAttemptSpawnEvent extends BlockEvent implements Cancellable{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be possible to change more values? The size, the number? Is it useful ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it makes sense to allow changing those in the event, those can be changed on the spawner block

src/item/SpawnEggEntityRegistry.php Outdated Show resolved Hide resolved
@pandaaaBE
Copy link
Contributor

does the author mind if i help with this pr?

@diamond-gold
Copy link
Contributor Author

does the author mind if i help with this pr?

I appreciate any help, feel free to offer suggestions or PR

Joshy3282 added a commit to Joshy3282/PocketMine-MP that referenced this pull request Oct 3, 2024
Copy link
Member

@dktapps dktapps left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really don't like how much this depends on Mojang internal data. Not sure if there's currently a way to avoid this, but this is why I didn't implement mob spawners myself.

$this->spawnPerAttempt = $tile->getSpawnPerAttempt();
$this->maxNearbyEntities = $tile->getMaxNearbyEntities();
$this->spawnRange = $tile->getSpawnRange();
$this->requiredPlayerRange = $tile->getRequiredPlayerRange();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not liking this. A data class to wrap all these up into one item to be passed between block & tile would be a lot cleaner.

Copy link

github-actions bot commented Dec 8, 2024

This PR has been marked as "Waiting on Author", but we haven't seen any activity in 7 days.

If there is no further activity, it will be closed in 28 days.

Note for maintainers: Adding an assignee to the PR will prevent it from being marked as stale.

@github-actions github-actions bot added the Stale label Dec 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: API Related to the plugin API Category: Core Related to internal functionality Stale Status: Waiting on Author Type: Enhancement Contributes features or other improvements to PocketMine-MP
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants