PistonDevelopers / hematite

A simple Minecraft written in Rust with the Piston game engine
http://hematite.piston.rs/
MIT License
1.86k stars 105 forks source link

Windows build launches and immediately exits. #177

Closed AaronFriel closed 8 years ago

AaronFriel commented 9 years ago

I built Hematite for Windows, and placed the SDL libraries in my C:\Rust\bin\rustlib\x86_64-pc-windows-gnu\lib, and it builds a hematite.exe, but launching it does nothing.

I'm having some difficulty understanding the Readme as well, which has the OSX instructions as follows:

Here are my points of confusion:

  1. Which assets folder? The one inside the git repo .\hematite, or the one inside the final build path, i.e.: .\hematite\target\release\...\assets?
  2. The instructions say to copy the <version>.jar file to assets and rename it to <version>.zip. Does the name <version>.zip have any consequence, or is it discarded after use?
  3. The instructions say to extract the jar. That means <version>.zip, right?
  4. The <version>.zip does not have a minecraft folder, except it does underneath a few other folders. Is that the folder you're referring to?
  5. Now, should I have assets\minecraft\.. or assets\.. after I extract the minecraft folder? i.e.: do I want a minecraft folder in my assets folder, or do I want the contents of the minecraft folder in my assets folder?
  6. Why don't I get any output on stdout when I run hematite? Even when I don't pass in a world path, it just exits immediately.

Unfortunately it looks like something broke between my desktop and my laptop, as on my laptop I'm now unable to build hematite as time v0.1.14 fails to build.

eddyb commented 9 years ago

I blame @bvssvni for the awkward instructions. There is no need to rename the jar to .zip, just copy/extract the assets/minecraft folder to assets, the one next to the src folder. I can't remember if the code is smart enough to find it on a release build.

toqueteos commented 9 years ago

Let me update to latest nightlies and try. It should work perfectly.

eddyb commented 9 years ago

Oops, mobile + github => accidents. I should also mention that we could do the decompression ourselves, but the obvious method (run unzip) only works "by default" on Linux and maybe OSX. We could do in-memory decompression, as we have access to (rudimentary) inflate (the image crate has zlib bindings, too, I think), and all we'd need would be an implementation of the PK zip directory/whatever.

AaronFriel commented 9 years ago

So I have, for example:

.\hematite\assets\acacia_door.json
.\hematite\assets\acacia_double_slab.json
.\hematite\assets\acacia_fence.json
.\hematite\assets\acacia_fence_gate.json
.\hematite\assets\acacia_leaves.json
.\hematite\assets\acacia_log.json
.\hematite\assets\acacia_planks.json
.\hematite\assets\acacia_sapling.json
.\hematite\assets\acacia_slab.json
.\hematite\assets\acacia_stairs.json
.\hematite\assets\activator_rail.json
.\hematite\assets\allium.json
.\hematite\assets\andesite.json
.\hematite\assets\anvil.json
.\hematite\assets\beacon.json
.\hematite\assets\bed.json
.\hematite\assets\bedrock.json
.\hematite\assets\birch_door.json
.\hematite\assets\birch_double_slab.json
.\hematite\assets\birch_fence.json
.\hematite\assets\birch_fence_gate.json
.\hematite\assets\birch_leaves.json
.\hematite\assets\birch_log.json
.\hematite\assets\birch_planks.json
.\hematite\assets\birch_sapling.json

That hematite folder is the one cloned from git. I'm doing cargo build --release again.

toqueteos commented 9 years ago

Confirmed it works.

Instructions:

  1. Download and install Rust latest nightlies.
  2. Setup Minecraft to download/play version 1.8.1, that's already explained.
  3. Go to %appdata%\.minecraft\versions\1.8.1 folder.
  4. Copy 1.8.1.jar to your desktop or any place you want.
  5. Rename the jar to zip.
  6. Extract zip somewhere.
  7. Open extracted folder.
  8. Take assets/minecraft folder and copy it inside $HEMATITE_ROOT/assets. Or just tell it to add all contents of assets (zip file) to the other assets ($HEMATITE_ROOT).
  9. Ensure your SDL2.dll is on C:\Rust\bin\rustlib\x86_64-pc-windows-gnu\lib and also on your $HEMATITE_ROOT.
  10. Run cargo run --release "path\to\world"
  11. Compiling...
  12. Enjoy!

EDIT: Issues? Annihilate repo, clone repo then cargo update and continue with step 8.

AaronFriel commented 9 years ago

So it compiles and I get a hematite.exe but it immediately exits.

I used procmon to analyze it, and I see it load the DLLs that I would expect it to, C:\Rust\bin\std-4e7c5e5c.dll and so on, then it queries for system libraries, then it exits with code -1073741515 or 0x3FFFFECB. Some Google searches suggest that means a dependency is missing?

toqueteos commented 9 years ago

@AaronFriel It may be SDL2.dll missing, try copying it to hematite root too and repeat step 9.

EDIT: Yup, this is the thing, SDL2 is loaded dynamically... Duh, updating steps.

toqueteos commented 9 years ago

@AaronFriel Is it working now?

eddyb commented 9 years ago

@AaronFriel You seem to have copied individual files without preserving directory structure.

../hematite.orig/assets/minecraft/
../hematite.orig/assets/minecraft/blockstates
../hematite.orig/assets/minecraft/blockstates/acacia_door.json
../hematite.orig/assets/minecraft/blockstates/acacia_double_slab.json
../hematite.orig/assets/minecraft/blockstates/acacia_fence.json
../hematite.orig/assets/minecraft/blockstates/acacia_fence_gate.json

where ../hematite.orig is a checkout of hematite I had laying around.

eddyb commented 9 years ago

@toqueteos couldn't we say "open .jar file with some archiving tool"? Almost everything I've seen lets you extract part of an archive or even drag&drop/copy-paste to achieve the same effect. I could swear that even the zip support in windows lets you do that.

toqueteos commented 9 years ago

@eddyb That should do that may still confuse some people. Send a PR with new wording and let's see what happens.

toqueteos commented 9 years ago

@AaronFriel ping, would like to know if problem still persists.

toqueteos commented 9 years ago

@AaronFriel ping, problem persists?

AaronFriel commented 9 years ago

Sorry @toqueteos, Life keeps interceding. The directory structure issue was due to me screwing up my path naively in powershell:

Get-ChildItem .\assets -Recurse | Select { ".\hematite\assets\"+$_.Name } | Select -First 50

So, here's the actual output of the full path, note that it shows files and folders:

Projects\hematite\assets\minecraft
Projects\hematite\assets\texture.png
Projects\hematite\assets\minecraft\blockstates
Projects\hematite\assets\minecraft\font
Projects\hematite\assets\minecraft\lang
Projects\hematite\assets\minecraft\models
Projects\hematite\assets\minecraft\shaders
Projects\hematite\assets\minecraft\texts
Projects\hematite\assets\minecraft\textures
Projects\hematite\assets\minecraft\blockstates\acacia_door.json
Projects\hematite\assets\minecraft\blockstates\acacia_double_slab.json
Projects\hematite\assets\minecraft\blockstates\acacia_fence.json
Projects\hematite\assets\minecraft\blockstates\acacia_fence_gate.json
Projects\hematite\assets\minecraft\blockstates\acacia_leaves.json
Projects\hematite\assets\minecraft\blockstates\acacia_log.json
Projects\hematite\assets\minecraft\blockstates\acacia_planks.json
Projects\hematite\assets\minecraft\blockstates\acacia_sapling.json
Projects\hematite\assets\minecraft\blockstates\acacia_slab.json
Projects\hematite\assets\minecraft\blockstates\acacia_stairs.json
Projects\hematite\assets\minecraft\blockstates\activator_rail.json

Here's what I get:

cargo run --release .\world\SkyLands --verbose
       Fresh shader_version v0.0.1 (https://github.com/PistonDevelopers/shader_version#71300bf7)
       Fresh regex v0.1.10
       Fresh gfx_macros v0.1.0 (https://github.com/gfx-rs/gfx-rs#cb47f60a)
       Fresh libc v0.1.0
       Fresh clock_ticks v0.0.2 (https://github.com/tomaka/clock_ticks#75347002)
       Fresh gl_common v0.0.3 (https://github.com/bjz/gl-rs.git#79933ec9)
       Fresh current v0.0.5 (https://github.com/PistonDevelopers/current#749a98a3)
       Fresh bitflags v0.1.0
       Fresh khronos_api v0.0.5 (https://github.com/bjz/gl-rs.git#79933ec9)
       Fresh quack v0.0.2 (https://github.com/PistonDevelopers/quack#d5b452f0)
       Fresh gcc v0.1.6
       Fresh pkg-config v0.1.6
       Fresh piston-texture v0.0.1 (https://github.com/PistonDevelopers/texture#0380876c)
       Fresh vecmath v0.0.3 (https://github.com/PistonDevelopers/vecmath#3080ca14)
       Fresh rustc-serialize v0.2.9
       Fresh log v0.1.10
       Fresh xml-rs v0.1.15
       Fresh pistoncore-event_loop v0.0.4 (https://github.com/pistondevelopers/event_loop#05766fd2)
       Fresh pistoncore-input v0.0.5 (https://github.com/PistonDevelopers/input#ce3ba43c)
       Fresh num v0.1.10 (https://github.com/rust-lang/num#c05cd530)
       Fresh gl_generator v0.0.12 (https://github.com/bjz/gl-rs.git#79933ec9)
       Fresh pistoncore-window v0.0.3 (https://github.com/pistondevelopers/window#1ace3fdd)
       Fresh image v0.2.0-alpha.7 (https://github.com/PistonDevelopers/image#98f866aa)
       Fresh time v0.1.14
       Fresh sdl2-sys v0.0.16 (https://github.com/AngryLawyer/rust-sdl2#1b29c7a1)
       Fresh pistoncore-event v0.0.5 (https://github.com/PistonDevelopers/event#9e6cc2e7)
       Fresh fps_counter v0.0.0 (https://github.com/PistonDevelopers/fps_counter#6e8bb78b)
       Fresh sdl2 v0.0.18 (https://github.com/AngryLawyer/rust-sdl2#1b29c7a1)
       Fresh piston3d-cam v0.0.1 (https://github.com/PistonDevelopers/cam#620ac5b1)
       Fresh gfx_gl v0.1.0 (https://github.com/gfx-rs/gfx_gl.git#c944aa62)
       Fresh gl v0.0.6 (https://github.com/bjz/gl-rs.git#79933ec9)
       Fresh device v0.1.0 (https://github.com/gfx-rs/gfx-rs#cb47f60a)
       Fresh pistoncore-sdl2_window v0.0.0 (https://github.com/PistonDevelopers/sdl2_window#80f6392c)
       Fresh render v0.1.0 (https://github.com/gfx-rs/gfx-rs#cb47f60a)
       Fresh gfx v0.1.0 (https://github.com/gfx-rs/gfx-rs#cb47f60a)
       Fresh piston-gfx_texture v0.0.1 (https://github.com/PistonDevelopers/gfx_texture#2a77c087)
       Fresh piston3d-gfx_voxel v0.0.1 (https://github.com/PistonDevelopers/gfx_voxel#01d9372d)
       Fresh hematite v0.0.0 (file:///C:/Users/Aaron/OneDrive/Documents/Projects/hematite)
     Running `target\release\hematite .\world\SkyLands`
Process didn't exit successfully: `target\release\hematite .\world\SkyLands` (status=3221225781)

Using the full path for .\world\Skylands does not fix it. The contents of .\world\Skylands are (only the first level, files and folders shown):

##MCEDIT.TEMP##
data
DIM-1
DIM1
playerdata
players
region
stats
level.dat
level.dat_mcr
level.dat_old
session.lock
AaronFriel commented 9 years ago

If I put SDL2.dll in the same folder as hematite.exe, I actually get further:

.\target\release\hematite.exe C:\users\Aaron\OneDrive\Documents\Projects\hematite\world\SkyLands
HashMap {"Data": HashMap {"raining": 0b, "rainTime": 8995i, "allowCommands": 0b,
"generatorName": "default", "LevelName": "Skylands", "generatorOptions": "",
"thunderTime": 149912i, "Player": HashMap {"foodLevel": 20i, "OnGround": 1b,
"foodTickTimer": 0i, "Pos": DoubleList([-390.465445, 76, 845.02408]),
"FallDistance": 0.0f, "EnderItems": CompoundList([]), "Air": 300s,
"foodExhaustionLevel": 0.0f, "playerGameType": 0i, "AbsorptionAmount": 0.0f,
"HealF": 20.0f, "Motion": DoubleList([0, -0.0784, 0]), "XpTotal": 0i,
"Dimension": 0i, "SelectedItemSlot": 0i, "XpLevel": 0i, "DeathTime": 0s,
"UUIDMost": -7517610300441017865L, "Attributes": CompoundList([HashMap {"Name":
"generic.maxHealth", "Base": 20.0}, HashMap {"Name":
"generic.knockbackResistance", "Base": 0.0}, HashMap {"Base": 0.1, "Name":
"generic.movementSpeed"}, HashMap {"Base": 1.0, "Name":
"generic.attackDamage"}]), "Sleeping": 0b, "Inventory": CompoundList([]),
"Rotation": FloatList([-358.799316, 0.450013]), "Score": 0i, "XpP": 0.0f,
"AttackTime": 0s, "UUIDLeast": -5220355947007662411L, "HurtTime": 0s,
"Invulnerable": 0b, "foodSaturationLevel": 5.0f, "abilities": HashMap
{"walkSpeed": 0.1f, "mayBuild": 1b, "flySpeed": 0.1f, "invulnerable": 0b,
"mayfly": 0b, "instabuild": 0b, "flying": 0b}, "PortalCooldown": 0i, "Health":
20s, "SleepTimer": 0s, "Fire": -20s}, "GameType": 0i, "SizeOnDisk": 41470301L,
"generatorVersion": 1i, "DayTime": 10959L, "GameRules": HashMap {"doMobLoot":
"true", "commandBlockOutput": "true", "doFireTick": "true",
"naturalRegeneration": "true", "doDaylightCycle": "true", "mobGriefing": "true",
"doTileDrops": "true", "doMobSpawning": "true", "keepInventory": "false"},
"SpawnX": -391i, "Time": 154646L, "LastPlayed": 1400564574811L, "MapFeatures":
1b, "initialized": 1b, "version": 19133i, "SpawnY": 78i, "SpawnZ": 845i,
"thundering": 0b, "RandomSeed": 2410989659L, "hardcore": 0b}}

Then it crashes with no messages or prompts.

toqueteos commented 9 years ago

@AaronFriel Sorry for the delay, nightlies changes broke hematite.

It now builds again with latest nightlies so.. would you mind retrying again please?

toqueteos commented 9 years ago

Ping. Just updated repo, it's compiling but you may get weird results as in #187

toqueteos commented 9 years ago

Could you please retry with current nightlies and latest commits?

mattico commented 9 years ago

The takeaway from this issue for me is that using hematite is a little tedious right now. This isn't a huge issue for right now since hematite is tech demo status, but it also doesn't seem too difficult to fix. Wouldn't it be ideal to have hematite find the minecraft data, and unzip it (perhaps at runtime) rather than doing it manually?

toqueteos commented 9 years ago

@mattico What part is tedious? You just have to copy SDL2.dll and the jar folder, once.

mattico commented 9 years ago

@toqueteos I found the 13 step process enumerated above to be a bit tedious. Granted, half of that is within the minecraft launcher and can't really be avoided, but it wouldn't be overly difficult to just have hematite open the jar itself. Ideally the entire process would be:

  1. Get correct jar in minecraft launcher
  2. Make a new world
  3. cargo run --release -world new_world

90% of the time the .minecraft folder will be in one of three places:

OS Path
Windows %appdata%.minecraft
Linux ~/.minecraft
Mac OS X ~/Library/Application Support/minecraft

so just the world name should suffice. None of these things are a big deal, of course, but it bothered me a little. I'd be willing to make a PR for this, but it's probably not a big enough deal to warrant adding a zip library dependency.

tl;dr: none of it :P

bvssvni commented 9 years ago

@mattico That's a good idea. Could be a small library handling this part, and give an error message if it doesn't find the path.

eddyb commented 9 years ago

Zip handling is actually pretty easy (just a collection of deflated files) - though it would be nice to shell out to unzip but I have no idea how that would work on windows.

toqueteos commented 9 years ago

@eddyb There's https://crates.io/crates/zip I'm prototyping something for this right now. EDIT: Also https://github.com/slackito/zip

eddyb commented 9 years ago

@toqueteos That looks pretty much exactly like what I would expect from a Rust implementation, great find!

toqueteos commented 9 years ago

Here's a working version: https://gist.github.com/toqueteos/e2e2921d4f9e639b0eec (macosx, linux and windows). I wasn't sure if cfg(linux) would work for macosx or not. Apparently cfg(target_os = "win32") doesn't work but cfg(windows) does; Is there a win64 directive?

@eddyb It has its quirks.. (file.name() fucks everything because of litetime) but got it working.

EDIT: @mattico Could you give it a try to this snippet?

eddyb commented 9 years ago

@toqueteos ~ won't work, that's a shell thing, you need to grab $HOME using std::env (not env!, that's compile-time) - I wonder if that's available on windows - actually, nvm, I don't think is %HOME% is %APPDATA%, it's more likely C:\Users\name.

philippTheCat commented 9 years ago

this discussion seems to have gone a bit offtopic?

I suggest creating a new issue for it.

toqueteos commented 9 years ago

What is wrong with $HOME at compile-time?

mattico commented 9 years ago

@pharno yep, that seems to be my fault... I'll make an issue to consolidate this discussion.

@toqueteos Yep, that works.

mattico commented 9 years ago

Let's move this discussion over to #209

mattico commented 8 years ago

I'm closing this, since the original problem has been mitigated by #210 and better instructions.