Skip to content

Commit

Permalink
Merge pull request #37 from voxel/indexhtml
Browse files Browse the repository at this point in the history
Add bundled index.html for wsmc/Java. Closes GH-33
  • Loading branch information
deathcap committed Feb 9, 2016
2 parents 85a2593 + 88a255c commit b82805b
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 79 deletions.
4 changes: 0 additions & 4 deletions app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ const main = function() {
'voxel-wool': require('voxel-wool'),
'voxel-pumpkin': require('voxel-pumpkin'),
'voxel-blockdata': require('voxel-blockdata'),
'./inert-blocks': require('./inert-blocks'),
'./inert-items': require('./inert-items'),
'voxel-decorative': require('voxel-decorative'),
'voxel-land': require('voxel-land'),
'voxel-flatland': require('voxel-flatland'),
Expand Down Expand Up @@ -120,8 +118,6 @@ const main = function() {
'voxel-wool': {},
'voxel-pumpkin': {},

'./inert-blocks': {}, // misc inanimate opaque solid blocks
'./inert-items': {},
'voxel-decorative': {},
//'voxel-land': {registerBlocks: false},
'voxel-flatland': {block: 'missing'},
Expand Down
15 changes: 15 additions & 0 deletions app/bundled-index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE HTML>
<html>
<head>
<title>voxel-clientmc</title>
<style>
body {
background-color: lightgray;
}
</style>
</head>
<body>
<a href="https://github.com/voxel/voxel-clientmc"><img style="position: absolute; top: 0; left: 0; border: 0;" src="https://camo.githubusercontent.com/121cd7cbdc3e4855075ea8b558508b91ac463ac2/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f6c6566745f677265656e5f3030373230302e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_left_green_007200.png"></a>
<script src="bundle.js"></script>
</body>
</html>
32 changes: 0 additions & 32 deletions app/inert-blocks.js

This file was deleted.

33 changes: 0 additions & 33 deletions app/inert-items.js

This file was deleted.

1 change: 1 addition & 0 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ checkout:
- npm install
- (cd app && npm install)
- ./app/node_modules/.bin/browserify app/app.js > app/wsmc/src/main/resources/www/bundle.js
- cp ./app/bundled-index.html app/wsmc/src/main/resources/www/index.html
# build wsmc/Java with the bundled voxel-clientmc
- (cd app/wsmc && mvn package)

Expand Down
35 changes: 25 additions & 10 deletions clientmc.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,37 @@ class ClientMC extends EventEmitter
this.enable();
}


enable() {
// only begin connecting to server after voxel-engine is initialized,
// Register our own blocks and items which aren't provided by other more specialized plugins
const inertBlockProps = mcData.inertBlockProps;
Object.keys(inertBlockProps).forEach((name) => {
const props = inertBlockProps[name];

this.registry.registerBlock(name, props);
});

const inertItemProps = mcData.inertItemProps;
Object.keys(inertItemProps).forEach((name) => {
const props = inertItemProps[name];

this.registry.registerItem(name, props);
});

// Begin connecting to server after voxel-engine is initialized,
// since it shows chunks (game.showChunk) which requires engine initialization,
// but plugins are "enabled" before the engine fully is
this.game.on('engine-init', this.connectServer.bind(this));
}

disable() {
this.log('voxel-clientmc disabling');
this.game.voxels.removeListener('missingChunk', this.missingChunk);
this.game.plugins.get('voxel-console').widget.removeListener('input', this.onConsoleInput);
this.ws.end();
if (this.clearPositionUpdateTimer) this.clearPositionUpdateTimer();
// TODO: unregister inert items/blocks
}

// TODO: refactor further into modules
connectServer() {
this.log('voxel-clientmc connecting...');
Expand Down Expand Up @@ -160,12 +183,4 @@ class ClientMC extends EventEmitter

this.emit('connectServer');
}

disable() {
this.log('voxel-clientmc disabling');
this.game.voxels.removeListener('missingChunk', this.missingChunk);
this.game.plugins.get('voxel-console').widget.removeListener('input', this.onConsoleInput);
this.ws.end();
if (this.clearPositionUpdateTimer) this.clearPositionUpdateTimer();
}
}

0 comments on commit b82805b

Please sign in to comment.