Skip to content

Commit

Permalink
feat: add actual project files
Browse files Browse the repository at this point in the history
  • Loading branch information
2mal3 committed May 5, 2024
1 parent 59b0235 commit a677b52
Show file tree
Hide file tree
Showing 16 changed files with 187 additions and 90 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ on:

env:
VERSION: '1.20'
NAME: ''
NAME: 'Advancement-Count'

jobs:
build:
Expand Down
18 changes: 2 additions & 16 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ permissions:
contents: write

env:
NAME: ''
MODRINTH_ID: ''
NAME: 'Advancement-Count'
MODRINTH_ID: '2tEdxXOF'

jobs:
build:
Expand Down Expand Up @@ -43,25 +43,13 @@ jobs:
- name: Add secondary files to datapack
run: zip -u ${{ env.NAME }} LICENSE.txt README.md CHANGELOG.md

- name: Squash resourcepack
uses: ComunidadAylas/PackSquash-action@v4
with:
packsquash_version: v0.4.0
artifact_name: resourcepack-raw
options: |
pack_directory = "build/${{ env.NAME }}-Resourcepack"
output_file_path = "${{ env.NAME }}-Resourcepack.zip"
- name: Add secondary files to resourcepack
run: zip -u ${{ env.NAME }}-Resourcepack LICENSE.txt README.md CHANGELOG.md

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: artifact
path: |
CHANGELOG.md
${{ env.NAME }}.zip
${{ env.NAME }}-Resourcepack.zip
release-github:
runs-on: ubuntu-latest
Expand All @@ -80,7 +68,6 @@ jobs:
body_path: CHANGELOG.md
files: |
${{ env.NAME }}.zip
${{ env.NAME }}-Resourcepack.zip
release-modrinth:
runs-on: ubuntu-latest
Expand All @@ -100,7 +87,6 @@ jobs:
modrinth-unfeature-mode: intersection
files: |
${{ env.NAME }}.zip
${{ env.NAME }}-Resourcepack.zip
name: ${{ env.NAME }} ${{github.ref_name}}
version: ${{github.ref_name}}
version-type: release
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Changed

- update to Minecraft version 1.20.4
33 changes: 32 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,32 @@
# datapack-template
# Advancement-Count

![release](https://img.shields.io/github/v/release/2mal3/Advancement-Count?style=flat-square) ![version](https://img.shields.io/badge/Minecraft-1.20-orange?style=flat-square) ![downloads](https://img.shields.io/github/downloads/2mal3/Advancement-Count/total?style=flat-square)

Advancement Count is a simple datapack that awards players a certain number of points for each advancement they complete.
The total number of all points for each player can then be viewed in the player list and compared between players, providing an alternative competition to the normal game play.

### 📖 Features

- ⚖️ balanced, point rewards depend on the difficulty of the advancement
- 🚀 fast and optimized, creates no lag
- 🪶 lightweight
- ♻️ fast and complete updates to new versions of Minecraft, thanks to an automated build system

The maximum number of points you can score is 206.

### ⭐ Rewards

- Task (square boxes) → 1 point
- Goal (rounded boxes) → 2 points
- Challenge (decorated boxes) → 5 points

## 📝 Notes

- **ONLY** the latest version of the datapack for Fabric and Vanilla 1.20 is supported
- advancements from other datapacks or mods are not supported
- bug reports and suggestions are **ONLY** accepted on [GitHub](https://github.com/2mal3/No-Lag/issues)
- to uninstall, run the command `/function adco:core/uninstall`and then optionally delete the datapack file
- to reset the scores for all current players, run the command `/function adco:reset`
- datapack was created with the help of [beet](https://github.com/mcbeet/beet)

_v1.15_
42 changes: 19 additions & 23 deletions beet.yaml
Original file line number Diff line number Diff line change
@@ -1,25 +1,18 @@
id: ""
name: ""
description: ""
id: "adco"
name: "Advancement Count"
description: "Awards players a certain number of points for each advancement they complete. The total number for each player can then be viewed in the Tab list."
author: "2mal3"
version: "v0.1.0"
version: "v1.1.1"
minecraft: "1.20"

output: "build"

data_pack:
name: ""
description: "v0.1.0"
load:
- "src"
- pack.png: "pack.png"


resource_pack:
name: "-Resourcepack"
load:
- assets: "assets"
- pack.png: "pack.png"
name: "Advancement-Count"
description: "v1.1.0"
load:
- "src"
- pack.png: "pack.png"

pipeline:
- mecha
Expand All @@ -29,12 +22,15 @@ require:
- bolt

meta:
version: 100
version: 10101

bolt:
entrypoint:
- adco:advancements

bolt:
entrypoint:
- ""
vanilla:
version: "1.20.1"

installation_advancement:
icon:
item: "minecraft:cobblestone"
installation_advancement:
icon:
item: minecraft:knowledge_book
Binary file modified pack.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "template"
version = "0.1.0"
name = "advancement-count"
version = "1.1.1"
description = "Add your description here"
authors = [
{ name = "2mal3", email = "56305732+2mal3@users.noreply.github.com" }
Expand Down
6 changes: 3 additions & 3 deletions requirements-dev.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
annotated-types==0.6.0
# via pydantic
beet==0.105.0
# via advancement-count
# via bolt
# via mecha
# via template
bolt==0.48.0
# via template
# via advancement-count
click==8.1.7
# via beet
# via click-help-colors
Expand All @@ -26,8 +26,8 @@ jinja2==3.1.3
markupsafe==2.1.5
# via jinja2
mecha==0.94.0
# via advancement-count
# via bolt
# via template
nbtlib==1.12.1
# via beet
numpy==1.26.4
Expand Down
6 changes: 3 additions & 3 deletions requirements.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
annotated-types==0.6.0
# via pydantic
beet==0.105.0
# via advancement-count
# via bolt
# via mecha
# via template
bolt==0.48.0
# via template
# via advancement-count
click==8.1.7
# via beet
# via click-help-colors
Expand All @@ -26,8 +26,8 @@ jinja2==3.1.3
markupsafe==2.1.5
# via jinja2
mecha==0.94.0
# via advancement-count
# via bolt
# via template
nbtlib==1.12.1
# via beet
numpy==1.26.4
Expand Down
40 changes: 0 additions & 40 deletions src/data/___/functions/core.mcfunction

This file was deleted.

49 changes: 49 additions & 0 deletions src/data/adco/functions/core.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
from 2mal3:log import log


## Load
function ~/load:
scoreboard objectives add adco.data dummy

log "info" "server" "Loaded!"

execute unless score %installed adco.data matches 1 run function ~/install
execute if score %installed adco.data matches 1 unless score $version adco.data matches ctx.meta.version run function ~/update


## Install
function ~/load/install:
scoreboard players set %installed adco.data 1

scoreboard objectives add 2mal3.debug_mode dummy
scoreboard objectives add adco.score dummy
scoreboard objectives setdisplay list adco.score
scoreboard objectives modify adco.score rendertype integer
# Set the version in format: xx.xx.xx
scoreboard players set $version adco.data ctx.meta.version

# Sent installation message after 4 seconds
schedule function ~/send_message 4s replace:
tellraw @a:
text: f"Installed {ctx.project_name} {ctx.project_version} from {ctx.project_author}!"
color: "green"


## Update
function ~/update:
execute if score $version adco.data matches 10100:
scoreboard players set $version adco.data 10101
log "info" "server" "Updated to 1.0.1"


## Uninstall
function ~/uninstall:
scoreboard objectives remove adco.data
scoreboard objectives remove adco.score

tellraw @a:
text: f"Uninstalled {ctx.project_name} {ctx.project_version} from {ctx.project_author}!"
color: "green"

datapack disable f"file/{ctx.project_name}"
datapack disable f"file/{ctx.project_name}.zip"
9 changes: 9 additions & 0 deletions src/data/adco/functions/count.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

function ~/1:
scoreboard players add @s adco.score 1

function ~/2:
scoreboard players add @s adco.score 2

function ~/5:
scoreboard players add @s adco.score 5
11 changes: 11 additions & 0 deletions src/data/adco/functions/reset.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

advancement revoke @a everything

scoreboard objectives remove adco.score
scoreboard objectives add adco.score dummy
scoreboard objectives setdisplay list adco.score
scoreboard objectives modify adco.score rendertype integer

tellraw @s:
text: "Reset all Advancements for all current players"
color: "gold"
31 changes: 31 additions & 0 deletions src/data/adco/functions/unlock_previous.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from beet.contrib.vanilla import Vanilla


vanilla_advancements = ctx.inject(Vanilla).mount("data/minecraft/advancements").data.advancements
for name, advancement in vanilla_advancements.items():
if "recipes" in name: # Skip recipe unlocking advancements
continue

# Create a predicate for the advancement to test if it has been unlocked
predicate_name = name.split(":")[1].replace("/", "-")
predicate_content = {
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type_specific": {
"type": "player",
"advancements": {}
}
}
}
predicate_content["predicate"]["type_specific"]["advancements"][name] = true
predicate f"adco:unlock_previous/{predicate_name}" predicate_content

# Give the corresponding points to all players that have unlocked the advancement
advancement_content = advancement.data
if advancement_content["display"]["frame"] == "task":
execute if predicate f"adco:unlock_previous/{predicate_name}" run function adco:count/1
if advancement_content["display"]["frame"] == "goal":
execute if predicate f"adco:unlock_previous/{predicate_name}" run function adco:count/2
if advancement_content["display"]["frame"] == "challenge":
execute if predicate f"adco:unlock_previous/{predicate_name}" run function adco:count/5
21 changes: 21 additions & 0 deletions src/data/adco/modules/advancements.bolt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from beet.contrib.vanilla import Vanilla


vanilla_advancements = ctx.inject(Vanilla).mount("data/minecraft/advancements").data.advancements
for name, advancement in vanilla_advancements.items():
if "recipes" in name: # Skip recipe unlocking advancements
continue

modified_advancement = advancement.data

if "rewards" not in modified_advancement:
modified_advancement["rewards"] = {}

if modified_advancement["display"]["frame"] == "task":
modified_advancement["rewards"]["function"] = "adco:count/1"
if modified_advancement["display"]["frame"] == "goal":
modified_advancement["rewards"]["function"] = "adco:count/2"
if modified_advancement["display"]["frame"] == "challenge":
modified_advancement["rewards"]["function"] = "adco:count/5"

advancement name modified_advancement
2 changes: 1 addition & 1 deletion src/data/load/tags/functions/load.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"values": [
"___:core/load"
"adco:core/load"
]
}

0 comments on commit a677b52

Please sign in to comment.