Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
violine1101 committed Jun 19, 2021
0 parents commit 5fb3e1e
Show file tree
Hide file tree
Showing 13 changed files with 118 additions and 0 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 violine1101

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# MC-Region-Pregen

A data pack for pregenerating larger regions in Minecraft

## Usage

1. Teleport to the lowest coordinates where the region starts
2. Run `/function regiongen:start`
3. Wait for the data pack to teleport you around
4. Done!

In order to stop the pregeneration prematurely, use `/function regiongen:stop`.

## Configuration

These configuration options are available:

### Teleportation speed

You can change the teleportation speed by using:

```
/scoreboard players set stepLength regiongen <timeInTicks>
```

The higher this value is, the slower the teleportation will go.

The lower this value is, the more likely it is that your computer won't keep up with world generation.
It is recommended to use lower values with low render distance (2-4 chunks).

By default, the teleportation speed is 1 teleportation per second.

### Region size

You can change the size of the pregenerated region:

```
/scoreboard players set xRegionSize regiongen <sizeInChunks>
/scoreboard players set zRegionSize regiongen <sizeInChunks>
```

By default, the region size is 32x32 chunks (size of a `.mca` file).

## Drawbacks
The current version of this pack only teleports one chunk at a time, meaning that it might take a long time for an entire region to be pregenerated.
5 changes: 5 additions & 0 deletions data/minecraft/tags/functions/load.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"values": [
"regiongen:load"
]
}
5 changes: 5 additions & 0 deletions data/minecraft/tags/functions/tick.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"values": [
"regiongen:tick"
]
}
8 changes: 8 additions & 0 deletions data/regiongen/functions/load.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
scoreboard objectives add regiongen dummy

scoreboard players set xRegionSize regiongen 32
scoreboard players set zRegionSize regiongen 32
scoreboard players set curX regiongen 0
scoreboard players set curZ regiongen 0
scoreboard players set stepLength regiongen 20
scoreboard players set #nextStep regiongen 0
3 changes: 3 additions & 0 deletions data/regiongen/functions/start.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
tag @s add regiongen
summon armor_stand ~ ~ ~ {Tags: [regiongen_as], NoGravity: 1b, Marker: 1b}
execute as @e[tag=regiongen_as] at @s run forceload add ~ ~
2 changes: 2 additions & 0 deletions data/regiongen/functions/step.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
execute if score #nextStep regiongen >= stepLength regiongen run function regiongen:teleport
scoreboard players add #nextStep regiongen 1
7 changes: 7 additions & 0 deletions data/regiongen/functions/stop.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
tag @a remove regiongen
scoreboard players set curX regiongen 0
scoreboard players set curZ regiongen 0
scoreboard players set #nextStep regiongen 0

kill @e[tag=regiongen_as]
forceload remove all
11 changes: 11 additions & 0 deletions data/regiongen/functions/teleport.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
execute unless score curX regiongen matches 0 run function regiongen:teleport_next_row
execute if score curX regiongen matches 0 if score curZ regiongen matches 0 run function regiongen:teleport_next_row
execute if score curX regiongen matches 0 unless score curZ regiongen matches 0 run function regiongen:teleport_next_col

execute unless score curZ regiongen < zRegionSize regiongen run function regiongen:stop

scoreboard players add curX regiongen 1
scoreboard players operation curX regiongen %= xRegionSize regiongen
execute if score curX regiongen matches 0 run scoreboard players add curZ regiongen 1

scoreboard players set #nextStep regiongen 0
3 changes: 3 additions & 0 deletions data/regiongen/functions/teleport_next_col.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
execute as @e[tag=regiongen_as] at @s run tp @s ~ ~ ~16
execute as @a[tag=regiongen] run tp @s @e[tag=regiongen_as,limit=1,sort=nearest]
execute as @e[tag=regiongen_as] at @s run forceload add ~ ~
1 change: 1 addition & 0 deletions data/regiongen/functions/teleport_next_row.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
execute as @a[tag=regiongen] at @s run tp @s ~16 ~ ~
1 change: 1 addition & 0 deletions data/regiongen/functions/tick.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
execute if entity @a[tag=regiongen] run function regiongen:step
6 changes: 6 additions & 0 deletions pack.mcmeta
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"pack": {
"pack_format": 6,
"description": "A data pack for pregenerating a certain region in the world"
}
}

0 comments on commit 5fb3e1e

Please sign in to comment.