Skip to content

Commit

Permalink
Fixed: Invisible blocks when new-style texture pack is attempted.
Browse files Browse the repository at this point in the history
External texture packs disabled for now.
  • Loading branch information
codewarrior0 committed Apr 25, 2013
1 parent 17bf193 commit 0a6b999
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 120 deletions.
36 changes: 18 additions & 18 deletions mcedit.py
Expand Up @@ -398,23 +398,23 @@ def __init__(self, mcedit):
Panel.__init__(self)

self.mcedit = mcedit

def getPacks():
return ["[Default]", "[Current]"] + mcplatform.getTexturePacks()

def packChanged():
self.texturePack = self.texturePackChoice.selectedChoice
packs = getPacks()
if self.texturePack not in packs:
self.texturePack = "[Default]"
self.texturePackChoice.selectedChoice = self.texturePack
self.texturePackChoice.choices = packs

self.texturePackChoice = texturePackChoice = mceutils.ChoiceButton(getPacks(), choose=packChanged)
if self.texturePack in self.texturePackChoice.choices:
self.texturePackChoice.selectedChoice = self.texturePack

texturePackRow = albow.Row((albow.Label("Skin: "), texturePackChoice))
#
# def getPacks():
# return ["[Default]", "[Current]"] + mcplatform.getTexturePacks()
#
# def packChanged():
# self.texturePack = self.texturePackChoice.selectedChoice
# packs = getPacks()
# if self.texturePack not in packs:
# self.texturePack = "[Default]"
# self.texturePackChoice.selectedChoice = self.texturePack
# self.texturePackChoice.choices = packs
#
# self.texturePackChoice = texturePackChoice = mceutils.ChoiceButton(getPacks(), choose=packChanged)
# if self.texturePack in self.texturePackChoice.choices:
# self.texturePackChoice.selectedChoice = self.texturePack
#
# texturePackRow = albow.Row((albow.Label("Skin: "), texturePackChoice))

fieldOfViewRow = mceutils.FloatInputRow("Field of View: ",
ref=Settings.fov.propertyRef(), width=100, min=25, max=120)
Expand All @@ -440,7 +440,7 @@ def packChanged():
settingsColumn = albow.Column((fastLeavesRow,
roughGraphicsRow,
enableMouseLagRow,
texturePackRow,
# texturePackRow,
fieldOfViewRow,
targetFPSRow,
bufferLimitRow,
Expand Down
102 changes: 0 additions & 102 deletions mceutils.py
Expand Up @@ -273,111 +273,9 @@ def drawTerrainCuttingWire(box,

def loadAlphaTerrainTexture():
pngFile = None
customWaterFile = None
customLavaFile = None
grassColorFile = None
foliageColorFile = None

try:
skin = config.config.get("Settings", "MCEdit Skin")
if skin is None or skin == "[Current]":
optionsFile = os.path.join(mcplatform.minecraftDir, "options.txt")
for line in file(optionsFile):
if line.startswith("skin:"):
skin = line[5:].strip('\n')

if skin and skin != "[Default]":
print "Loading texture pack {0}...".format(skin)
try:
if skin == "Default":
pack = os.path.join(mcplatform.minecraftDir, "bin", "minecraft.jar")
print "Loading textures from minecraft.jar"
else:
pack = os.path.join(mcplatform.texturePacksDir, skin)
zf = zipfile.ZipFile(pack, "r")
pngFile = zf.open("terrain.png")
pngFile.nlSeps = []
if "custom_water_still.png" in zf.namelist():
customWaterFile = zf.open("custom_water_still.png")
if "custom_lava_still.png" in zf.namelist():
customLavaFile = zf.open("custom_lava_still.png")
if "misc/foliagecolor.png" in zf.namelist():
foliageColorFile = zf.open("misc/foliagecolor.png")
if "misc/grasscolor.png" in zf.namelist():
grassColorFile = zf.open("misc/grasscolor.png")
zf.close()

except Exception, e:
print repr(e), "while reading terrain.png from ", repr(pack)

except Exception, e:
print repr(e), "while loading texture pack info."

texW, texH, terraindata = loadPNGFile(os.path.join(directories.dataDir, "terrain.png"))

def slurpZipExt(zipextfile):
# zipextfile.read() doesn't read all available data
alldata = ""
data = zipextfile.read()
while len(data):
alldata += data
data = zipextfile.read()
return StringIO(alldata)

if pngFile is not None:
try:
texW, texH, terraindata = loadPNGData(slurpZipExt(pngFile))

except Exception, e:
print repr(e), "while loading texture pack"

if customWaterFile is not None:
s, t = pymclevel.materials.alphaMaterials.blockTextures[pymclevel.materials.alphaMaterials.Water.ID, 0, 0]
s = s * texW / 256
t = t * texH / 256

w, h, data = loadPNGData(slurpZipExt(customWaterFile))
if w == texW / 16:
# only handle the easy case for now
texdata = data[:w, :w]
terraindata[t:t + w, s:s + w] = texdata

# GL.glTexSubImage2D(GL.GL_TEXTURE_2D, 0, s, t, w, w, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, texdata)
if customLavaFile is not None:
s, t = pymclevel.materials.alphaMaterials.blockTextures[pymclevel.materials.alphaMaterials.Lava.ID, 0, 0]
s = s * texW / 256
t = t * texH / 256

w, h, data = loadPNGData(slurpZipExt(customLavaFile))
if w == texW / 16:
# only handle the easy case for now
texdata = data[:w, :w]
terraindata[t:t + w, s:s + w] = texdata

# GL.glTexSubImage2D(GL.GL_TEXTURE_2D, 0, s, t, w, w, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, texdata)

from renderer import LeafBlockRenderer
from renderer import GenericBlockRenderer
if foliageColorFile is not None:
w, h, data = loadPNGData(slurpZipExt(foliageColorFile))
color = data[77, 55, :3]
pymclevel.materials.alphaMaterials.flatColors[17, 0, :3] = color # xxxxxxx

color = [c / 255.0 for c in color]
LeafBlockRenderer.leafColor = color
else:
LeafBlockRenderer.leafColor = LeafBlockRenderer.leafColorDefault

if grassColorFile is not None:
w, h, data = loadPNGData(slurpZipExt(grassColorFile))
color = data[77, 55, :3]
pymclevel.materials.alphaMaterials.flatColors[2, 0, :3] = color # xxxxxxx
color = [c / 255.0 for c in color]

GenericBlockRenderer.grassColor = color
else:
GenericBlockRenderer.grassColor = GenericBlockRenderer.grassColorDefault

def _loadFunc():
loadTextureFunc(texW, texH, terraindata)

Expand Down

0 comments on commit 0a6b999

Please sign in to comment.