Begin port to 26.3: movement

This commit is contained in:
Tanner
2026-11-03 22:48:15 +00:00
parent 891f14b988
commit 59c76471f2
23 changed files with 30692 additions and 478 deletions
+84 -273
View File
@@ -1,280 +1,84 @@
import json
import importlib
"""Minecraft 26.3 block-state metadata and legacy automation selectors."""
from itertools import product
from mosfet.info import mcdata
MCD_BLOCKS = {}
for d in mcdata.mcd.blocks.values():
MCD_BLOCKS[d['name']] = d
with open('minecraft_data/blocks.json') as f:
JSON_BLOCKS = json.load(f)
MCD_BLOCKS = mcdata.mcd.blocks
JSON_BLOCKS = {'minecraft:' + name: data
for name, data in MCD_BLOCKS.items()}
BLOCKS = {}
for name, data in JSON_BLOCKS.items():
for state in data['states']:
BLOCKS[state['id']] = name.replace('minecraft:', '')
PROPS = {}
for name, data in JSON_BLOCKS.items():
for state in data['states']:
PROPS[state['id']] = state.get('properties', {})
COLLISION_BOXES = {}
for name, data in MCD_BLOCKS.items():
first = data['minStateId']
last = data['maxStateId']
properties = data.get('states', [])
property_values = [prop.get('values', []) for prop in properties]
combinations = list(product(*property_values)) if property_values else [()]
for offset, state_id in enumerate(range(first, last + 1)):
BLOCKS[state_id] = name
if offset < len(combinations):
PROPS[state_id] = {
prop['name']: value
for prop, value in zip(properties, combinations[offset])
}
else:
PROPS[state_id] = {}
shape_ref = mcdata.mcd.collision_shapes['blocks'].get(name, 1)
refs = shape_ref if isinstance(shape_ref, list) else [shape_ref] * (last-first+1)
for offset, state_id in enumerate(range(first, last + 1)):
ref = refs[offset] if offset < len(refs) else refs[-1]
COLLISION_BOXES[state_id] = mcdata.mcd.collision_shapes['shapes'].get(
str(ref), [])
BREAK_DISTANCE = 6
AIR = 0
STONE = 1
SAND = 66
SINGLE_SNOW = 3921
SOUL_TORCH = 4008
EMERALD_BLOCK = 5407
AIR = MCD_BLOCKS['air']['minStateId']
STONE = MCD_BLOCKS['stone']['minStateId']
SAND = MCD_BLOCKS['sand']['minStateId']
SOUL_TORCH = MCD_BLOCKS['soul_torch']['minStateId']
EMERALD_BLOCK = MCD_BLOCKS['emerald_block']['minStateId']
SINGLE_SNOW = MCD_BLOCKS.get('snow', MCD_BLOCKS.get('snow_layer', {})).get(
'minStateId', AIR)
TEST_BLOCK = (616, 78, 496)
AVOID = [
'lava',
'water',
'fire',
'magma_block',
'oak_fence',
'oak_fence_gate',
'nether_brick_fence',
'spruce_fence_gate',
'birch_fence_gate',
'jungle_fence_gate',
'acacia_fence_gate',
'dark_oak_fence_gate',
'spruce_fence',
'birch_fence',
'jungle_fence',
'acacia_fence',
'dark_oak_fence',
'sweet_berry_bush',
'nether_portal',
'end_portal',
'cobblestone_wall',
'mossy_cobblestone_wall',
'brick_wall',
'prismarine_wall',
'red_sandstone_wall',
'mossy_stone_brick_wall',
'granite_wall',
'stone_brick_wall',
'nether_brick_wall',
'andesite_wall',
'red_nether_brick_wall',
'sandstone_wall',
'end_stone_brick_wall',
'diorite_wall',
'oak_sapling', # saplings can grow up and hurt
'spruce_sapling',
'birch_sapling',
'jungle_sapling',
'acacia_sapling',
'dark_oak_sapling',
]
NON_SOLID = [
'air',
'powered_rail',
'detector_rail',
'grass',
'fern',
'dead_bush',
'seagrass',
'tall_seagrass',
'dandelion',
'poppy',
'blue_orchid',
'allium',
'azure_bluet',
'red_tulip',
'orange_tulip',
'white_tulip',
'pink_tulip',
'oxeye_daisy',
'cornflower',
'wither_rose',
'lily_of_the_valley',
'brown_mushroom',
'red_mushroom',
'torch',
'wall_torch',
'redstone_wire',
'wheat',
'oak_sign',
'spruce_sign',
'birch_sign',
'acacia_sign',
'jungle_sign',
'dark_oak_sign',
'rail',
'oak_wall_sign',
'spruce_wall_sign',
'birch_wall_sign',
'acacia_wall_sign',
'jungle_wall_sign',
'dark_oak_wall_sign',
'lever',
'stone_pressure_plate',
'oak_pressure_plate',
'spruce_pressure_plate',
'birch_pressure_plate',
'jungle_pressure_plate',
'acacia_pressure_plate',
'dark_oak_pressure_plate',
'redstone_torch',
'redstone_wall_torch',
'stone_button',
'sugar_cane',
'repeater',
'attached_pumpkin_stem',
'attached_melon_stem',
'pumpkin_stem',
'melon_stem',
'nether_wart',
'tripwire_hook',
'tripwire',
'carrots',
'potatoes',
'oak_button',
'spruce_button',
'birch_button',
'jungle_button',
'acacia_button',
'dark_oak_button',
'light_weighted_pressure_plate',
'heavy_weighted_pressure_plate',
'comparator',
'activator_rail',
'white_carpet',
'orange_carpet',
'magenta_carpet',
'light_blue_carpet',
'yellow_carpet',
'lime_carpet',
'pink_carpet',
'gray_carpet',
'light_gray_carpet',
'cyan_carpet',
'purple_carpet',
'blue_carpet',
'brown_carpet',
'green_carpet',
'red_carpet',
'black_carpet',
'sunflower',
'lilac',
'rose_bush',
'peony',
'tall_grass',
'large_fern',
'white_banner',
'orange_banner',
'magenta_banner',
'light_blue_banner',
'yellow_banner',
'lime_banner',
'pink_banner',
'gray_banner',
'light_gray_banner',
'cyan_banner',
'purple_banner',
'blue_banner',
'brown_banner',
'green_banner',
'red_banner',
'black_banner',
'white_wall_banner',
'orange_wall_banner',
'magenta_wall_banner',
'light_blue_wall_banner',
'yellow_wall_banner',
'lime_wall_banner',
'pink_wall_banner',
'gray_wall_banner',
'light_gray_wall_banner',
'cyan_wall_banner',
'purple_wall_banner',
'blue_wall_banner',
'brown_wall_banner',
'green_wall_banner',
'red_wall_banner',
'black_wall_banner',
'beetroots',
'bamboo_sapling',
'void_air',
'cave_air',
'lantern',
'soul_torch',
]
LOGS = [
'oak_log',
'spruce_log',
'birch_log',
'jungle_log',
'acacia_log',
'dark_oak_log',
]
LEAVES = [
'oak_leaves',
'spruce_leaves',
'birch_leaves',
'jungle_leaves',
'acacia_leaves',
'dark_oak_leaves',
]
SAPLINGS = [
'oak_sapling',
'spruce_sapling',
'birch_sapling',
'jungle_sapling',
'acacia_sapling',
'dark_oak_sapling',
]
BEDS = [
'white_bed',
'orange_bed',
'magenta_bed',
'light_blue_bed',
'yellow_bed',
'lime_bed',
'pink_bed',
'gray_bed',
'light_gray_bed',
'cyan_bed',
'purple_bed',
'blue_bed',
'brown_bed',
'green_bed',
'red_bed',
'black_bed',
]
INDEXED = [
'chest',
'trapped_chest',
'emerald_block',
'barrel',
] + BEDS
def get_set(ids):
def get_set(names):
"""Return every state ID belonging to the named blocks; ignore removed names."""
result = set()
for block_name in ids:
for state in JSON_BLOCKS['minecraft:' + block_name]['states']:
result.add(state['id'])
for name in names:
name = name.removeprefix('minecraft:')
data = MCD_BLOCKS.get(name)
if data is not None:
result.update(range(data['minStateId'], data['maxStateId'] + 1))
return result
NON_SOLID_IDS = get_set(NON_SOLID)
NON_SOLID_IDS.add(SINGLE_SNOW)
# Collision geometry is safer for navigation than the old hard-coded 1.16 list.
NON_SOLID_IDS = {
state_id for state_id, boxes in COLLISION_BOXES.items() if not boxes
}
AVOID = {
'lava', 'water', 'fire', 'magma_block', 'sweet_berry_bush',
'nether_portal', 'end_portal', 'cactus', 'powder_snow',
}
AVOID_IDS = get_set(AVOID)
AVOID_IDS.update(
state_id for state_id, name in BLOCKS.items()
if name.endswith(('_fence', '_fence_gate', '_wall'))
)
WATER_IDS = get_set(['water'])
LOGS = sorted(name for name in MCD_BLOCKS
if name.endswith(('_log', '_wood', '_stem', '_hyphae')))
LEAVES = sorted(name for name in MCD_BLOCKS if name.endswith('_leaves'))
SAPLINGS = sorted(name for name in MCD_BLOCKS
if name.endswith('_sapling') or name.endswith('_propagule'))
BEDS = sorted(name for name in MCD_BLOCKS if name.endswith('_bed'))
INDEXED = ['chest', 'trapped_chest', 'emerald_block', 'barrel'] + BEDS
LOG_IDS = get_set(LOGS)
LEAF_IDS = get_set(LEAVES)
CHEST_IDS = get_set(['chest'])
@@ -287,21 +91,28 @@ CARROT_IDS = get_set(['carrots'])
BEETROOT_IDS = get_set(['beetroots'])
SAPLING_IDS = get_set(SAPLINGS)
BED_IDS = get_set(BEDS)
INDEXED_IDS = set()
for block_name in INDEXED:
for state in JSON_BLOCKS['minecraft:' + block_name]['states']:
INDEXED_IDS.add(state['id'])
INDEXED_IDS = get_set(INDEXED)
MATURE_WHEAT_ID = max(WHEAT_IDS)
MATURE_POTATO_ID = max(POTATO_IDS)
MATURE_CARROT_ID = max(CARROT_IDS)
MATURE_BEETROOT_ID = max(BEETROOT_IDS)
def _mature_state(name, property_name, mature_value):
data = MCD_BLOCKS.get(name)
if data is None:
return None
for state_id in range(data['minStateId'], data['maxStateId'] + 1):
if PROPS[state_id].get(property_name) == str(mature_value):
return state_id
return data['maxStateId']
MATURE_WHEAT_ID = _mature_state('wheat', 'age', 7)
MATURE_POTATO_ID = _mature_state('potatoes', 'age', 7)
MATURE_CARROT_ID = _mature_state('carrots', 'age', 7)
MATURE_BEETROOT_ID = _mature_state('beetroots', 'age', 3)
def get(block_state_id):
return MCD_BLOCKS[BLOCKS[block_state_id]]
def get(bid):
name = BLOCKS[bid]
return MCD_BLOCKS[name]
def find(name):
return MCD_BLOCKS[name]
return MCD_BLOCKS[name.removeprefix('minecraft:')]
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2022 grepsedawk <grepsedawk@users.noreply.github.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+7
View File
@@ -0,0 +1,7 @@
Minecraft 26.3 data files
Source: RosegoldMC/minecraft-data.cr, data/26.3
https://github.com/RosegoldMC/minecraft-data.cr/tree/main/data/26.3
The JSON files in this directory are redistributed under the MIT License;
see LICENSE. They are generated data, not Mojang source code.
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+45
View File
@@ -0,0 +1,45 @@
[
{"id":0,"name":"aqua_affinity"},
{"id":1,"name":"bane_of_arthropods"},
{"id":2,"name":"binding_curse"},
{"id":3,"name":"blast_protection"},
{"id":4,"name":"breach"},
{"id":5,"name":"channeling"},
{"id":6,"name":"density"},
{"id":7,"name":"depth_strider"},
{"id":8,"name":"efficiency"},
{"id":9,"name":"feather_falling"},
{"id":10,"name":"fire_aspect"},
{"id":11,"name":"fire_protection"},
{"id":12,"name":"flame"},
{"id":13,"name":"fortune"},
{"id":14,"name":"frost_walker"},
{"id":15,"name":"impaling"},
{"id":16,"name":"infinity"},
{"id":17,"name":"knockback"},
{"id":18,"name":"looting"},
{"id":19,"name":"loyalty"},
{"id":20,"name":"luck_of_the_sea"},
{"id":21,"name":"lunge"},
{"id":22,"name":"lure"},
{"id":23,"name":"mending"},
{"id":24,"name":"multishot"},
{"id":25,"name":"piercing"},
{"id":26,"name":"power"},
{"id":27,"name":"projectile_protection"},
{"id":28,"name":"protection"},
{"id":29,"name":"punch"},
{"id":30,"name":"quick_charge"},
{"id":31,"name":"respiration"},
{"id":32,"name":"riptide"},
{"id":33,"name":"sharpness"},
{"id":34,"name":"silk_touch"},
{"id":35,"name":"smite"},
{"id":36,"name":"soul_speed"},
{"id":37,"name":"sweeping_edge"},
{"id":38,"name":"swift_sneak"},
{"id":39,"name":"thorns"},
{"id":40,"name":"unbreaking"},
{"id":41,"name":"vanishing_curse"},
{"id":42,"name":"wind_burst"}
]
+163
View File
@@ -0,0 +1,163 @@
[
{"id":0,"name":"acacia_boat","width":1.375,"height":0.5625},
{"id":1,"name":"acacia_chest_boat","width":1.375,"height":0.5625},
{"id":2,"name":"allay","width":0.35,"height":0.6},
{"id":3,"name":"area_effect_cloud","width":6,"height":0.5},
{"id":4,"name":"armadillo","width":0.7,"height":0.65},
{"id":5,"name":"armor_stand","width":0.5,"height":1.975},
{"id":6,"name":"arrow","width":0.5,"height":0.5},
{"id":7,"name":"axolotl","width":0.75,"height":0.42},
{"id":8,"name":"bamboo_chest_raft","width":1.375,"height":0.5625},
{"id":9,"name":"bamboo_raft","width":1.375,"height":0.5625},
{"id":10,"name":"bat","width":0.5,"height":0.9},
{"id":11,"name":"bee","width":0.7,"height":0.6},
{"id":12,"name":"birch_boat","width":1.375,"height":0.5625},
{"id":13,"name":"birch_chest_boat","width":1.375,"height":0.5625},
{"id":14,"name":"blaze","width":0.6,"height":1.8},
{"id":15,"name":"block_display","width":0,"height":0},
{"id":16,"name":"bogged","width":0.6,"height":1.99},
{"id":17,"name":"breeze","width":0.6,"height":1.77},
{"id":18,"name":"breeze_wind_charge","width":0.3125,"height":0.3125},
{"id":19,"name":"camel","width":1.7,"height":2.375},
{"id":20,"name":"camel_husk","width":1.7,"height":2.375},
{"id":21,"name":"cat","width":0.6,"height":0.7},
{"id":22,"name":"cave_spider","width":0.7,"height":0.5},
{"id":23,"name":"cherry_boat","width":1.375,"height":0.5625},
{"id":24,"name":"cherry_chest_boat","width":1.375,"height":0.5625},
{"id":25,"name":"chest_minecart","width":0.98,"height":0.7},
{"id":26,"name":"chicken","width":0.4,"height":0.7},
{"id":27,"name":"cod","width":0.5,"height":0.3},
{"id":28,"name":"copper_golem","width":0.49,"height":0.98},
{"id":29,"name":"command_block_minecart","width":0.98,"height":0.7},
{"id":30,"name":"cow","width":0.9,"height":1.4},
{"id":31,"name":"creaking","width":0.9,"height":2.7},
{"id":32,"name":"creeper","width":0.6,"height":1.7},
{"id":33,"name":"cushion","width":1.0,"height":0.25,"type":"other","category":"Other"},
{"id":34,"name":"dark_oak_boat","width":1.375,"height":0.5625},
{"id":35,"name":"dark_oak_chest_boat","width":1.375,"height":0.5625},
{"id":36,"name":"dolphin","width":0.9,"height":0.6},
{"id":37,"name":"donkey","width":1.3964844,"height":1.5},
{"id":38,"name":"dragon_fireball","width":1,"height":1},
{"id":39,"name":"drowned","width":0.6,"height":1.95},
{"id":40,"name":"egg","width":0.25,"height":0.25},
{"id":41,"name":"elder_guardian","width":1.9975,"height":1.9975},
{"id":42,"name":"enderman","width":0.6,"height":2.9},
{"id":43,"name":"endermite","width":0.4,"height":0.3},
{"id":44,"name":"ender_dragon","width":16,"height":8},
{"id":45,"name":"ender_pearl","width":0.25,"height":0.25},
{"id":46,"name":"end_crystal","width":2,"height":2},
{"id":47,"name":"evoker","width":0.6,"height":1.95},
{"id":48,"name":"evoker_fangs","width":0.5,"height":0.8},
{"id":49,"name":"experience_bottle","width":0.25,"height":0.25},
{"id":50,"name":"experience_orb","width":0.5,"height":0.5},
{"id":51,"name":"eye_of_ender","width":0.25,"height":0.25},
{"id":52,"name":"falling_block","width":0.98,"height":0.98},
{"id":53,"name":"fireball","width":1,"height":1},
{"id":54,"name":"firework_rocket","width":0.25,"height":0.25},
{"id":55,"name":"fox","width":0.6,"height":0.7},
{"id":56,"name":"frog","width":0.5,"height":0.5},
{"id":57,"name":"furnace_minecart","width":0.98,"height":0.7},
{"id":58,"name":"ghast","width":4,"height":4},
{"id":59,"name":"happy_ghast","width":4,"height":4},
{"id":60,"name":"giant","width":3.6,"height":12},
{"id":61,"name":"glow_item_frame","width":0.5,"height":0.5},
{"id":62,"name":"glow_squid","width":0.8,"height":0.8},
{"id":63,"name":"goat","width":0.9,"height":1.3},
{"id":64,"name":"guardian","width":0.85,"height":0.85},
{"id":65,"name":"hoglin","width":1.3964844,"height":1.4},
{"id":66,"name":"hopper_minecart","width":0.98,"height":0.7},
{"id":67,"name":"horse","width":1.3964844,"height":1.6},
{"id":68,"name":"husk","width":0.6,"height":1.95},
{"id":69,"name":"illusioner","width":0.6,"height":1.95},
{"id":70,"name":"interaction","width":0,"height":0},
{"id":71,"name":"iron_golem","width":1.4,"height":2.7},
{"id":72,"name":"item","width":0.25,"height":0.25},
{"id":73,"name":"item_display","width":0,"height":0},
{"id":74,"name":"item_frame","width":0.5,"height":0.5},
{"id":75,"name":"jungle_boat","width":1.375,"height":0.5625},
{"id":76,"name":"jungle_chest_boat","width":1.375,"height":0.5625},
{"id":77,"name":"leash_knot","width":0.375,"height":0.5},
{"id":78,"name":"lightning_bolt","width":0,"height":0},
{"id":79,"name":"llama","width":0.9,"height":1.87},
{"id":80,"name":"llama_spit","width":0.25,"height":0.25},
{"id":81,"name":"magma_cube","width":0.52,"height":0.52},
{"id":82,"name":"mangrove_boat","width":1.375,"height":0.5625},
{"id":83,"name":"mangrove_chest_boat","width":1.375,"height":0.5625},
{"id":84,"name":"mannequin","width":0.6,"height":1.8},
{"id":85,"name":"marker","width":0,"height":0},
{"id":86,"name":"minecart","width":0.98,"height":0.7},
{"id":87,"name":"mooshroom","width":0.9,"height":1.4},
{"id":88,"name":"mule","width":1.3964844,"height":1.6},
{"id":89,"name":"nautilus","width":0.875,"height":0.95},
{"id":90,"name":"oak_boat","width":1.375,"height":0.5625},
{"id":91,"name":"oak_chest_boat","width":1.375,"height":0.5625},
{"id":92,"name":"ocelot","width":0.6,"height":0.7},
{"id":93,"name":"ominous_item_spawner","width":0.25,"height":0.25},
{"id":94,"name":"painting","width":0.5,"height":0.5},
{"id":95,"name":"pale_oak_boat","width":1.375,"height":0.5625},
{"id":96,"name":"pale_oak_chest_boat","width":1.375,"height":0.5625},
{"id":97,"name":"panda","width":1.3,"height":1.25},
{"id":98,"name":"parched","width":0.6,"height":1.99},
{"id":99,"name":"parrot","width":0.5,"height":0.9},
{"id":100,"name":"phantom","width":0.9,"height":0.5},
{"id":101,"name":"pig","width":0.9,"height":0.9},
{"id":102,"name":"piglin","width":0.6,"height":1.95},
{"id":103,"name":"piglin_brute","width":0.6,"height":1.95},
{"id":104,"name":"pillager","width":0.6,"height":1.95},
{"id":105,"name":"polar_bear","width":1.4,"height":1.4},
{"id":106,"name":"poplar_boat","width":1.375,"height":0.5625,"type":"other","category":"Vehicles"},
{"id":107,"name":"poplar_chest_boat","width":1.375,"height":0.5625,"type":"other","category":"Vehicles"},
{"id":108,"name":"splash_potion","width":0.25,"height":0.25},
{"id":109,"name":"lingering_potion","width":0.25,"height":0.25},
{"id":110,"name":"pufferfish","width":0.7,"height":0.7},
{"id":111,"name":"rabbit","width":0.4,"height":0.5},
{"id":112,"name":"ravager","width":1.95,"height":2.2},
{"id":113,"name":"salmon","width":0.7,"height":0.4},
{"id":114,"name":"sheep","width":0.9,"height":1.3},
{"id":115,"name":"shulker","width":1,"height":1},
{"id":116,"name":"shulker_bullet","width":0.3125,"height":0.3125},
{"id":117,"name":"silverfish","width":0.4,"height":0.3},
{"id":118,"name":"skeleton","width":0.6,"height":1.99},
{"id":119,"name":"skeleton_horse","width":1.3964844,"height":1.6},
{"id":120,"name":"slime","width":0.52,"height":0.52},
{"id":121,"name":"small_fireball","width":0.3125,"height":0.3125},
{"id":122,"name":"sniffer","width":1.9,"height":1.75},
{"id":123,"name":"snowball","width":0.25,"height":0.25},
{"id":124,"name":"snow_golem","width":0.7,"height":1.9},
{"id":125,"name":"spawner_minecart","width":0.98,"height":0.7},
{"id":126,"name":"spectral_arrow","width":0.5,"height":0.5},
{"id":127,"name":"spider","width":1.4,"height":0.9},
{"id":128,"name":"spruce_boat","width":1.375,"height":0.5625},
{"id":129,"name":"spruce_chest_boat","width":1.375,"height":0.5625},
{"id":130,"name":"squid","width":0.8,"height":0.8},
{"id":131,"name":"stray","width":0.6,"height":1.99},
{"id":132,"name":"strider","width":0.9,"height":1.7},
{"id":133,"name":"sulfur_cube","width":0.49,"height":0.49},
{"id":134,"name":"tadpole","width":0.4,"height":0.3},
{"id":135,"name":"text_display","width":0,"height":0},
{"id":136,"name":"tnt","width":0.98,"height":0.98},
{"id":137,"name":"tnt_minecart","width":0.98,"height":0.7},
{"id":138,"name":"trader_llama","width":0.9,"height":1.87},
{"id":139,"name":"trident","width":0.5,"height":0.5},
{"id":140,"name":"tropical_fish","width":0.5,"height":0.4},
{"id":141,"name":"turtle","width":1.2,"height":0.4},
{"id":142,"name":"vex","width":0.4,"height":0.8},
{"id":143,"name":"villager","width":0.6,"height":1.95},
{"id":144,"name":"vindicator","width":0.6,"height":1.95},
{"id":145,"name":"wandering_trader","width":0.6,"height":1.95},
{"id":146,"name":"warden","width":0.9,"height":2.9},
{"id":147,"name":"wind_charge","width":0.3125,"height":0.3125},
{"id":148,"name":"witch","width":0.6,"height":1.95},
{"id":149,"name":"wither","width":0.9,"height":3.5},
{"id":150,"name":"wither_skeleton","width":0.7,"height":2.4},
{"id":151,"name":"wither_skull","width":0.3125,"height":0.3125},
{"id":152,"name":"wolf","width":0.6,"height":0.85},
{"id":153,"name":"zoglin","width":1.3964844,"height":1.4},
{"id":154,"name":"zombie","width":0.6,"height":1.95},
{"id":155,"name":"zombie_horse","width":1.3964844,"height":1.6},
{"id":156,"name":"zombie_nautilus","width":0.875,"height":0.95},
{"id":157,"name":"zombie_villager","width":0.6,"height":1.95},
{"id":158,"name":"zombified_piglin","width":0.6,"height":1.95},
{"id":159,"name":"player","width":0.6,"height":1.8},
{"id":160,"name":"fishing_bobber","width":0.25,"height":0.25}
]
File diff suppressed because it is too large Load Diff
+53
View File
@@ -0,0 +1,53 @@
{
"default":{},
"sword_instantly_mines":{"1025":2.0,"1030":1.0,"1035":4.0,"1040":12.0,"1045":6.0,"1050":8.0,"1055":9.0},
"sword_efficient":{"1025":2.0,"1030":1.0,"1035":4.0,"1040":12.0,"1045":6.0,"1050":8.0,"1055":9.0},
"incorrect_for_wooden_tool":{"1026":2.0,"1027":2.0,"1028":2.0,"1029":2.0},
"mineable/shovel":{"1026":2.0,"1031":1.0,"1036":4.0,"1041":12.0,"1046":6.0,"1051":8.0,"1056":9.0},
"mineable/pickaxe":{"1027":2.0,"1032":1.0,"1037":4.0,"1042":12.0,"1047":6.0,"1052":8.0,"1057":9.0},
"mineable/axe":{"1028":2.0,"1033":1.0,"1038":4.0,"1043":12.0,"1048":6.0,"1053":8.0,"1058":9.0},
"mineable/hoe":{"1029":2.0,"1034":1.0,"1039":4.0,"1044":12.0,"1049":6.0,"1054":8.0,"1059":9.0},
"incorrect_for_copper_tool":{"1031":1.0,"1032":1.0,"1033":1.0,"1034":1.0},
"incorrect_for_stone_tool":{"1036":4.0,"1037":4.0,"1038":4.0,"1039":4.0},
"incorrect_for_gold_tool":{"1041":12.0,"1042":12.0,"1043":12.0,"1044":12.0},
"incorrect_for_iron_tool":{"1046":6.0,"1047":6.0,"1048":6.0,"1049":6.0},
"incorrect_for_diamond_tool":{"1051":8.0,"1052":8.0,"1053":8.0,"1054":8.0},
"incorrect_for_netherite_tool":{"1056":9.0,"1057":9.0,"1058":9.0,"1059":9.0},
"shears_extreme_breaking_speed":{"1255":1.0},
"shears_major_breaking_speed":{"1255":1.0},
"shears_minor_breaking_speed":{"1255":1.0},
"leaves":{"1255":15.0,"1025":1.5,"1030":1.5,"1035":1.5,"1040":1.5,"1045":1.5,"1050":1.5,"1055":1.5},
"coweb":{"1255":15.0,"1025":15.0,"1030":15.0,"1035":15.0,"1040":15.0,"1045":15.0,"1050":15.0,"1055":15.0},
"vine_or_glow_lichen":{"1255":2.0},
"wool":{"1255":5.0},
"plant":{"1025":1.5,"1030":1.5,"1035":1.5,"1040":1.5,"1045":1.5,"1050":1.5,"1055":1.5},
"gourd":{"1025":1.5,"1030":1.5,"1035":1.5,"1040":1.5,"1045":1.5,"1050":1.5,"1055":1.5},
"plant;mineable/axe":{"1025":1.5,"1030":1.5,"1035":1.5,"1040":1.5,"1045":1.5,"1050":1.5,"1055":1.5,"1028":2.0,"1033":1.0,"1038":4.0,"1043":12.0,"1048":6.0,"1053":8.0,"1058":9.0},
"gourd;mineable/axe":{"1025":1.5,"1030":1.5,"1035":1.5,"1040":1.5,"1045":1.5,"1050":1.5,"1055":1.5,"1028":2.0,"1033":1.0,"1038":4.0,"1043":12.0,"1048":6.0,"1053":8.0,"1058":9.0},
"leaves;mineable/hoe":{"1255":15.0,"1025":1.5,"1030":1.5,"1035":1.5,"1040":1.5,"1045":1.5,"1050":1.5,"1055":1.5,"1029":2.0,"1034":1.0,"1039":4.0,"1044":12.0,"1049":6.0,"1054":8.0,"1059":9.0},
"leaves;mineable/axe;mineable/hoe":{
"1255":15.0,
"1025":1.5,
"1030":1.5,
"1035":1.5,
"1040":1.5,
"1045":1.5,
"1050":1.5,
"1055":1.5,
"1028":2.0,
"1033":1.0,
"1038":4.0,
"1043":12.0,
"1048":6.0,
"1053":8.0,
"1058":9.0,
"1029":2.0,
"1034":1.0,
"1039":4.0,
"1044":12.0,
"1049":6.0,
"1054":8.0,
"1059":9.0
},
"vine_or_glow_lichen;plant;mineable/axe":{"1255":2.0,"1025":1.5,"1030":1.5,"1035":1.5,"1040":1.5,"1045":1.5,"1050":1.5,"1055":1.5,"1028":2.0,"1033":1.0,"1038":4.0,"1043":12.0,"1048":6.0,"1053":8.0,"1058":9.0}
}
+32 -69
View File
@@ -1,78 +1,45 @@
import json
"""Minecraft 26.3 item registry data and automation selectors."""
from mosfet.info import mcdata
with open('minecraft_data/registries.json') as f:
ITEMS = json.load(f)['minecraft:item']['entries']
ITEMS = {
'minecraft:' + name: dict(item, protocol_id=item['id'])
for name, item in mcdata.mcd.items.items()
}
BEDS = [
'white_bed',
'orange_bed',
'magenta_bed',
'light_blue_bed',
'yellow_bed',
'lime_bed',
'pink_bed',
'gray_bed',
'light_gray_bed',
'cyan_bed',
'purple_bed',
'blue_bed',
'brown_bed',
'green_bed',
'red_bed',
'black_bed',
'white_bed', 'orange_bed', 'magenta_bed', 'light_blue_bed',
'yellow_bed', 'lime_bed', 'pink_bed', 'gray_bed', 'light_gray_bed',
'cyan_bed', 'purple_bed', 'blue_bed', 'brown_bed', 'green_bed',
'red_bed', 'black_bed',
]
SHOVELS = [
'wooden_shovel',
'stone_shovel',
'golden_shovel',
'iron_shovel',
'diamond_shovel',
'netherite_shovel',
'wooden_shovel', 'stone_shovel', 'golden_shovel', 'iron_shovel',
'diamond_shovel', 'netherite_shovel',
]
AXES = [
'wooden_axe',
'stone_axe',
'golden_axe',
'iron_axe',
'diamond_axe',
'netherite_axe',
'wooden_axe', 'stone_axe', 'golden_axe', 'iron_axe',
'diamond_axe', 'netherite_axe',
]
SAPLINGS = [
'oak_sapling',
'spruce_sapling',
'birch_sapling',
'jungle_sapling',
'acacia_sapling',
'dark_oak_sapling',
name for name in mcdata.mcd.blocks
if name.endswith('_sapling') or name.endswith('_propagule')
]
FOOD = [
'cooked_porkchop',
'cooked_beef',
'bread',
'cooked_chicken',
'cooked_cod',
'cooked_salmon',
'cooked_porkchop', 'cooked_beef', 'bread', 'cooked_chicken',
'cooked_cod', 'cooked_salmon',
]
LOGS = [
'oak_log',
'spruce_log',
'birch_log',
'jungle_log',
'acacia_log',
'dark_oak_log',
name for name in mcdata.mcd.blocks
if name.endswith(('_log', '_wood', '_stem', '_hyphae'))
]
def get_set(ids):
result = set()
for item_name in ids:
result.add(ITEMS['minecraft:'+item_name]['protocol_id'])
return result
def get_set(names):
return {
ITEMS['minecraft:' + name]['protocol_id']
for name in names if 'minecraft:' + name in ITEMS
}
BED_IDS = get_set(BEDS)
SHOVEL_IDS = get_set(SHOVELS)
@@ -80,23 +47,22 @@ AXE_IDS = get_set(AXES)
FOOD_IDS = get_set(FOOD)
SAPLING_IDS = get_set(SAPLINGS)
LOG_IDS = get_set(LOGS)
ITEM_NAMES = {}
for item_name, item in ITEMS.items():
ITEM_NAMES[ITEMS[item_name]['protocol_id']] = item_name.replace('minecraft:', '')
ITEM_NAMES = {item['protocol_id']: name.removeprefix('minecraft:')
for name, item in ITEMS.items()}
def get_id(name):
return ITEMS['minecraft:' + name]['protocol_id']
def get_name(idx):
return ITEM_NAMES[idx]
CHEST_ID = get_id('chest')
GAPPLE_ID = get_id('enchanted_golden_apple')
SAND_ID = get_id('sand')
NETHERWART_ID = get_id('nether_wart')
CARROT_ID = get_id('carrot')
POTATO_ID = get_id('potato')
WHEAT_ID = get_id('wheat')
@@ -104,25 +70,22 @@ WHEAT_SEEDS_ID = get_id('wheat_seeds')
BEETROOT_SEEDS_ID = get_id('beetroot_seeds')
PUMPKIN_ID = get_id('pumpkin')
BEETROOT_ID = get_id('beetroot')
EMERALD_ID = get_id('emerald')
BERRIES_ID = get_id('sweet_berries')
IRON_INGOT_ID = get_id('iron_ingot')
INIT_NEEDED_ITEMS = BED_IDS | FOOD_IDS
INIT_NEEDED_ITEMS.add(CHEST_ID)
NEEDED_ITEMS = INIT_NEEDED_ITEMS
INIT_WANTED_ITEMS = set()
WANTED_ITEMS = INIT_WANTED_ITEMS
def set_needed(items):
global NEEDED_ITEMS
NEEDED_ITEMS = INIT_NEEDED_ITEMS | items
def set_wanted(items):
global WANTED_ITEMS
WANTED_ITEMS = INIT_WANTED_ITEMS | items
+30 -26
View File
@@ -1,32 +1,36 @@
"""Minecraft 26.3 client data used by the automation layer.
The generated data is vendored under ``mosfet/info/data/26.3`` from
RosegoldMC/minecraft-data.cr (MIT); see that directory's LICENSE.
"""
import json
from munch import Munch
from pathlib import Path
from types import SimpleNamespace
import minecraft_data
DATA_VERSION = '26.3'
DATA_DIR = Path(__file__).resolve().parent / 'data' / DATA_VERSION
mcd = minecraft_data('1.16.4')
with open('minecraft_data/registries.json') as f:
DATA = json.load(f)
def _load(name):
with (DATA_DIR / name).open(encoding='utf-8') as source:
return json.load(source)
SINGLE_CHEST = 2
DOUBLE_CHEST = 5
VILLAGER_TRADE = 18
WINDOWS = {
SINGLE_CHEST: Munch(
container=list(range(0, 27)),
inventory=list(range(27, 63)),
slot_diff=18,
),
DOUBLE_CHEST: Munch(
container=list(range(0, 54)),
inventory=list(range(54, 90)),
slot_diff=45,
),
VILLAGER_TRADE: Munch(
input1=0,
input2=1,
output=2,
inventory=list(range(3, 38)),
),
}
block_list = _load('blocks.json')
item_list = _load('items.json')
entity_list = _load('entities.json')
materials = _load('materials.json')
collision_shapes = _load('blockCollisionShapes.json')
blocks = {block['name']: block for block in block_list}
items = {item['name']: item for item in item_list}
entities = {entity['name']: entity for entity in entity_list}
mcd = SimpleNamespace(
version=DATA_VERSION,
blocks=blocks,
items=items,
entities=entities,
materials=materials,
collision_shapes=collision_shapes,
)
+22 -49
View File
@@ -1,10 +1,13 @@
from mosfet.info import items
import json
"""Minecraft 26.3 entity registry data and legacy mob selectors."""
from mosfet.info import items, mcdata
with open('minecraft_data/registries.json') as f:
MOBS = json.load(f)['minecraft:entity_type']['entries']
MOBS = {
'minecraft:' + name: dict(entity, protocol_id=entity['id'])
for name, entity in mcdata.mcd.entities.items()
}
VILLAGER = MOBS['minecraft:villager']['protocol_id']
VILLAGER = 93
# Villager profession enum values remain the protocol's 0-based profession IDs.
ARMORER = 1
BUTCHER = 2
CARTOGRAPHER = 3
@@ -23,53 +26,23 @@ WEAPONSMITH = 14
TRADES = {
ARMORER: [items.IRON_INGOT_ID],
BUTCHER: [items.BERRIES_ID],
FARMER: [items.PUMPKIN_ID, items.WHEAT_ID, items.POTATO_ID, items.CARROT_ID, items.BEETROOT_ID],
FARMER: [items.PUMPKIN_ID, items.WHEAT_ID, items.POTATO_ID,
items.CARROT_ID, items.BEETROOT_ID],
TOOLSMITH: [items.IRON_INGOT_ID],
WEAPONSMITH: [items.IRON_INGOT_ID],
}
EVIL = [
'blaze',
'cave_spider',
'creeper',
'drowned',
'elder_guardian',
'ender_dragon',
'enderman',
'endermite',
'evoker',
'ghast',
'giant',
'guardian',
'hoglin',
'husk',
'illusioner',
'magma_cube',
'phantom',
'piglin',
'piglin_brute',
'pillager',
'ravager',
'shulker',
'silverfish',
'skeleton',
'skeleton_horse',
'slime',
'spider',
'stray',
'vex',
'vindicator',
'witch',
'wither',
'zoglin',
'zombie',
'zombie_villager',
'blaze', 'cave_spider', 'creeper', 'drowned', 'elder_guardian',
'ender_dragon', 'enderman', 'endermite', 'evoker', 'ghast', 'giant',
'guardian', 'hoglin', 'husk', 'illusioner', 'magma_cube', 'phantom',
'piglin', 'piglin_brute', 'pillager', 'ravager', 'shulker', 'silverfish',
'skeleton', 'skeleton_horse', 'slime', 'spider', 'stray', 'vex',
'vindicator', 'witch', 'wither', 'zoglin', 'zombie', 'zombie_villager',
]
EVIL_IDS = set()
for mob_name in EVIL:
EVIL_IDS.add(MOBS['minecraft:'+mob_name]['protocol_id'])
MOB_NAMES = {}
for mob_name, mob in MOBS.items():
MOB_NAMES[MOBS[mob_name]['protocol_id']] = mob_name.replace('minecraft:', '')
EVIL_IDS = {
MOBS['minecraft:' + name]['protocol_id']
for name in EVIL if 'minecraft:' + name in MOBS
}
MOB_NAMES = {entity['protocol_id']: name.removeprefix('minecraft:')
for name, entity in MOBS.items()}