Ejemplo n.º 1
0
class Item(MCDict):
	count:			Union[IntRange, int]	= mc_basic('count', init_int_or_range)
	durability:		Union[IntRange, int]	= mc_basic('durability', init_int_or_range)
	enchantments:	List[Enchantment]		= mc_list('enchantments', Enchantment)
	item_id:		str						= mc_basic('item', str)
	nbt:			str						= mc_basic('nbt', str)
	potion:			str						= mc_basic('potion', str)
	tag:			str						= mc_basic('tag', str)

	@staticmethod
	def populate(count: Union[IntRange, int] = None, durability: Union[IntRange, int] = None, enchantments: List[Enchantment] = None, item_id: str = None, nbt: str = None, potion: str = None, tag: str = None):
		item = Item()
		if count is not None:
			item.count = count
		if durability is not None:
			item.durability = durability
		if enchantments is not None:
			item.enchantments = enchantments
		if item is not None:
			item.item_id = item_id
		if nbt is not None:
			item.nbt = nbt
		if potion is not None:
			item.potion = potion
		if tag is not None:
			item.tag = tag

		return item
class Advancement(MCDict):
    display: Display = mc_basic('display', Display)
    parent: str = mc_basic('parent', str)
    criteria: Dict[str, Criteria] = mc_dict('criteria', Criteria.create)
    requirements: List[List[str]] = mc_list('requirements', list)
    rewards: Rewards = mc_basic('rewards', Rewards)

    @staticmethod
    def populate(criteria: Dict[str, Criteria],
                 display: Display = None,
                 parent: str = None,
                 requirements: List[str] = None,
                 rewards: Rewards = None):
        adv = Advancement()
        adv.criteria = criteria
        if display is not None:
            adv.display = display
        if parent is not None:
            adv.parent = parent
        if requirements is not None:
            adv.requirements = requirements
        if rewards is not None:
            adv.rewards = rewards

        return adv
Ejemplo n.º 3
0
class Pool(MCDict, MCInteractable):
    conditions: List[Condition] = mc_list('conditions', Condition.create)
    rolls: Union[IntRange, int] = mc_basic('rolls', init_int_or_range)
    bonus_rolls: Union[FloatRange, float] = mc_basic('bonus_rolls',
                                                     init_float_or_range)
    entries: List[Entry] = mc_list('entries', Entry.create)

    def interact(self, info: MCActionInfo):
        if info.item_type == eItemType.Entry and 'entries' in self:
            interact_with_items(self, 'entries', info)

        elif info.item_type == eItemType.Condition:
            if 'conditions' in self:
                interact_with_items(self, 'conditions', info)
            if 'entries' in self:
                interact_with_subitems(self.entries, info)
class LootTable(MCDict, MCInteractable):
	typ:	eLootTable = mc_basic('type', eLootTable)
	pools:	List[Pool] = mc_list('pools', Pool)

	def interact(self, info: MCActionInfo):
		if 'pools' in self:
			interact_with_subitems(self.pools, info)
Ejemplo n.º 5
0
class Function(MCDict, MCInteractable):
    function: eFunction = mc_basic('function', eFunction)
    conditions: List[Condition] = mc_list('conditions', Condition.create)

    def interact(self, info: MCActionInfo):
        if info.item_type == eItemType.Condition and 'conditions' in self:
            interact_with_items(self, 'conditions', info)

    @staticmethod
    def create(json_dict):
        return Function(json_dict)
Ejemplo n.º 6
0
class Entry(MCDict, MCInteractable):
    conditions: List[Condition] = mc_list('conditions', Condition.create)
    typ: eEntry = mc_basic('type', eEntry)
    weight: int = mc_basic('weight', int)
    quality: int = mc_basic('quality', int)

    def interact(self, info: MCActionInfo):
        if info.item_type == eItemType.Entry and 'children' in self:
            interact_with_items(self, 'children', info)

        elif info.item_type == eItemType.Condition:
            if 'conditions' in self:
                interact_with_items(self, 'conditions', info)
            if 'children' in self:
                interact_with_subitems(self['children'], info)
                if info.action_type is eActionType.Delete and self.typ is eEntry.alternatives and not any(
                        'conditions' in child for child in self['children']):
                    self.typ = eEntry.group
            if 'functions' in self:
                interact_with_subitems(self['functions'], info)

    @staticmethod
    def create(json_body):
        typ = json_body['type']

        if typ == eEntry.item:
            return ItemEntry(json_body)

        elif typ == eEntry.tag:
            return TagEntry(json_body)

        elif typ == eEntry.loot_table:
            return LootTableEntry(json_body)

        elif typ == eEntry.group:
            return GroupEntry(json_body)

        elif typ == eEntry.alternatives:
            return AlternativesEntry(json_body)

        elif typ == eEntry.sequence:
            return SequenceEntry(json_body)

        elif typ == eEntry.dynamic:
            return DynamicEntry(json_body)

        else:
            return Entry(json_body)
class CraftingShaped(Recipe):
    pattern: List[str] = mc_list('pattern', str)
    key: Dict[str, Union[Ingredient,
                         List[Ingredient]]] = mc_dict('key',
                                                      init_ingredient_or_list)
    result: Result = mc_basic('result', Result)
class Rewards(MCDict):
    recipes: List[str] = mc_list('recipes', str)
    loot: List[str] = mc_list('loot', str)
    experience: int = mc_basic('experience', int)
    function: str = mc_basic('function', str)
class InventoryChanged(TriggerConditions):
    req_items: List[Item] = mc_list('items', Item)
    slots: dict = mc_basic('slots', dict)
Ejemplo n.º 10
0
class Alternative(Condition):
    terms: List[Condition] = mc_list('terms', Condition.create)
Ejemplo n.º 11
0
class SequenceEntry(Entry):
    children: List[Entry] = mc_list('children', Entry.create)
Ejemplo n.º 12
0
class AlternativesEntry(Entry):
    children: List[Entry] = mc_list('children', Entry.create)
Ejemplo n.º 13
0
class GroupEntry(Entry):
    children: List[Entry] = mc_list('children', Entry.create)
Ejemplo n.º 14
0
class ItemEntry(Entry):
    name: str = mc_basic('name', str)
    functions: List[Function] = mc_list('functions', Function.create)