-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Create index.js * Update index.js * Create README.md * Update README.md * world-border
- Loading branch information
1 parent
c32f00c
commit 8d958a4
Showing
2 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# world-border | ||
|
||
## Description | ||
|
||
Rn code when the player is outside the set coordinates. | ||
|
||
**Parameters:** | ||
|
||
- `player` (type: Player or entity): The player or entity for which the function will be executed on. | ||
|
||
- `border` (type: object): An object representing the border with the following properties: | ||
|
||
- `minX` (type: number): The minimum X-coordinate value of the border. | ||
|
||
- `minZ` (type: number): The minimum Z-coordinate value of the border. | ||
|
||
- `maxX` (type: number): The maximum X-coordinate value of the border. | ||
|
||
- `maxZ` (type: number): The maximum Z-coordinate value of the border. | ||
|
||
The border is defined by the range between (`minX`, `minZ`) and (`maxX`, `maxZ`) coordinates. | ||
|
||
## Credits | ||
|
||
These scripts were written by [defowler2005](https://github.com/defowler2005). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Script example for ScriptAPI | ||
// Author: defowler2005 <https://github.com/defowler2005> | ||
// Project: https://github.com/JaylyDev/ScriptAPI | ||
|
||
/** | ||
* world border | ||
* @license Do whatever you want | ||
* @author defowler2005 | ||
* @version 1.0.0 | ||
* @project https://github.com/JaylyDev/ScriptAPI | ||
* -------------------------------------------------------------------------- | ||
* A code that creates a border for the world, Simple. | ||
* -------------------------------------------------------------------------- | ||
*/ | ||
import { world, system } from '@minecraft/server'; | ||
|
||
/** | ||
* @property {number} minX - The minimum X-coordinate value of the border. | ||
* @property {number} minZ - The minimum Z-coordinate value of the border. | ||
* @property {number} maxX - The maximum X-coordinate value of the border. | ||
* @property {number} maxZ - The maximum Z-coordinate value of the border. | ||
*/ | ||
|
||
const minX = -10; | ||
const minZ = -10; | ||
const maxX = 10; | ||
const maxZ = 10; | ||
|
||
system.runInterval(() => { | ||
world.getPlayers().forEach(player => { | ||
const x = Math.floor(player.location.x); | ||
const z = Math.floor(player.location.z); | ||
if (Math.abs(x - (minX + maxX) / 2) > Math.abs(minX - maxX) / 2 || Math.abs(z - (minZ + maxZ) / 2) > Math.abs(minZ - maxZ) / 2) { | ||
player.sendMessage('You are outside the border!'); | ||
} else { | ||
player.sendMessage('You are in the border!'); | ||
} | ||
}) | ||
}, 20); |