Skip to content

Commit

Permalink
Merge branch 'Gamemode4Dev:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
TheThanathor authored Oct 23, 2023
2 parents 37e0be9 + bb4cde7 commit 4e61c67
Show file tree
Hide file tree
Showing 152 changed files with 5,205 additions and 270 deletions.
3 changes: 3 additions & 0 deletions gm4/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ def readme_gen(ctx: click.Context, project: Project, modules: tuple[str], watch:
"broadcast": modules,
"extend": "beet.yaml",
"meta": {"readme-gen": True},
"require":[
"gm4.plugins.player_heads",
],
"pipeline": [
"gm4.plugins.manifest.write_credits",
"gm4.plugins.readme_generator",
Expand Down
41 changes: 23 additions & 18 deletions gm4/plugins/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,25 +153,32 @@ def update_patch(ctx: Context):
for id in packs:
pack = packs[id]
released = released_modules.get(id, None)
last_ver = Version(released.version) if released else Version("0.0.0")
version = Version(pack.version)

publish_date = released.publish_date if released else None
pack.publish_date = publish_date or datetime.datetime.now().date().isoformat()

deps = _traverse_includes(id)
if packs is manifest_cache.modules:
deps |= {"base"} # scan the base directory if this is a module
deps_dirs = [element for sublist in [[f"{d}/data", f"{d}/*py"] for d in deps] for element in sublist]

# add watches to skins this module uses from other modules. NOTE this could be done in a more extendable way in the future, rather than "hardcoded"
skin_dep_dirs: list[str] = []
for skin_ref in skin_cache["nonnative_references"].get(id, []):
d = skin_cache["skins"][skin_ref]["parent_module"]
ns, path = skin_ref.split(":")
skin_dep_dirs.append(f"{d}/data/{ns}/skins/{path}.png")

watch_dirs = deps_dirs+skin_dep_dirs
if version != last_ver.replace(patch=None): # check for forced content-less version increment
diff = True

else: # otherwise check for file differences
deps = _traverse_includes(id)
if packs is manifest_cache.modules:
deps |= {"base"} # scan the base directory if this is a module
deps_dirs = [element for sublist in [[f"{d}/data", f"{d}/overlay_*/data", f"{d}/*py"] for d in deps] for element in sublist]

# add watches to skins this module uses from other modules. NOTE this could be done in a more extendable way in the future, rather than "hardcoded"
skin_dep_dirs: list[str] = []
for skin_ref in skin_cache["nonnative_references"].get(id, []):
d = skin_cache["skins"][skin_ref]["parent_module"]
ns, path = skin_ref.split(":")
skin_dep_dirs.append(f"{d}/data/{ns}/skins/{path}.png")

watch_dirs = deps_dirs+skin_dep_dirs

diff = run(["git", "diff", last_commit, "--shortstat", "--", f"{id}/data", f"{id}/*.py"] + watch_dirs) if last_commit else True
diff = run(["git", "diff", last_commit, "--shortstat", "--", f"{id}/data", f"{id}/overlay_*", f"{id}/*.py"] + watch_dirs) if last_commit else True
# NOTE it may be needed later to only search overlay_*/data, but that currently caused some issues with GH action

if not diff and released:
# No changes were made, keep the same patch version
Expand All @@ -181,12 +188,10 @@ def update_patch(ctx: Context):
pack.version = pack.version.replace("X", "0")
logger.debug(f"First release of {id}")
else:
# Changes were made, bump the patch
version = Version(pack.version)
last_ver = Version(released.version)

# Changes were made, bump the patch
if version.minor > last_ver.minor or version.major > last_ver.major: # type: ignore
version.patch = 0
logger.info(f"Feature update for {id}, setting version to {version}")
else:
version.patch = last_ver.patch + 1 # type: ignore
logger.info(f"Updating {id} patch to {version.patch}")
Expand Down
2 changes: 1 addition & 1 deletion gm4/plugins/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
MODRINTH_AUTH_KEY = "BEET_MODRINTH_TOKEN"
SMITHED_API = "https://api.smithed.dev/v2"
SMITHED_AUTH_KEY = "BEET_SMITHED_TOKEN"
SUPPORTED_GAME_VERSIONS = ["1.20", "1.20.1"]
SUPPORTED_GAME_VERSIONS = ["1.20", "1.20.1", "1.20.2"]
USER_AGENT = "Gamemode4Dev/GM4_Datapacks/release-pipeline ([email protected])"

class ModrinthConfig(PluginOptions):
Expand Down
4 changes: 4 additions & 0 deletions gm4/plugins/write_mcmeta.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ def beet_default(ctx: Context):
"""Writes the pack.mcmeta based on the module name and version."""
version = os.getenv("VERSION", "1.20")
ctx.data.pack_format = 15 # manually set as beet's `latest` is not available for 1.20 at this time.
ctx.data.supported_formats = {
"min_inclusive": 15,
"max_inclusive": 18
}
ctx.data.description = [
ctx.project_name,
"\n",
Expand Down
7 changes: 6 additions & 1 deletion gm4/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import subprocess
import warnings
from dataclasses import dataclass
from dataclasses import dataclass, asdict
from typing import Any
from functools import total_ordering

Expand Down Expand Up @@ -57,6 +57,11 @@ def __lt__(self, other: object) -> bool:
return False
raise TypeError

def replace(self, **changes: Any):
params = asdict(self) | changes
params = {k:(v if v is not None else 'X') for k,v in params.items()}
return Version(f"{params['major']}.{params['minor']}.{params['patch']}")

def nested_get(d: dict[str, Any], key: str) -> list[Any]:
"""Recursively traverses a string-keyed dict (like minecraft json files) for the specified key, returning all that exist
returns empty list and throws no errors if key does not exist"""
Expand Down
25 changes: 25 additions & 0 deletions gm4_auto_crafting/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Auto Crafting <!--$headerTitle--> <!--$pmc:delete-->

Excited for the new 1.21 crafter block? Want to start making the cake factory of your dreams right now? Try out Gamemode 4's take on auto-crafting, available right now for 1.19 and 1.20!<!--$pmc:headerSize-->

<img src="images/auto_crafter.webp" alt="Auto Crafter at work" width="350"/> <!--$localAssetToURL--> <!--$modrinth:replaceWithVideo--> <!--$pmc:delete-->

### Features
- Crafts any vanilla item.
- Set the recipe shape, give it ingredients one at a time, and power the piston to craft the item
- Build a cool steampunk multiblock structure

### Creation
Craft the auto-crafter in a [Custom Crafter](https://wiki.gm4.co/wiki/Custom_Crafters)

<img src="images/crafting_recipe.png" alt="Auto Crafter Recipe" width="150"/> <!--$localAssetToURL-->

Build the Multiblock Structure

<img src="images/setting-up-a-crafter.webp" alt="Auto Crafter Recipe" width="200"/> <!--$localAssetToURL-->

### Usage
- Set the shape of your recipe inside the Auto Crafter, using any items
- Fill the top barrel with the ingredients of your recipe, in order
- Power the Piston to craft the item
- Retrieve the result from the bottom barrel
6 changes: 6 additions & 0 deletions gm4_auto_crafting/beet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,9 @@ meta:
- BluePsychoRanger
Icon Design:
- Hozz
modrinth:
project_id: WkDoUESw
smithed:
pack_id: gm4_auto_crafting
planetminecraft:
uid: 6097435
Binary file added gm4_auto_crafting/images/auto_crafter.webp
Binary file not shown.
Binary file added gm4_auto_crafting/images/crafting_recipe.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file added gm4_auto_crafting/pack.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion gm4_chairs/beet.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
id: gm4_chairs
name: Chairs
version: 1.2.X
version: 1.3.X

data_pack:
load: .
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Create chair from saddle item
# @s = saddle item on top of stairs
# at @s align xyz positioned ~.5 ~ ~.5
# run from main

# spawn chair
summon minecraft:pig ~ ~-10000.39 ~ {CustomName:'"gm4_chair"',Tags:["gm4_chairs","smithed.entity","smithed.strict","smithed.block"],Team:"gm4_chairs",NoAI:1b,Saddle:1b,NoGravity:1b,Silent:1b,DeathTime:19s,InLove:2147483647,Attributes:[{Name:"generic.max_health",Base:1.0},{Name:"generic.movement_speed",Base:0.0}],active_effects:[{id:'minecraft:invisibility',amplifier:0,duration:2147483647,show_particles:0b},{id:'minecraft:resistance',amplifier:10b,duration:2147483647,show_particles:0b}],DeathLootTable:"minecraft:empty"}

# set chair to orientation of stairs
execute if block ~ ~ ~ #minecraft:stairs[facing=north] positioned ~ ~-10000 ~ as @e[type=minecraft:pig,tag=gm4_chairs,distance=..0.4,limit=1] at @s run tp @s ~ ~10000 ~.05 0 0
execute if block ~ ~ ~ #minecraft:stairs[facing=south] positioned ~ ~-10000 ~ as @e[type=minecraft:pig,tag=gm4_chairs,distance=..0.4,limit=1] at @s run tp @s ~ ~10000 ~-.05 180 0
execute if block ~ ~ ~ #minecraft:stairs[facing=east] positioned ~ ~-10000 ~ as @e[type=minecraft:pig,tag=gm4_chairs,distance=..0.4,limit=1] at @s run tp @s ~-.05 ~10000 ~ 90 0
execute if block ~ ~ ~ #minecraft:stairs[facing=west] positioned ~ ~-10000 ~ as @e[type=minecraft:pig,tag=gm4_chairs,distance=..0.4,limit=1] at @s run tp @s ~.05 ~10000 ~ -90 0

# store saddle data in chair
data modify entity @e[type=minecraft:pig,tag=gm4_chairs,distance=..0.4,limit=1] HandItems[0] set from entity @s Item
scoreboard players set @e[type=minecraft:pig,tag=gm4_chairs,distance=..0.4,limit=1] gm4_entity_version 1

# place sound
playsound minecraft:block.wool.place block @a[distance=..5] ~ ~ ~ .5 2

# advancement for creating a chair
advancement grant @a[distance=..3,gamemode=!spectator] only gm4:chairs_creation

# kill the saddle item
kill @s
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Replace zombified piglin with chair
# @s = zombified piglin that replaced the pig/chair
# at @s
# runs from lightning/delay

# spawn chair
summon minecraft:pig ~ ~-10000 ~ {Tags:["gm4_chairs","smithed.entity","smithed.strict","smithed.block"],Team:"gm4_chairs",NoAI:1b,Saddle:1b,NoGravity:1b,Silent:1b,DeathTime:19s,InLove:2147483647,Attributes:[{Name:"generic.movement_speed",Base:0.0}],active_effects:[{id:'minecraft:invisibility',amplifier:0,duration:2147483647,show_particles:0b},{id:'minecraft:resistance',amplifier:10b,duration:2147483647,show_particles:0b}],DeathLootTable:"minecraft:empty"}
execute positioned ~ ~-10000 ~ run scoreboard players set @e[type=pig,tag=gm4_chairs,limit=1,distance=..0.1] gm4_entity_version 1

# copy zombified piglin rotation
execute rotated as @s positioned ~ ~-10000 ~ run tp @e[type=minecraft:pig,tag=gm4_chairs,distance=..0.4,limit=1] ~ ~10000 ~ ~ ~

# kill zombified piglin
tp @s ~ -10000 ~
10 changes: 10 additions & 0 deletions gm4_chairs/pack.mcmeta
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"overlays": {
"entries": [
{
"formats": 18,
"directory": "overlay_18"
}
]
}
}
2 changes: 1 addition & 1 deletion gm4_combat_expanded/beet.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
id: gm4_combat_expanded
name: Combat Expanded
version: 1.3.X
version: 1.4.X

data_pack:
load: .
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# match wolf to armor slot and player id
# @s = new wolf
# at unspecified
# run from armor/type/canine/wolf_spawn

data merge entity @s {CollarColor:15b,Tags:["gm4_ce_wolf"],active_effects:[{id:'minecraft:resistance',amplifier:9b,duration:-1,show_particles:0b}],Attributes:[{Name:"generic.attack_damage",Base:4}]}

scoreboard players operation @s gm4_ce_id = $curr_id gm4_ce_id
scoreboard players operation @s gm4_ce_data = $slot gm4_ce_data
data modify entity @s Owner set from storage gm4_combat_expanded:temp uuid

execute store result score $name_len gm4_ce_data run data get storage gm4_combat_expanded:temp tag.display.Name
execute if score $name_len gm4_ce_data matches ..75 run data modify entity @s CustomName set from storage gm4_combat_expanded:temp tag.display.Name
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# apply glowing and first_strike damage to entities hit
# @s = entity being hit with glow
# at unspecified
# run from weapon/modifier/glow/activate

# if not hit with glow yet activate first strike
execute unless data entity @s ActiveEffects[{id:'minecraft:glowing'}] run function gm4_combat_expanded:weapon/modifier/glow/first_strike
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
{
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "minecraft:tipped_arrow",
"functions": [
{
"function": "minecraft:set_nbt",
"tag": "{custom_potion_effects:[{id:'minecraft:weakness',amplifier:0b,duration:100},{id:'minecraft:hunger',amplifier:1b,duration:100},{id:'minecraft:poison',amplifier:0b,duration:100}],CustomPotionColor:5149489,HideFlags:32}"
},
{
"function": "minecraft:set_lore",
"lore": [
{
"translate": "potion.withDuration",
"with": [
{
"translate": "potion.withAmplifier",
"with": [
{
"translate": "effect.minecraft.hunger"
},
{
"translate": "potion.potency.1"
}
]
},
"0:05"
],
"color": "red",
"italic": false
},
{
"translate": "potion.withDuration",
"with": [
{
"translate": "effect.minecraft.weakness"
},
"0:05"
],
"color": "red",
"italic": false
},
{
"translate": "potion.withDuration",
"with": [
{
"translate": "effect.minecraft.poison"
},
"0:05"
],
"color": "red",
"italic": false
},
"",
{
"translate": "potion.whenDrank",
"color": "purple",
"italic": false
},
{
"translate": "attribute.modifier.take.0",
"with": [
"4",
{
"translate": "attribute.name.generic.attack_damage"
}
],
"color": "red",
"italic": false
}
]
},
{
"function": "minecraft:set_name",
"name": {
"translate": "item.minecraft.tipped_arrow.effect.poison",
"italic": false
}
}
]
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "minecraft:tipped_arrow",
"functions": [
{
"function": "minecraft:set_nbt",
"tag": "{custom_potion_effects:[{id:'minecraft:slowness',amplifier:0b,duration:600}],Potion:\"minecraft:harming\",HideFlags:32,CustomPotionColor:4393481}"
},
{
"function": "minecraft:set_lore",
"lore": [
{
"translate": "potion.withDuration",
"with": [
{
"translate": "effect.minecraft.slowness"
},
"0:30"
],
"color": "red",
"italic": false
},
{
"translate": "effect.minecraft.instant_damage",
"color": "red",
"italic": false
},
"",
{
"translate": "potion.whenDrank",
"color": "purple",
"italic": false
},
{
"translate": "attribute.modifier.take.1",
"with": [
"15",
{
"translate": "attribute.name.generic.movement_speed"
}
],
"color": "red",
"italic": false
}
]
},
{
"function": "minecraft:set_name",
"name": {
"translate": "item.minecraft.tipped_arrow.effect.harming",
"italic": false
}
}
]
}
]
}
]
}
Loading

0 comments on commit 4e61c67

Please sign in to comment.