Rename data module to mcdata
This commit is contained in:
parent
b754a4746d
commit
6c0688b759
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -102,4 +102,4 @@ ENV/
|
|||
*.swp
|
||||
*.swo
|
||||
|
||||
mcdata/
|
||||
minecraft_data/
|
||||
|
|
20
blocks.py
20
blocks.py
|
@ -1,14 +1,14 @@
|
|||
import json
|
||||
import importlib
|
||||
|
||||
import data
|
||||
importlib.reload(data)
|
||||
import mcdata
|
||||
importlib.reload(mcdata)
|
||||
|
||||
MCD_BLOCKS = {}
|
||||
for d in data.mcd.blocks.values():
|
||||
for d in mcdata.mcd.blocks.values():
|
||||
MCD_BLOCKS[d['name']] = d
|
||||
|
||||
with open('mcdata/blocks.json') as f:
|
||||
with open('minecraft_data/blocks.json') as f:
|
||||
JSON_BLOCKS = json.load(f)
|
||||
|
||||
BLOCKS = {}
|
||||
|
@ -237,14 +237,6 @@ SAPLINGS = [
|
|||
'dark_oak_sapling',
|
||||
]
|
||||
|
||||
CHESTS = [
|
||||
'chest',
|
||||
]
|
||||
|
||||
TRAPPED_CHESTS = [
|
||||
'trapped_chest',
|
||||
]
|
||||
|
||||
INDEXED = [
|
||||
'chest',
|
||||
'trapped_chest',
|
||||
|
@ -278,12 +270,12 @@ for block_name in LEAVES:
|
|||
LEAF_IDS.add(state['id'])
|
||||
|
||||
CHEST_IDS = set()
|
||||
for block_name in CHESTS:
|
||||
for block_name in ['chest']:
|
||||
for state in JSON_BLOCKS['minecraft:' + block_name]['states']:
|
||||
CHEST_IDS.add(state['id'])
|
||||
|
||||
TRAPPED_CHEST_IDS = set()
|
||||
for block_name in TRAPPED_CHESTS:
|
||||
for block_name in ['trapped_chest']:
|
||||
for state in JSON_BLOCKS['minecraft:' + block_name]['states']:
|
||||
TRAPPED_CHEST_IDS.add(state['id'])
|
||||
|
||||
|
|
11
bot.py
11
bot.py
|
@ -36,6 +36,8 @@ import path
|
|||
importlib.reload(path)
|
||||
import jobs
|
||||
importlib.reload(jobs)
|
||||
import mcdata
|
||||
importlib.reload(mcdata)
|
||||
|
||||
last_tick = time.time()
|
||||
|
||||
|
@ -211,7 +213,7 @@ def bot(global_state):
|
|||
g = global_state
|
||||
|
||||
if not g.mcdata:
|
||||
g.mcdata = DataManager('./mcdata')
|
||||
g.mcdata = DataManager('./minecraft_data')
|
||||
|
||||
if not g.connection:
|
||||
auth_token = authentication.AuthenticationToken()
|
||||
|
@ -262,3 +264,10 @@ def bot(global_state):
|
|||
g.connection.early_outgoing_packet_listeners = []
|
||||
|
||||
print('Bot module loaded.')
|
||||
|
||||
print(mcdata.mcd.blockCollisionShapes['blocks']['brewing_stand'])
|
||||
print(mcdata.mcd.blockCollisionShapes['shapes']['107'])
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
#!/bin/sh
|
||||
|
||||
VERSION="1.16.2"
|
||||
VERSION="1.16.4"
|
||||
|
||||
wget -O/tmp/mcdata.zip https://apimon.de/mcdata/$VERSION/$VERSION.zip
|
||||
rm -rf mcdata
|
||||
mkdir mcdata
|
||||
unzip /tmp/mcdata.zip -d mcdata
|
||||
rm -rf minecraft_data
|
||||
mkdir minecraft_data
|
||||
unzip /tmp/mcdata.zip -d minecraft_data
|
||||
rm /tmp/mcdata.zip
|
||||
|
||||
|
|
27
game.py
27
game.py
|
@ -33,8 +33,8 @@ import blocks
|
|||
importlib.reload(blocks)
|
||||
import items
|
||||
importlib.reload(items)
|
||||
import data
|
||||
importlib.reload(data)
|
||||
import mcdata
|
||||
importlib.reload(mcdata)
|
||||
import mobs
|
||||
importlib.reload(mobs)
|
||||
|
||||
|
@ -588,6 +588,23 @@ class Game:
|
|||
tree = next(self.g.world.find_trees(pos, 50))
|
||||
reply = str(tree)[1:-1]
|
||||
|
||||
if command == 'block':
|
||||
try:
|
||||
data = data.replace('(', ' ').replace(')', ' ').replace(',', ' ')
|
||||
x1, y1, z1 = [int(x) for x in data.split()]
|
||||
except (AttributeError, ValueError):
|
||||
reply = 'usage: !block x1 y1 z1'
|
||||
|
||||
if not reply:
|
||||
coord = (x1, y1, z1)
|
||||
block = self.g.world.block_at(*coord)
|
||||
|
||||
if not reply and block is None:
|
||||
reply = 'first coord out of range'
|
||||
|
||||
if not reply:
|
||||
reply = blocks.BLOCKS[block] + ':' + str(block)
|
||||
|
||||
|
||||
################# Specific commands ##########################
|
||||
if for_me:
|
||||
|
@ -993,7 +1010,7 @@ class Game:
|
|||
player.y += packet.delta_y / 4096.0
|
||||
player.z += packet.delta_z / 4096.0
|
||||
|
||||
if player.player_uuid == '0c123cfa-1697-4427-9413-4b645dee7ec0': print(packet)
|
||||
#if player.player_uuid == '0c123cfa-1697-4427-9413-4b645dee7ec0': print(packet)
|
||||
|
||||
def handle_entity_position_rotation(self, packet):
|
||||
mob = self.g.mobs.get(packet.entity_id, None)
|
||||
|
@ -1008,7 +1025,7 @@ class Game:
|
|||
player.y += packet.delta_y / 4096.0
|
||||
player.z += packet.delta_z / 4096.0
|
||||
|
||||
if player.player_uuid == '0c123cfa-1697-4427-9413-4b645dee7ec0': print(packet)
|
||||
#if player.player_uuid == '0c123cfa-1697-4427-9413-4b645dee7ec0': print(packet)
|
||||
|
||||
def handle_entity_teleport(self, packet):
|
||||
mob = self.g.mobs.get(packet.entity_id, None)
|
||||
|
@ -1023,7 +1040,7 @@ class Game:
|
|||
player.y = packet.y
|
||||
player.z = packet.z
|
||||
|
||||
if player.player_uuid == '0c123cfa-1697-4427-9413-4b645dee7ec0': print(packet)
|
||||
#if player.player_uuid == '0c123cfa-1697-4427-9413-4b645dee7ec0': print(packet)
|
||||
|
||||
def handle_entity_velocity(self, packet):
|
||||
obj = self.g.objects.get(packet.entity_id, None)
|
||||
|
|
2
items.py
2
items.py
|
@ -1,6 +1,6 @@
|
|||
import json
|
||||
|
||||
with open('mcdata/registries.json') as f:
|
||||
with open('minecraft_data/registries.json') as f:
|
||||
ITEMS = json.load(f)['minecraft:item']['entries']
|
||||
|
||||
BEDS = [
|
||||
|
|
6
jobs.py
6
jobs.py
|
@ -19,8 +19,8 @@ import blocks
|
|||
importlib.reload(blocks)
|
||||
import items
|
||||
importlib.reload(items)
|
||||
import data
|
||||
importlib.reload(data)
|
||||
import mcdata
|
||||
importlib.reload(mcdata)
|
||||
import mobs
|
||||
importlib.reload(mobs)
|
||||
|
||||
|
@ -722,7 +722,7 @@ class CacheItemsStates:
|
|||
if self.g.item_lock: return
|
||||
|
||||
w = self.g.window
|
||||
w_info = data.WINDOWS[w.data.window_type]
|
||||
w_info = mcdata.WINDOWS[w.data.window_type]
|
||||
w_inventory_slots = w_info.inventory
|
||||
|
||||
slot_list = []
|
||||
|
|
|
@ -5,7 +5,7 @@ import minecraft_data
|
|||
|
||||
mcd = minecraft_data('1.16.4')
|
||||
|
||||
with open('mcdata/registries.json') as f:
|
||||
with open('minecraft_data/registries.json') as f:
|
||||
DATA = json.load(f)
|
||||
|
||||
SINGLE_CHEST = 2
|
2
mobs.py
2
mobs.py
|
@ -1,6 +1,6 @@
|
|||
import json
|
||||
|
||||
with open('mcdata/registries.json') as f:
|
||||
with open('minecraft_data/registries.json') as f:
|
||||
MOBS = json.load(f)['minecraft:entity_type']['entries']
|
||||
|
||||
EVIL = [
|
||||
|
|
5
utils.py
5
utils.py
|
@ -4,7 +4,8 @@ from math import floor, ceil, sqrt, hypot
|
|||
|
||||
import blocks
|
||||
importlib.reload(blocks)
|
||||
import data
|
||||
import mcdata
|
||||
importlib.reload(mcdata)
|
||||
|
||||
TICK = 0.05
|
||||
|
||||
|
@ -86,7 +87,7 @@ def break_time(block_id, held_item=0, in_water=False, on_ground=True, enchantmen
|
|||
|
||||
can_harvest = 'harvestTools' not in block_data or str(held_item) in block_data['harvestTools']
|
||||
material = block_data.get('material', 'n/a')
|
||||
tool_multipliers = data.mcd.materials.get(material, [])
|
||||
tool_multipliers = mcdata.mcd.materials.get(material, [])
|
||||
is_best_tool = held_item in tool_multipliers
|
||||
time = block_data['hardness']
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user