本文整理匯總了Python中block.Block方法的典型用法代碼示例。如果您正苦於以下問題:Python block.Block方法的具體用法?Python block.Block怎麽用?Python block.Block使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類block
的用法示例。
在下文中一共展示了block.Block方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: import block [as 別名]
# 或者: from block import Block [as 別名]
def __init__(self, x, y, z, blockType, blockData = 0, tag = ""):
#persist data
self.blockType = blockType
self.blockData = blockData
#store the positions
# original pos
self.originalPos = minecraft.Vec3(x, y, z)
# relative pos - block position relatively to other shape blocks
self.relativePos = minecraft.Vec3(x, y, z)
# actual pos - actual block position in the world
self.actualPos = minecraft.Vec3(x, y, z)
#the tag system is used to give a particular block inside a shape meaning
# e.g. for an animal shape you could tag the block which is its head
self.tag = tag
# the mc block object
self.mcBlock = block.Block(blockType, blockData)
示例2: getBlockWithData
# 需要導入模塊: import block [as 別名]
# 或者: from block import Block [as 別名]
def getBlockWithData(self, *args):
"""Get block with data (x,y,z) => Block"""
ans = self.conn.sendReceive("world.getBlockWithData", intFloor(args))
return Block(*map(int, ans.split(",")))
示例3: __init__
# 需要導入模塊: import block [as 別名]
# 或者: from block import Block [as 別名]
def __init__(self, address=None):
self._bucket = Bucket(Blockchain.db_file, Blockchain.block_bucket)
try:
self._tip = self._bucket.get('l')
except KeyError:
if not address:
self._tip = None
else:
cb_tx = CoinbaseTx(
address, Blockchain.genesis_coinbase_data)
genesis = Block([cb_tx]).pow_of_block()
self._block_put(genesis)
示例4: MineBlock
# 需要導入模塊: import block [as 別名]
# 或者: from block import Block [as 別名]
def MineBlock(self, transaction_lst):
# Mines a new block with the provided transactions
last_hash = self._bucket.get('l')
for tx in transaction_lst:
if not self.verify_transaction(tx):
print("ERROR: Invalid transaction")
sys.exit()
new_block = Block(transaction_lst, last_hash).pow_of_block()
self._block_put(new_block)
return new_block
示例5: __init__
# 需要導入模塊: import block [as 別名]
# 或者: from block import Block [as 別名]
def __init__(self, x, y, z, blockType, blockData=0):
#persist data
self.blockType = blockType
self.blockData = blockData
#store the positions
# relative pos - block position relatively to other shape blocks
self.relativePos = minecraft.Vec3(x, y, z)
# actual pos - actual block position in the world
self.actualPos = minecraft.Vec3(x, y, z)
# the mc block object
self.mcBlock = block.Block(blockType, blockData)
示例6: penblock
# 需要導入模塊: import block [as 別名]
# 或者: from block import Block [as 別名]
def penblock(self, blockId, blockData=0):
"""
set the block the turtle uses as its pen.
:param int blockType:
The block id.
:param int blockData:
The block data value, defaults to ``0``.
"""
self._penblock = block.Block(blockId, blockData)
示例7: refresh
# 需要導入模塊: import block [as 別名]
# 或者: from block import Block [as 別名]
def refresh(self):
""" Even though blocks never change, you freshly obtain its contents
from an API with this method
"""
identifier = self.identifier
block = self.blockchain.rpc.get_block(self.identifier)
if not block:
raise BlockDoesNotExistsException
super(Block, self).__init__(
block, blockchain_instance=self.blockchain, use_cache=self._use_cache
)
# block does not contain an id and thus identifier gets overwritten
self.identifier = identifier