-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update plugins subproject commit hash
- Loading branch information
1 parent
356b33e
commit d3c69f0
Showing
7 changed files
with
945 additions
and
2 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 |
---|---|---|
|
@@ -21,5 +21,3 @@ lodestone/test_plugins.py | |
lodestone/cache/ | ||
lodestone/.env | ||
lodestone/favicon.png | ||
lodestone/plugins | ||
plugins |
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,12 @@ | ||
from cactus_farm_builder import cactus | ||
from discord_webhook import discord | ||
from schematic_builder import schematic | ||
from discordrp import discordrp | ||
|
||
class plugins: | ||
def __init__(self): | ||
self.cactus = cactus() | ||
self.discordrp = discordrp() | ||
self.discord = discord() | ||
self.schematic = schematic() | ||
super().__init__() |
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,87 @@ | ||
# needs to be converted to a plugin | ||
|
||
|
||
import lodestone | ||
import time | ||
|
||
bot = lodestone.createBot( | ||
host='0.tcp.ap.ngrok.io', | ||
username='farmer', | ||
auth='offline', | ||
port=14995, | ||
version='1.19', | ||
ls_skip_checks=True | ||
) | ||
|
||
password = 'password' | ||
menu_item_id = 'birch_sapling' | ||
borken_counter = 0 | ||
scan_radius = 500 | ||
|
||
# @bot.on('spawn') | ||
def start(): | ||
global borken_counter | ||
# bot.chat(f'/login {password}') | ||
# time.sleep(3) | ||
# bot.chat('/menu') | ||
# @bot.once('windowOpen') | ||
# def on_window_open(window): | ||
# boats = [x for x in window.slots if x is not None and x.displayName == menu_item_id] | ||
# mouseButton = 0 # 0: left click, 1: right click | ||
# mode = 0 # 0: single click | ||
# bot.clickWindow(boats[0].slot, mouseButton, mode) | ||
# time.sleep(10) | ||
blockType = bot.bot.registry.blocksByName["sugar_cane"] | ||
def blockToHarvest(search_range=4, amount=1): | ||
curr_amount = 0 | ||
sugarcaneBlocks = bot.bot.findBlocks({ | ||
'matching': blockType.id, | ||
'count': scan_radius, | ||
'maxDistance': search_range, | ||
'useExtraInfo': False, | ||
}) | ||
if len(sugarcaneBlocks.valueOf()) == 0: | ||
print("nah im good") | ||
breakableSugarCane = [] | ||
for i in sugarcaneBlocks: | ||
print(i) | ||
if curr_amount == amount: | ||
return breakableSugarCane | ||
# stuff here | ||
idkblock = bot.bot.blockAt(i) | ||
belowBlock = bot.bot.blockAt(idkblock.position.offset(0, -1, 0)) | ||
if not belowBlock or belowBlock.name != "sugar_cane": | ||
continue | ||
breakableSugarCane.append(idkblock) | ||
curr_amount += 1 | ||
|
||
input('press enter to start') | ||
while True: | ||
blocks = blockToHarvest(amount=10) | ||
if blocks != None: | ||
for target in blocks: | ||
print(target.position) | ||
try: | ||
bot.bot.dig(target, {'forceLook':True}) | ||
borken_counter += 1 | ||
except Exception as e: | ||
print(e) | ||
print('error collecting reeds') | ||
continue | ||
else: | ||
blocks = blockToHarvest(amount=1, search_range=100) | ||
if blocks: | ||
for target in blocks: | ||
print(target.position) | ||
try: | ||
bot.goto(target.position.x, target.position.y, target.position.z) | ||
bot.bot.dig(target, {'forceLook':False}) | ||
borken_counter += 1 | ||
except Exception as e: | ||
print(e) | ||
print('error collecting reeds') | ||
continue | ||
time.sleep(0.5) | ||
|
||
start() | ||
|
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,228 @@ | ||
import lodestone | ||
from rich.console import Console | ||
from rich.progress import Progress | ||
import ast | ||
import inspect | ||
from javascript import require | ||
|
||
import plugins | ||
|
||
class cactus(plugins.Base): | ||
""" | ||
Build in cactus farm builder plugin | ||
""" | ||
def __init__(self, bot: lodestone.Bot): | ||
"The injection method" | ||
self.bot:lodestone.Bot = bot | ||
self.mcData = require('minecraft-data')(bot.bot.version) | ||
self.Item = require('prismarine-item')(bot.bot.version) | ||
self.Vec3 = require('vec3').Vec3 | ||
self.console = Console(force_terminal=True) | ||
self.code = inspect.getsource(inspect.getmodule(self.__class__)) | ||
self.tree = ast.parse(self.code) | ||
self.events = [] | ||
for node in ast.walk(self.tree): | ||
if isinstance(node, ast.Call) and hasattr(node.func, 'attr') and node.func.attr == 'on': | ||
event = node.args[0].s | ||
self.events.append(event) | ||
events_loaded = list(bot.loaded_events.keys()) | ||
events_loaded.append(self.events) # add the event to the list | ||
bot.emit('event_loaded', *events_loaded) | ||
plugins_loaded = list(bot.loaded_plugins.keys()) | ||
plugins_loaded.append(self.__class__.__name__) # add the plugin to the list | ||
bot.emit('plugin_loaded', *plugins_loaded) | ||
self.building_up = False | ||
self.bot.build_cactus:callable = self.start | ||
|
||
def __equip_item(self, name): | ||
id = self.bot.bot.registry.itemsByName[name].id | ||
if not any(x.type == id for x in self.bot.inventory.items()): | ||
slot = self.bot.bot.inventory.firstEmptyInventorySlot() | ||
if slot is None: | ||
slot = 36 | ||
|
||
# if self.bot.bot.player.gamemode == 0: | ||
# self.bot.collect_block(f"{item.name}") | ||
# else: | ||
# self.bot.bot.creative.setInventorySlot(slot, Item(id, 1)) | ||
while True: | ||
try: | ||
self.bot.bot.creative.setInventorySlot(slot, self.Item(id, 1)) | ||
break | ||
except: | ||
continue | ||
item = next(x for x in self.bot.inventory.items() if x.type==id) | ||
self.bot.bot.equip(item, "hand") | ||
|
||
|
||
def __dig_layer(self): | ||
self.bot.bot.dig(self.bot.bot.blockAt(self.bot.entity.position.offset(2, -2, 0)), True) | ||
self.bot.bot.dig(self.bot.bot.blockAt(self.bot.entity.position.offset(2, -2, 2)), True) | ||
self.bot.bot.dig(self.bot.bot.blockAt(self.bot.entity.position.offset(0, -2, 2)), True) | ||
self.bot.bot.dig(self.bot.bot.blockAt(self.bot.entity.position.offset(-2, -2, 2)), True) | ||
self.bot.bot.dig(self.bot.bot.blockAt(self.bot.entity.position.offset(-2, -2, 0)), True) | ||
self.bot.bot.dig(self.bot.bot.blockAt(self.bot.entity.position.offset(-2, -2, -2)), True) | ||
self.bot.bot.dig(self.bot.bot.blockAt(self.bot.entity.position.offset(0, -2, -2)), True) | ||
self.bot.bot.dig(self.bot.bot.blockAt(self.bot.entity.position.offset(2, -2, -2)), True) | ||
|
||
|
||
def __build_up(self): | ||
|
||
old_pos = int(self.bot.entity.position.y) | ||
self.__equip_item('dirt') | ||
@self.bot.on("physicsTick") | ||
def run(*arg): | ||
if self.bot.get_data("tower") == 1: | ||
if int(self.bot.entity.position.y) == int(old_pos) + 1: | ||
self.bot.bot.waitForTicks(50) | ||
if int(self.bot.entity.position.y) == int(old_pos) + 1: | ||
self.bot.set_data("tower", 0) | ||
self.bot.bot.setControlState("jump", True) | ||
eferenceBlock = self.bot.bot.blockAt(self.bot.bot.entity.position.offset(0, -1, 0)) | ||
placeBlockVar = self.bot.bot._genericPlace(eferenceBlock, self.Vec3(0,1,0), { "swingArm": "right" }) | ||
else: | ||
self.bot.bot.setControlState("jump", False) | ||
|
||
self.bot.set_data("tower", 1) | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
def __build_layer(self): | ||
# Plaziert den Sand | ||
self.__equip_item('sand') | ||
self.bot.bot.placeBlock(self.bot.bot.blockAt(self.bot.entity.position.offset(2, -1, 0)), self.Vec3(0, 1, 0)) | ||
|
||
self.bot.bot.placeBlock(self.bot.bot.blockAt(self.bot.entity.position.offset(2, -1, 2)), self.Vec3(0, 1, 0)) | ||
|
||
self.bot.bot.placeBlock(self.bot.bot.blockAt(self.bot.entity.position.offset(0, -1, 2)), self.Vec3(0, 1, 0)) | ||
|
||
self.bot.bot.placeBlock(self.bot.bot.blockAt(self.bot.entity.position.offset(-2, -1, 2)), self.Vec3(0, 1, 0)) | ||
|
||
self.bot.bot.placeBlock(self.bot.bot.blockAt(self.bot.entity.position.offset(-2, -1, 0)), self.Vec3(0, 1, 0)) | ||
|
||
self.bot.bot.placeBlock(self.bot.bot.blockAt(self.bot.entity.position.offset(-2, -1, -2)), self.Vec3(0, 1, 0)) | ||
|
||
self.bot.bot.placeBlock(self.bot.bot.blockAt(self.bot.entity.position.offset(0, -1, -2)), self.Vec3(0, 1, 0)) | ||
|
||
self.bot.bot.placeBlock(self.bot.bot.blockAt(self.bot.entity.position.offset(2, -1, -2)), self.Vec3(0, 1, 0)) | ||
|
||
# Plaziert den Kaktus | ||
self.__equip_item('cactus') | ||
self.bot.bot.placeBlock(self.bot.bot.blockAt(self.bot.entity.position.offset(2, 0, 0)), self.Vec3(0, 1, 0)) | ||
|
||
self.bot.bot.placeBlock(self.bot.bot.blockAt(self.bot.entity.position.offset(2, 0, 2)), self.Vec3(0, 1, 0)) | ||
|
||
self.bot.bot.placeBlock(self.bot.bot.blockAt(self.bot.entity.position.offset(0, 0, 2)), self.Vec3(0, 1, 0)) | ||
|
||
self.bot.bot.placeBlock(self.bot.bot.blockAt(self.bot.entity.position.offset(-2, 0, 2)), self.Vec3(0, 1, 0)) | ||
|
||
self.bot.bot.placeBlock(self.bot.bot.blockAt(self.bot.entity.position.offset(-2, 0, 0)), self.Vec3(0, 1, 0)) | ||
|
||
self.bot.bot.placeBlock(self.bot.bot.blockAt(self.bot.entity.position.offset(-2, 0, -2)), self.Vec3(0, 1, 0)) | ||
|
||
self.bot.bot.placeBlock(self.bot.bot.blockAt(self.bot.entity.position.offset(0, 0, -2)), self.Vec3(0, 1, 0)) | ||
|
||
self.bot.bot.placeBlock(self.bot.bot.blockAt(self.bot.entity.position.offset(2, 0, -2)), self.Vec3(0, 1, 0)) | ||
|
||
|
||
def __build_fence_dirt(self): | ||
self.__equip_item('dirt') | ||
self.bot.bot.placeBlock(self.bot.bot.blockAt(self.bot.entity.position.offset(2, -1, 2)), self.Vec3(0, 1, 0)) | ||
self.__equip_item('iron_bars') | ||
self.bot.bot.placeBlock(self.bot.bot.blockAt(self.bot.entity.position.offset(2, 0, 2)), self.Vec3(0, 0, -1)) | ||
self.__equip_item('dirt') | ||
self.bot.bot.placeBlock(self.bot.bot.blockAt(self.bot.entity.position.offset(0, -1, 2)), self.Vec3(0, 1, 0)) | ||
self.__equip_item('iron_bars') | ||
self.bot.bot.placeBlock(self.bot.bot.blockAt(self.bot.entity.position.offset(0, 0, 2)), self.Vec3(0, 0, -1)) | ||
self.__equip_item('dirt') | ||
self.bot.bot.placeBlock(self.bot.bot.blockAt(self.bot.entity.position.offset(-2, -1, 2)), self.Vec3(0, 1, 0)) | ||
self.__equip_item('iron_bars') | ||
self.bot.bot.placeBlock(self.bot.bot.blockAt(self.bot.entity.position.offset(-2, 0, 2)), self.Vec3(0, 0, -1)) | ||
self.__equip_item('dirt') | ||
self.bot.bot.placeBlock(self.bot.bot.blockAt(self.bot.entity.position.offset(-2, -1, -2)), self.Vec3(0, 1, 0)) | ||
self.__equip_item('iron_bars') | ||
self.bot.bot.placeBlock(self.bot.bot.blockAt(self.bot.entity.position.offset(-2, 0, -2)), self.Vec3(0, 0, 1)) | ||
self.__equip_item('dirt') | ||
self.bot.bot.placeBlock(self.bot.bot.blockAt(self.bot.entity.position.offset(0, -1, -2)), self.Vec3(0, 1, 0)) | ||
self.__equip_item('iron_bars') | ||
self.bot.bot.placeBlock(self.bot.bot.blockAt(self.bot.entity.position.offset(0, 0, -2)), self.Vec3(0, 0, 1)) | ||
self.__equip_item('dirt') | ||
self.bot.bot.placeBlock(self.bot.bot.blockAt(self.bot.entity.position.offset(2, -1, -2)), self.Vec3(0, 1, 0)) | ||
self.__equip_item('iron_bars') | ||
self.bot.bot.placeBlock(self.bot.bot.blockAt(self.bot.entity.position.offset(2, 0, -2)), self.Vec3(0, 0, 1)) | ||
self.__equip_item('dirt') | ||
self.bot.bot.placeBlock(self.bot.bot.blockAt(self.bot.entity.position.offset(2, -1, 0)), self.Vec3(0, 1, 0)) | ||
self.bot.bot.placeBlock(self.bot.bot.blockAt(self.bot.entity.position.offset(-2, -1, 0)), self.Vec3(0, 1, 0)) | ||
|
||
|
||
def __place_dirt_layer(self): | ||
self.__equip_item('dirt') | ||
self.bot.bot.placeBlock(self.bot.bot.blockAt(self.bot.entity.position.offset(2, -1, 0)), self.Vec3(0, 1, 0)) | ||
self.bot.bot.placeBlock(self.bot.bot.blockAt(self.bot.entity.position.offset(2, -1, 2)), self.Vec3(0, 1, 0)) | ||
self.bot.bot.placeBlock(self.bot.bot.blockAt(self.bot.entity.position.offset(0, -1, 2)), self.Vec3(0, 1, 0)) | ||
self.bot.bot.placeBlock(self.bot.bot.blockAt(self.bot.entity.position.offset(-2, -1, 2)), self.Vec3(0, 1, 0)) | ||
self.bot.bot.placeBlock(self.bot.bot.blockAt(self.bot.entity.position.offset(-2, -1, 0)), self.Vec3(0, 1, 0)) | ||
self.bot.bot.placeBlock(self.bot.bot.blockAt(self.bot.entity.position.offset(-2, -1, -2)), self.Vec3(0, 1, 0)) | ||
self.bot.bot.placeBlock(self.bot.bot.blockAt(self.bot.entity.position.offset(0, -1, -2)), self.Vec3(0, 1, 0)) | ||
self.bot.bot.placeBlock(self.bot.bot.blockAt(self.bot.entity.position.offset(2, -1, -2)), self.Vec3(0, 1, 0)) | ||
# break | ||
|
||
def __place_last_cactus(self): | ||
self.bot.bot.dig(self.bot.bot.blockAt(self.bot.entity.position.offset(0, -2, 0)), True) | ||
self.bot.bot.dig(self.bot.bot.blockAt(self.bot.entity.position.offset(0, -3, 0)), True) | ||
self.bot.bot.dig(self.bot.bot.blockAt(self.bot.entity.position.offset(0, -4, 0)), True) | ||
self.bot.bot.waitForTicks(50) | ||
self.__equip_item('sand') | ||
|
||
self.bot.bot.placeBlock(self.bot.bot.blockAt(self.bot.entity.position.offset(0, -5, 0)), self.Vec3(0, 1, 0)) | ||
self.__equip_item('cactus') | ||
self.bot.bot.waitForTicks(50) | ||
self.bot.bot.placeBlock(self.bot.bot.blockAt(self.bot.entity.position.offset(0, -4, 0)), self.Vec3(0, 1, 0)) | ||
|
||
def __cactus(self, layers): | ||
with Progress(console=self.console) as progress: | ||
task = progress.add_task(description="Building cactus farm...", total=8 * layers) | ||
for layer in range(0, layers): | ||
self.__build_layer() | ||
progress.update(task, advance=1) | ||
self.bot.bot.waitForTicks(50) | ||
self.__build_up() | ||
progress.update(task, advance=1) | ||
self.bot.bot.waitForTicks(50) | ||
self.__build_up() | ||
progress.update(task, advance=1) | ||
self.bot.bot.waitForTicks(50) | ||
self.__build_fence_dirt() | ||
progress.update(task, advance=1) | ||
self.bot.bot.waitForTicks(50) | ||
self.__build_up() | ||
progress.update(task, advance=1) | ||
self.bot.bot.waitForTicks(50) | ||
self.__place_dirt_layer() | ||
progress.update(task, advance=1) | ||
self.bot.bot.waitForTicks(50) | ||
self.__build_up() | ||
progress.update(task, advance=1) | ||
self.bot.bot.waitForTicks(50) | ||
self.__dig_layer() | ||
progress.update(task, advance=1) | ||
self.bot.bot.waitForTicks(50) | ||
self.__place_last_cactus() | ||
self.bot.bot.waitForTicks(50) | ||
progress.update(task, advance=1) | ||
|
||
progress.stop_task(task) | ||
progress.stop() | ||
|
||
|
||
def start(self,layers): | ||
lodestone.logger.info(f"Building cactus farm...\n{layers * 9}x sand\n{layers * 9}x cactus\n{layers * 9}x dirt\n{layers * 6}x iron bars") | ||
self.__cactus(layers) | ||
lodestone.logger.info("Done building cactus farm") | ||
# _thread = threading.Thread(target=self.__cactus, args=[layers]) | ||
# _thread.start() |
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,53 @@ | ||
import lodestone | ||
try: | ||
from discord import Embed | ||
except: | ||
pass | ||
import datetime | ||
try: | ||
from discord import SyncWebhook | ||
except: | ||
pass | ||
import ast | ||
import inspect | ||
|
||
class discord: | ||
""" | ||
Build in Discord plugin | ||
""" | ||
def __init__(self, bot: lodestone.Bot): | ||
"The injection method" | ||
self.bot = bot | ||
self.main() # run the main code to add the event | ||
self.code = inspect.getsource(inspect.getmodule(self.__class__)) | ||
self.tree = ast.parse(self.code) | ||
self.events = [] | ||
for node in ast.walk(self.tree): | ||
if isinstance(node, ast.Call) and hasattr(node.func, 'attr') and node.func.attr == 'on': | ||
event = node.args[0].s | ||
self.events.append(event) | ||
events_loaded = list(bot.loaded_events.keys()) | ||
events_loaded.append(self.events) # add the event to the list | ||
bot.emit('event_loaded', *events_loaded) | ||
plugins_loaded = list(bot.loaded_plugins.keys()) | ||
plugins_loaded.append(self.__class__.__name__) # add the plugin to the list | ||
bot.emit('plugin_loaded', *plugins_loaded) | ||
|
||
|
||
def main(self): | ||
@self.bot.on('discord_webhook') # this part of the code is ran when bot.emit('discord_webhook') is called | ||
def discord_webhook(bot, message:str, webhook:str, use_discord_forums:bool=False): | ||
hook = SyncWebhook.from_url(url=webhook) # connect to the webhook | ||
use_discord_forums:bool=False | ||
color=0x3498db | ||
embed = Embed(title="", description=f"**{message}**", color=color) # make the embed | ||
embed.timestamp = datetime.datetime.utcnow() | ||
try: | ||
embed.set_footer(text=f'{self.bot.username}', icon_url=f"https://mc-heads.net/avatar/{self.bot.username}/600.png") # set the footer image to the players head | ||
except: | ||
embed.set_footer(text='\u200b', icon_url="https://github.com/Project-Lodestone/Lodestone/blob/main/chestlogo.png?raw=True") # fallback footer image | ||
if use_discord_forums: | ||
today = datetime.date.today() # get the current date | ||
hook.send(content=f"{today}", thread_name=f"{today}", username="Lodestone", avatar_url="https://github.com/Project-Lodestone/Lodestone/blob/main/chestlogo.png?raw=True", embed=embed) # send the message in a forums channel | ||
else: | ||
hook.send(content=f" ", username="Lodestone", avatar_url="https://github.com/Project-Lodestone/Lodestone/blob/main/chestlogo.png?raw=True", embed=embed) # send the message in a normal channel |
Oops, something went wrong.