Skip to content

Commit

Permalink
1.8 Release Update
Browse files Browse the repository at this point in the history
Made item system 1.7+ Compatible, widened text windows, and tweaked more
renderers.
  • Loading branch information
Khroki committed Sep 5, 2014
1 parent ce29842 commit 159a318
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 26 deletions.
4 changes: 2 additions & 2 deletions editortools/blockpicker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
12 changes: 8 additions & 4 deletions editortools/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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)

Expand Down
24 changes: 12 additions & 12 deletions leveleditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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):
Expand All @@ -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),
)
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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"),

])
Expand Down
4 changes: 3 additions & 1 deletion mceutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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]
Expand Down
90 changes: 83 additions & 7 deletions renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,9 +418,11 @@ def makeRenderstates(self, materials):
SnowBlockRenderer,
CarpetBlockRenderer,
CactusBlockRenderer,
PaneBlockRenderer,
CakeBlockRenderer,
DaylightBlockRenderer,
#LeverBlockRenderer,
BedBlockRenderer,
EnchantingBlockRenderer,
RedstoneBlockRenderer,
IceBlockRenderer,
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 159a318

Please sign in to comment.