From 159a3188b07675007b8156e3edd1eb8665260c2f Mon Sep 17 00:00:00 2001 From: Khroki Date: Fri, 5 Sep 2014 10:06:29 -0400 Subject: [PATCH] 1.8 Release Update Made item system 1.7+ Compatible, widened text windows, and tweaked more renderers. --- editortools/blockpicker.py | 4 +- editortools/select.py | 12 +++-- leveleditor.py | 24 +++++----- mceutils.py | 4 +- renderer.py | 90 +++++++++++++++++++++++++++++++++++--- 5 files changed, 108 insertions(+), 26 deletions(-) diff --git a/editortools/blockpicker.py b/editortools/blockpicker.py index f832452..70cf01d 100644 --- a/editortools/blockpicker.py +++ b/editortools/blockpicker.py @@ -23,7 +23,7 @@ class BlockPicker(Dialog): def __init__(self, blockInfo, materials, *a, **kw): self.allowWildcards = False Dialog.__init__(self, *a, **kw) - panelWidth = 350 + panelWidth = 435 self.materials = materials self.anySubtype = blockInfo.wildcard @@ -63,7 +63,7 @@ def formatBlockName(x): return r - tableview = TableView(columns=[TableColumn(" ", 24, "l", lambda x: ""), TableColumn("(ID) Name [Aliases]", 276, "l", formatBlockName)]) + tableview = TableView(columns=[TableColumn(" ", 24, "l", lambda x: ""), TableColumn("(ID) Name [Aliases]", 376, "l", formatBlockName)]) tableicons = [blockview.BlockView(materials) for i in range(tableview.rows.num_rows())] for t in tableicons: t.size = (16, 16) diff --git a/editortools/select.py b/editortools/select.py index baf89f1..8a9be23 100644 --- a/editortools/select.py +++ b/editortools/select.py @@ -323,7 +323,7 @@ def worldTooltipText(self): return repr(e) def worldTooltipForBlock(self, pos): - + blockdata = self.editor.level.blockDataAt(*pos) x, y, z = pos cx, cz = x / 16, z / 16 if isinstance(self.editor.level, pymclevel.MCInfdevOldLevel): @@ -343,7 +343,9 @@ def worldTooltipForBlock(self, pos): if block in (pymclevel.alphaMaterials.Chest.ID, pymclevel.alphaMaterials.Furnace.ID, pymclevel.alphaMaterials.LitFurnace.ID, - pymclevel.alphaMaterials.Dispenser.ID): + pymclevel.alphaMaterials.Dispenser.ID, + pymclevel.alphaMaterials.Hopper.ID, + pymclevel.alphaMaterials.Dropper.ID): t = self.editor.level.tileEntityAt(*pos) if t: containerID = t["id"].value @@ -364,7 +366,9 @@ def worldTooltipForBlock(self, pos): else: return "Empty {0}. \n\nDouble-click to edit {0}.".format(containerID) else: - return "Double-click to initialize the {0}.".format(pymclevel.alphaMaterials.names[block][0]) + #return "Double-click to initialize {0}.".format(pymclevel.alphaMaterials.names[block][blockdata]) + #Will undo when container initialization is fixed. + return "Uninitialized {0}.".format(pymclevel.alphaMaterials.names[block][blockdata]) if block == pymclevel.alphaMaterials.MonsterSpawner.ID: t = self.editor.level.tileEntityAt(*pos) @@ -384,7 +388,7 @@ def worldTooltipForBlock(self, pos): signtext = "Undefined" return "Sign text: \n" + signtext + "\n\n" + "Double-click to edit sign." - absentTexture = (self.editor.level.materials.blockTextures[block, 0, 0] == pymclevel.materials.NOTEX).all() + absentTexture = (self.editor.level.materials.blockTextures[block, blockdata, 0] == pymclevel.materials.NOTEX).all() if absentTexture: return self.describeBlockAt(pos) diff --git a/leveleditor.py b/leveleditor.py index 63c50bb..17c9dfe 100644 --- a/leveleditor.py +++ b/leveleditor.py @@ -759,7 +759,7 @@ class ChestWidget(Widget): id = itemProp("id") Damage = itemProp("Damage") Count = itemProp("Count") - itemLimit = pymclevel.TileEntity.maxItems.get(containerID, 255) + itemLimit = pymclevel.TileEntity.maxItems.get(containerID, 26) def slotFormat(slot): slotNames = pymclevel.TileEntity.slotNames.get(containerID) @@ -769,12 +769,12 @@ def slotFormat(slot): chestWidget = ChestWidget() chestItemTable = TableView(columns=[ - TableColumn("Slot", 80, "l", fmt=slotFormat), - TableColumn("ID", 50, "l"), + TableColumn("Slot", 60, "l", fmt=slotFormat), + TableColumn("ID / ID Name", 345, "l"), #Widened to accept the much longer 1.8 internal names TableColumn("DMG", 50, "l"), TableColumn("Count", 65, "l"), - TableColumn("Name", 200, "l"), + TableColumn("Name", 260, "l"), ]) def itemName(id, damage): @@ -799,8 +799,8 @@ def selectTableRow(i, evt): chestItemTable.click_row = selectTableRow fieldRow = ( - # mceutils.IntInputRow("Slot: ", ref=AttrRef(chestWidget, 'Slot'), min= -128, max=127), - mceutils.IntInputRow("ID: ", ref=AttrRef(chestWidget, 'id'), min=0, max=32767), + mceutils.IntInputRow("Slot: ", ref=AttrRef(chestWidget, 'Slot'), min=0, max=26), + mceutils.TextInputRow("ID / ID Name: ", ref=AttrRef(chestWidget, 'id'),width=300), #Text to allow the input of internal item names mceutils.IntInputRow("DMG: ", ref=AttrRef(chestWidget, 'Damage'), min=-32768, max=32767), mceutils.IntInputRow("Count: ", ref=AttrRef(chestWidget, 'Count'), min=-128, max=127), ) @@ -898,16 +898,16 @@ def addItem(): if slot >= chestWidget.itemLimit: return item = pymclevel.TAG_Compound() - item["id"] = pymclevel.TAG_Short(0) + item["id"] = pymclevel.TAG_String("minecraft:") item["Damage"] = pymclevel.TAG_Short(0) item["Slot"] = pymclevel.TAG_Byte(slot) item["Count"] = pymclevel.TAG_Byte(0) tileEntityTag["Items"].append(item) - addItemButton = Button("Add Item", action=addItem, enable=addEnable) + addItemButton = Button("New Item (1.7+)", action=addItem, enable=addEnable) deleteItemButton = Button("Delete This Item", action=deleteItem, enable=deleteEnable) - deleteFromWorldButton = Button("Delete Item ID From Entire World", action=deleteFromWorld, enable=deleteEnable) - deleteCol = Column((addItemButton, deleteItemButton, deleteFromWorldButton), align="l") + deleteFromWorldButton = Button("Delete All Instances Of This Item From World", action=deleteFromWorld, enable=deleteEnable) + deleteCol = Column((addItemButton, deleteItemButton, deleteFromWorldButton)) fieldRow = Row(fieldRow) col = Column((chestItemTable, fieldRow, deleteCol)) @@ -2915,8 +2915,8 @@ def click_row(i, evt): d.dismiss("Cancel") worldTable = TableView(columns=[ - TableColumn("Last Played", 250, "l"), - TableColumn("Level Name (filename)", 400, "l"), + TableColumn("Last Played", 170, "l"), + TableColumn("Level Name (filename)", 500, "l"), TableColumn("Dims", 100, "r"), ]) diff --git a/mceutils.py b/mceutils.py index f17ea74..44ba528 100644 --- a/mceutils.py +++ b/mceutils.py @@ -488,7 +488,7 @@ def value(self, val): row.checkbox = cb return row -from albow import FloatField, IntField +from albow import FloatField, IntField, TextField def FloatInputRow(title, *args, **kw): @@ -501,6 +501,8 @@ def IntInputRow(title, *args, **kw): from albow.dialogs import Dialog from datetime import timedelta +def TextInputRow(title, *args, **kw): + return Row((Label(title, tooltipText=kw.get('tooltipText')), TextField(*args, **kw))) def setWindowCaption(prefix): caption = display.get_caption()[0] diff --git a/renderer.py b/renderer.py index 360354d..047fc46 100644 --- a/renderer.py +++ b/renderer.py @@ -418,9 +418,11 @@ def makeRenderstates(self, materials): SnowBlockRenderer, CarpetBlockRenderer, CactusBlockRenderer, + PaneBlockRenderer, CakeBlockRenderer, DaylightBlockRenderer, #LeverBlockRenderer, + BedBlockRenderer, EnchantingBlockRenderer, RedstoneBlockRenderer, IceBlockRenderer, @@ -656,10 +658,21 @@ def calcHighDetailFaces(self, cr, blockRenderers): # ForChunk(self, chunkPositi areaBlockLights = self.getAreaBlockLights(chunk, neighboringChunks) yield - slabs = areaBlocks == pymclevel.materials.alphaMaterials.StoneSlab.ID + slabs = areaBlocks == pymclevel.materials.alphaMaterials.StoneSlab.ID #If someone could combine these, that would be great. if slabs.any(): areaBlockLights[slabs] = areaBlockLights[:, :, 1:][slabs[:, :, :-1]] yield + + woodSlabs = areaBlocks == pymclevel.materials.alphaMaterials.OakWoodSlab.ID + if woodSlabs.any(): + areaBlockLights[woodSlabs] = areaBlockLights[:, :, 1:][woodSlabs[:, :, :-1]] + yield + + redSlabs = areaBlocks == pymclevel.materials.alphaMaterials.RedSandstoneSlab.ID + if redSlabs.any(): + areaBlockLights[redSlabs] = areaBlockLights[:, :, 1:][redSlabs[:, :, :-1]] + yield + showHiddenOres = cr.renderer.showHiddenOres if showHiddenOres: @@ -1356,7 +1369,7 @@ def makePlantVertices(self, facingBlockIndices, blocks, blockMaterials, blockDat makeVertices = makePlantVertices -class TorchBlockRenderer(BlockRenderer): #Levers here until someone makes a renderer for it. +class TorchBlockRenderer(BlockRenderer): #Levers here until someone makes a separate renderer for it. blocktypes = [pymclevel.materials.alphaMaterials.Torch.ID, pymclevel.materials.alphaMaterials.RedstoneTorchOff.ID, pymclevel.materials.alphaMaterials.RedstoneTorchOn.ID, @@ -1752,6 +1765,40 @@ def makeCactusVertices(self, facingBlockIndices, blocks, blockMaterials, blockDa makeVertices = makeCactusVertices +class PaneBlockRenderer(BlockRenderer): #Basic no thickness panes, add more faces to widen. + blocktypes = [pymclevel.materials.alphaMaterials.GlassPane.ID, pymclevel.materials.alphaMaterials.StainedGlassPane.ID, pymclevel.materials.alphaMaterials.IronBars.ID] + + def makePaneVertices(self, facingBlockIndices, blocks, blockMaterials, blockData, areaBlockLights, texMap): + materialIndices = self.getMaterialIndices(blockMaterials) + arrays = [] + yield + for direction, exposedFaceIndices in enumerate(facingBlockIndices): + + blockIndices = materialIndices + facingBlockLight = areaBlockLights[self.directionOffsets[direction]] + lights = facingBlockLight[blockIndices][..., numpy.newaxis, numpy.newaxis] + + vertexArray = self.makeTemplate(direction, blockIndices) + if not len(vertexArray): + continue + vertexArray[_ST] += texMap(blocks[blockIndices], blockData[blockIndices], direction)[:, numpy.newaxis, 0:2] + vertexArray.view('uint8')[_RGB] *= lights + + if direction == pymclevel.faces.FaceXIncreasing: + vertexArray[_XYZ][..., 0] -= 0.5 + if direction == pymclevel.faces.FaceXDecreasing: + vertexArray[_XYZ][..., 0] += 0.5 + if direction == pymclevel.faces.FaceZIncreasing: + vertexArray[_XYZ][..., 2] -= 0.5 + if direction == pymclevel.faces.FaceZDecreasing: + vertexArray[_XYZ][..., 2] += 0.5 + + arrays.append(vertexArray) + yield + self.vertexArrays = arrays + + makeVertices = makePaneVertices + class PlateBlockRenderer(BlockRenderer): #suggestions to make this the proper shape is appreciated. blocktypes = [pymclevel.materials.alphaMaterials.StoneFloorPlate.ID, pymclevel.materials.alphaMaterials.WoodFloorPlate.ID, @@ -1843,6 +1890,35 @@ def makeDaylightVertices(self, facingBlockIndices, blocks, blockMaterials, block self.vertexArrays = arrays makeVertices = makeDaylightVertices + +class BedBlockRenderer(BlockRenderer): + blocktypes = [pymclevel.materials.alphaMaterials.Bed.ID] + def makeBedVertices(self, facingBlockIndices, blocks, blockMaterials, blockData, areaBlockLights, texMap): + materialIndices = self.getMaterialIndices(blockMaterials) + arrays = [] + yield + for direction, exposedFaceIndices in enumerate(facingBlockIndices): + if direction != pymclevel.faces.FaceYIncreasing: + blockIndices = materialIndices & exposedFaceIndices + else: + blockIndices = materialIndices + + facingBlockLight = areaBlockLights[self.directionOffsets[direction]] + lights = facingBlockLight[blockIndices][..., numpy.newaxis, numpy.newaxis] + vertexArray = self.makeTemplate(direction, blockIndices) + if not len(vertexArray): + continue + + vertexArray[_ST] += texMap(blocks[blockIndices], blockData[blockIndices], direction)[:, numpy.newaxis, 0:2] + vertexArray.view('uint8')[_RGB] *= lights + if direction == pymclevel.faces.FaceYIncreasing: + vertexArray[_XYZ][..., 1] -= 0.438 + + arrays.append(vertexArray) + yield + self.vertexArrays = arrays + + makeVertices = makeBedVertices class CakeBlockRenderer(BlockRenderer): #Only shows whole cakes blocktypes = [pymclevel.materials.alphaMaterials.Cake.ID] @@ -2124,13 +2200,13 @@ def vineFaceVertices(self, direction, blockIndices, exposedFaceIndices, blocks, class SlabBlockRenderer(BlockRenderer): - blocktypes = [pymclevel.materials.alphaMaterials.OakWoodSlab.ID, pymclevel.materials.alphaMaterials.StoneSlab.ID, pymclevel.materials.alphaMaterials.RedSandstoneSlab.ID] + blocktypes = [pymclevel.materials.alphaMaterials.OakWoodSlab.ID, + pymclevel.materials.alphaMaterials.StoneSlab.ID, + pymclevel.materials.alphaMaterials.RedSandstoneSlab.ID] - def slabFaceVertices(self, direction, blockIndices, exposedFaceIndices, blocks, blockData, blockLight, facingBlockLight, texMap): - if direction != pymclevel.faces.FaceYIncreasing: - blockIndices = blockIndices & exposedFaceIndices + def slabFaceVertices(self, direction, blockIndices, facingBlockLight, blocks, blockData, blockLight, areaBlockLights, texMap): - lights = facingBlockLight[blockIndices][..., numpy.newaxis, numpy.newaxis] + lights = areaBlockLights[blockIndices][..., numpy.newaxis, numpy.newaxis] bdata = blockData[blockIndices] top = (bdata >> 3).astype(bool) bdata &= 7