2024-09-19 23:45:29 发布
网友
在MCEdit过滤器编程中,如何从头开始创建一个箱子?不是chests实体,处理方式与使用setBlockAt的块不同。在
有人能展示一些在过滤器中创建新的空箱子的示例代码吗?最好在用户所做的选择框内。在
在研究了MCE的源代码和SethBling的一些过滤器的源代码之后,我设法编写了一些代码。在
以下函数假定一个名为levelOBJ的全局对象,该对象被设置为perform()函数中的传入level对象。这样你就不用一直传球了。在
# Just so I don't have to keep doing the math def getChunkAt(x, z): chunk = levelObj.getChunk(x / 16, z / 16) return chunk # Creates a TAG_Compound Item (for use with the CreateChestAt function) def CreateChestItem(itemid, damage=0, count=1, slot=0): item = TAG_Compound() item["id"] = TAG_Short(itemid) item["Damage"] = TAG_Short(damage) item["Count"] = TAG_Byte(count) item["Slot"] = TAG_Byte(slot) return item # Creates a chest at the specified coords containing the items passed def CreateChestAt(x, y, z, Items=None, Direction=2, CustomName=""): levelObj.setBlockAt(x, y, z, 54) # Chest Block (single = 27 slots 0-26), 54 == chest, 146 == Trapped Chest levelObj.setBlockDataAt(x, y, z, Direction) # 2==N, 3==S, 4==W, 5==E anything else == N # Now Create Entity Block and add it to the chunk chunk = getChunkAt(x, z) chest = TileEntity.Create("Chest") TileEntity.setpos(chest, (x, y, z)) if Items <> None: chest["Items"] = Items if CustomName <> "": chest["CustomName"] = CustomName chunk.TileEntities.append(chest)
然后,您可以在过滤器中使用我的函数,方法是按照下面的示例调用它们。下面,x,y,z假设它们已经被你希望放置胸部的适当坐标填充。在
另外,双胸就是两个并排的胸。调用CreateChestAt两次(两个坐标分别为E-W或N-S)创建一个双保险箱。你可以连续创造3个,但地雷阵会使第3个箱子失效,使其无法进入游戏,所以请注意你如何放置它们。在
要创建空箱子:
要创建包含项目的箱子,请执行以下操作:
# Build item list (4 Jungle Planks and 11 chests ChestItems = TAG_List() ChestItems.append( CreateChestItem(5, 3, 4, 0) ) ChestItems.append( CreateChestItem(54, 0, 11, 1) ) # Make a chest with the items. CreateChestAt(x, y, z, ChestItems)
也可以指定方向和CustomName的可选参数。。。在
创建一个朝西的空箱子,名为“我的胸部”
在研究了MCE的源代码和SethBling的一些过滤器的源代码之后,我设法编写了一些代码。在
以下函数假定一个名为levelOBJ的全局对象,该对象被设置为perform()函数中的传入level对象。这样你就不用一直传球了。在
然后,您可以在过滤器中使用我的函数,方法是按照下面的示例调用它们。下面,x,y,z假设它们已经被你希望放置胸部的适当坐标填充。在
另外,双胸就是两个并排的胸。调用CreateChestAt两次(两个坐标分别为E-W或N-S)创建一个双保险箱。你可以连续创造3个,但地雷阵会使第3个箱子失效,使其无法进入游戏,所以请注意你如何放置它们。在
要创建空箱子:
^{pr2}$要创建包含项目的箱子,请执行以下操作:
也可以指定方向和CustomName的可选参数。。。在
创建一个朝西的空箱子,名为“我的胸部”
^{4}$相关问题 更多 >
编程相关推荐