added proper paths for Macs. Thanks ventolin!
This commit is contained in:
18
textures.py
18
textures.py
@@ -9,11 +9,27 @@ import numpy
|
|||||||
from PIL import Image, ImageEnhance
|
from PIL import Image, ImageEnhance
|
||||||
|
|
||||||
def _get_terrain_image():
|
def _get_terrain_image():
|
||||||
|
if "darwin" in sys.platform:
|
||||||
|
# On Macs, terrain.png could lie at
|
||||||
|
# "/Applications/minecraft/terrain.png" for custom terrain. Try this
|
||||||
|
# first.
|
||||||
|
png = "/Applications/Minecraft/terrain.png"
|
||||||
|
if os.access(png, os.F_OK):
|
||||||
|
return Image.open(png)
|
||||||
|
|
||||||
|
# Paths on a Mac are a bit different
|
||||||
|
minecraftdir = os.path.join(os.environ['HOME'], "Library",
|
||||||
|
"Application Support", "minecraft")
|
||||||
|
minecraftjar = zipfile.ZipFile(os.path.join(minecraftdir, "bin", "minecraft.jar"))
|
||||||
|
textures = minecraftjar.open("terrain.png")
|
||||||
|
|
||||||
|
else:
|
||||||
if "win" in sys.platform:
|
if "win" in sys.platform:
|
||||||
minecraftdir = os.environ['APPDATA']
|
minecraftdir = os.environ['APPDATA']
|
||||||
else:
|
else:
|
||||||
minecraftdir = os.environ['HOME']
|
minecraftdir = os.environ['HOME']
|
||||||
minecraftjar = zipfile.ZipFile(os.path.join(minecraftdir, ".minecraft", "bin", "minecraft.jar"))
|
minecraftjar = zipfile.ZipFile(os.path.join(minecraftdir, ".minecraft",
|
||||||
|
"bin", "minecraft.jar"))
|
||||||
textures = minecraftjar.open("terrain.png")
|
textures = minecraftjar.open("terrain.png")
|
||||||
buffer = StringIO(textures.read())
|
buffer = StringIO(textures.read())
|
||||||
return Image.open(buffer)
|
return Image.open(buffer)
|
||||||
|
|||||||
Reference in New Issue
Block a user