Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/SuperAnt220/antbot into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperAnt220 committed Dec 14, 2024
2 parents 033da48 + 7ed3822 commit 0f7b907
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 8 deletions.
15 changes: 12 additions & 3 deletions assets/faqs/item_model/item_model.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
## {item_modifier} Компонент `item_model`
В 1.21.2 был добавлен компонент `item_model`, который значительно упрощает изменение модели определённого предмета без использования кастом модел даты (смотрите `?cmd`).

Работает он очень просто - в него нужно вписать путь к модели предмета в ресурспаке, и путь начинается с папки `assets/minecraft/models/item`. Например, если нужно выдать палку с моделью стержня энда, это можно сделать так:
Работает он очень просто - в него нужно вписать путь к модели предмета в ресурспаке, и путь начинается с папки `assets/namespace/items`. Например, если нужно выдать палку с моделью стержня энда, это можно сделать так:
```ansi
give @s stick[item_model="end_rod"]```
А если у нас есть кастомная модель в ресурспаке, и лежит она, например, по пути `assets/namespace/models/item/custom/fire_wand.json`, то команда выдачи будет выглядеть так:
А если у нас есть кастомная модель в ресурспаке, и лежит она, например, по пути `assets/namespace/models/item/custom/fire_wand.json`, то сначала надо сделать для неё специальный джсон файл, например `assets/namespace/items/custom/wand.json`, в котором самый простой способ прописать модель будет так:
```json
{
"model": {
"type": "minecraft:model",
"model": "<путь к модели в models>"
}
}
```
И тогда команда выдачи будет выглядеть так:
```ansi
[35mgive [36m@s [0mstick[33m[[37mitem_model[34m=[32m"namespace:custom/fire_wand"[33m]```
[35mgive [36m@s [0mstick[33m[[37mitem_model[34m=[32m"namespace:custom/wand"[33m]```
2 changes: 1 addition & 1 deletion assets/links.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"https://github.com/PuckiSilver/mc-silica": ["mc-silica","cooldown lib","cdlib","силика","мссилика","кдлиб","кулдаун библиотека","ьс-ышдшсф"],
"https://github.com/ShockMicro/CorePerspectiveModels": ["CorePerspectiveModels","cpm","core perspective models","корперспективмоделс","сщкузукызусешмуьщвуды"],
"https://github.com/ShockMicro/VanillaDynamicEmissives": ["VanillaDynamicEmissives","emissive textures","vde","emissives","ВаниллаДайнемикЭмиссивс","вде","эмиссивные текстуры","эмиссивность","мфтшддфвнтфьшсуьшыышмуы"],
"https://github.com/CloudWolfYT/ShaderSelectorV2": ["ShaderSelectorV2","shader selector","post shaders switch","ss","Шейдер селектор","переключать пост шейдеров","шс","ырфвукыудусещк"],
"https://github.com/HalbFettKaese/ShaderSelectorV3": ["ShaderSelectorV2","shader selector","post shaders switch","ss","Шейдер селектор","переключать пост шейдеров","шс","ырфвукыудусещк"],
"https://github.com/onnowhere/VertexEdit": ["VertexEdit","veredit","ve","вершинный редактор","вэдит","мукеучувше"],
"https://sourceblock.net/beta/en-US/tools/data-packs/raycasting-generator": ["Raycast Generator","raycastgen","rg","генератор рейкастов","рейкастген","кфнсфые путукфещк"],
"https://vberlier.github.io/animated-models/": ["Item model animator","animated-models","am","аниматор моделей предметов","аним модели","ам","шеуь ьщвуд фтшьфещк"],
Expand Down
24 changes: 20 additions & 4 deletions cogs/minecraft/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@
from io import BytesIO
from pymongo import MongoClient

from settings import MONGO_URI, GITHUB_HEADERS
from settings import MONGO_URI, GITHUB_HEADERS, LOGS_CHANNEL_ID
from utils.tree_gen import generate_tree
from utils.general import handle_errors
from utils.shortcuts import no_color, no_ping

db = MongoClient(MONGO_URI).antbot.minecraft_data
versions_pathes = MongoClient(MONGO_URI).antbot.versons_pathes
versions_pathes = MongoClient(MONGO_URI).antbot.versions_pathes
files = {}
latest_version = ""
logs_channel = None


class FileCommand(commands.Cog):
Expand All @@ -25,8 +26,11 @@ def __init__(self, bot):
self.update_files_list.start()

async def get_files_list(self, branches=("data", "assets")):
global logs_channel
await logs_channel.send("getting files...")
async with ClientSession(headers=GITHUB_HEADERS) as session:
current_files = {}
await logs_channel.send("Client session started")
for branch in branches:
async with session.get(f"https://api.github.com/repos/misode/mcmeta/git/trees/{branch}?recursive=1") as response:
if response.status == 200:
Expand All @@ -37,25 +41,35 @@ async def get_files_list(self, branches=("data", "assets")):
for item in tree if item["type"] == "blob"
})
else:
await logs_channel.send(f"Resoponse error idk {response.status} {response}")
raise Exception(f"Response error")
await logs_channel.send("`for branch in bracnhes` finished")
try:
current_files.pop(".gitattributes")
except:pass
await logs_channel.send("returning the files")
return current_files

@tasks.loop(minutes=6)
async def update_files_list(self):
global latest_version, files
global latest_version, files, logs_channel
logs_channel = await self.bot.fetch_channel(LOGS_CHANNEL_ID)
await logs_channel.send(f'latest_known_snapshot: `{db.find_one({"_id": "latest_known_snapshot"})["_"]}`, latest_version: `{latest_version}`')
if (newer_version:=db.find_one({"_id": "latest_known_snapshot"})["_"]) != latest_version:
await logs_channel.send(f"`newer_version`({newer_version}) != `latest_version`({latest_version})")
if (latest_files := versions_pathes.find_one({"_id": newer_version.replace('.', '_')})):
files = latest_files["_"]
await logs_channel.send("files already exist")
else:
await logs_channel.send("files are not exist rn")
files = await self.get_files_list()
await self.update_versions_hashes(newer_version)
latest_version = newer_version
await logs_channel.send("all the stuff finished yeaa")
versions_pathes.insert_one({"_id": latest_version.replace('.', '_'), "_": files})

async def update_versions_hashes(self, newer_version=None):
await logs_channel.send("started updating versions hashes")
versions_hashes = db.find_one({"_id": "versions_hashes"})
if versions_hashes:
versions_hashes = versions_hashes["_"]
Expand All @@ -66,20 +80,22 @@ async def update_versions_hashes(self, newer_version=None):
while True:
url = f"https://api.github.com/repos/misode/mcmeta/commits?sha={branch}&per_page=100&page={page}"
async with ClientSession(headers=GITHUB_HEADERS) as session:
await logs_channel.send(f"client session started, curr page is `{page}`")
async with session.get(url) as response:
if response.status == 200:
data = await response.json()
print(data)
if not data:
break
for commit in data:
version = commit["commit"]["message"].split(" ")[-1].replace(".", "_")
versions_hashes[branch][version] = commit["sha"]
else:
await logs_channel.send(f"Failed to fetch commits. Status code: {response.status}")
print(f"Failed to fetch commits. Status code: {response.status}")
break
page += 1
if newer_version and not (newer_version in versions_hashes["data"]):
await logs_channel.send("Mcmeta not updated")
raise Exception("Mcmeta not updated")
db.update_one({"_id": "versions_hashes"}, {"$set": {"_": versions_hashes}}, upsert=True)

Expand Down

0 comments on commit 0f7b907

Please sign in to comment.