def _compiled_extend(self, other: BaseTranslationFunction, parents: list):
		"""Used to merge two completed translations together.
		The formats must match in such a way that the two base translations do not interfere."""
		assert self.get('type', None) == other.get('type', None), '"type" must match in both NBT types'

		for key, default in (('self_default', {"carry_nbt": {}}), ('functions', {})):
			if key in self:
				self[key].extend(other.get(key, default), parents)
			elif key in other:
				self[key] = other[key]

		if not self.bypass_type and self['type'] in ('compound', 'list', 'byte_array', 'int_array', 'long_array'):
			if 'nested_default' in self:
				self['nested_default'].extend(other.get('nested_default', {"carry_nbt": {}}), parents)
			elif 'nested_default' in other:
				self['nested_default'] = other['nested_default']

			if self['type'] == 'compound':
				key = 'keys'
			else:
				key = 'index'

			if key in other and key in self:
				for val in other[key].keys():
					if val in self[key].keys():
						self[key][val].extend(other[key][val], parents)
					else:
						self[key][val] = other[key][val]
			else:
				assert key not in other and key not in self, '"keys" defined in one but not the other'
Exemple #2
0
	def __init__(self, data):
		if 'cases' in data['options']:
			for key, val in data['options']['cases'].items():
				data['options']['cases'][key] = FunctionList(val)
		if 'default' in data['options']:
			data['options']['default'] = FunctionList(data['options']['default'])
		BaseTranslationFunction.__init__(self, data)
Exemple #3
0
 def __init__(self, data):
     from PyMCTCompiler import primitives  # if this is imported at the top it causes issues because values have not been defined
     if isinstance(data['options'], str):
         data['options']: List[List[str]] = [[data['options']]]
     elif isinstance(data['options'], list):
         data['options']: List[List[str]] = [data['options']]
     else:
         raise Exception('Format is not correct')
     BaseTranslationFunction.__init__(self, data)
	def __init__(self, data, bypass_type=False):
		for key in ('self_default', 'functions'):
			if key in data:
				data[key] = FunctionList(data[key])

		if not bypass_type and data['type'] in ('compound', 'list', 'byte_array', 'int_array', 'long_array'):
			if 'nested_default' in data:
				data['nested_default'] = FunctionList(data['nested_default'])
			if data['type'] == 'compound':
				if 'keys' in data:
					for key, val in data['keys'].items():
						data['keys'][key] = ContainerWalkInputNBT(val)
			elif data['type'] == 'list':
				if 'index' in data:
					for key, val in data['index'].items():
						data['index'][key] = ContainerWalkInputNBT(val)
			else:
				if 'index' in data:
					for key, val in data['index'].items():
						data['index'][key] = ContainerWalkInputNBT(val, True)

		BaseTranslationFunction.__init__(self, data)
		self.bypass_type = bypass_type
Exemple #5
0
	def __init__(self, data):
		BaseTranslationFunction.__init__(self, data)
Exemple #6
0
 def __init__(self, data):
     for option, data_ in data['options'].items():
         data['options'][option] = FunctionList(data_)
     BaseTranslationFunction.__init__(self, data)
	def __init__(self, data):
		data['options'] = ContainerWalkInputNBT(data['options'])
		BaseTranslationFunction.__init__(self, data)
 def __init__(self, data):
     if isinstance(data['options'], dict):
         data['options'] = [data['options']]
     for option in data['options']:
         option['functions'] = FunctionList(option['functions'])
     BaseTranslationFunction.__init__(self, data)
 def __init__(self, data):
     for property_name in data.get('options', {}):
         for property_value in data['options'][property_name]:
             data['options'][property_name][property_value] = FunctionList(
                 data['options'][property_name][property_value])
     BaseTranslationFunction.__init__(self, data)