MCMrARM / mcpelauncher-linux

Please note this is a legacy repository, please go to: https://github.com/minecraft-linux/mcpelauncher-manifest/wiki
GNU General Public License v3.0
312 stars 46 forks source link

[server] spawnRadius #333

Open DaMatrix opened 6 years ago

DaMatrix commented 6 years ago

See this link

A way to have players not always respawn at the exact same place would be useful, as it makes it possible for people to spawn trap players and make it impossible to get out.

I'm not sure if this is within the scope of the project, as it's (currently) not in vanilla MCPE. However, it's a very useful feature for multiplayer servers.

nic96 commented 6 years ago

It could probably be done by writing a mod that hooks Level::onPlayerDeath(Player&, EntityDamageSource const&) and calls LevelData::setSpawn(BlockPos const&) with a random spawn position. This will change the world spawn point every time a player dies.

I'm new to modding so what I just said may not be true.

nic96 commented 6 years ago

Actually to make a spawn protection mod it would be better to just not allow players to modify blocks near the spawnpoint. This could maybe be done with minecraft::api::PlayerInteractionInterface::handlePlayerPlacingBlockEvent() and minecraft::api::PlayerInteractionInterface::handlePlayerBreakingBlockEvent(), but how I would need to modify that function to keep a player from placing a block I don't know.

nic96 commented 6 years ago

I tried writing a mod for this, but I ran into an issue when trying to get the player abilities.

EntityUniqueID entityuniqueid = player.getUniqueID();
Level level = player.getLevel();
Abilities abilities = level.getPlayerAbilities(entityuniqueid);

But everything I tried just resulted in crashes so I guess I give up for now.

InusualZ commented 6 years ago

@nic96 Most likely you are guessing the wrong, the return type of function. Player::getLevel() most likely return an pointer.

MCMrARM commented 6 years ago

Discussing modding is off-topic, please use a different place for this.