Git Product home page Git Product logo

flying-squid's Introduction

flying-squid

NPM version Build Status Discord Gitter Irc

Create Minecraft servers with a powerful, stable, and high level JavaScript API.

Features

  • Support for Minecraft 1.8, 1.9, 1.10, 1.11, 1.12, 1.13, 1.14, 1.15 and 1.16
  • Players can see the world
  • Players see each other in-game and in tab
  • Digging
  • Placing blocks
  • Player movement
  • World generation
  • Anvil loading
  • Multi-world

Building / Running

Before running or building it is recommended that you configure the server in config/settings.json

npm install
node app.js

You can also install flying-squid globally with sudo npm install -g flying-squid and then run it with flying-squid command.

Docker

Docker allows for a higher level of isolation, compatibility and consistency. You can learn how to install Docker here.

Quick start a simple server to test out flying-squid:

docker run -p 25565:25565 prismarinejs/flying-squid

With specific configuration and a container name:

docker run -p 25565:25565 -v $(pwd)/config:/config --name my-flying-squid prismarinejs/flying-squid

docker-compose is useful to quickly launch & stop a single container with a specific configuration.

docker-compose.yaml:

version: '3.8'

services:
  flying-squid:
    image: prismarinejs/flying-squid
    volumes:
       - ${PWD}/config:/config
    ports:
      - "25565:25565"
volumes:
  flying-squid:
docker-compose -f path/to/docker-compose.yaml up

Or do it all locally:

docker build -t local-flying-squid .
docker run -p 25565:25565 local-flying-squid

or

docker-compose up

World generation

There are several modules than can be used to generate the world. The default one is called diamond-square

  • node-voxel-worldgen: a voxel world generator written in Rust, compatible with flying-squid and allows basic minecraft-like generation including caves.
  • diamond-square: a diamond square minecraft generation.
  • superflat: a superflat worldgen with configurable blocks and biome.

To install a world generation, all you have to do is npm install it and then change the generation option in settings.json.

Plugins

  • flying-squid-irc a bridge between a irc chan and the minecraft server. Currently used between our test server (rom1504.fr) and our gitter room (through the official gitter irc bridge)
  • flying-squid-schematic Flying-squid plugin providing /listSchemas and /loadSchema commands. You can add schema through a simple http api and then add them in your world by just calling /loadSchema in game.
  • flying-squid-essentials Plugin that in a future will be like Essentials of bukkit/spigot. All the basic commands that a server should have
  • squidcord a bridge between a discord channel and the minecraft server.
  • authme an auth plugin for online-mode=false servers.

Documentation

For development see the API documentation, CONTRIBUTE.md and HISTORY.md

Using as a lib

flying-squid is also a server lib. Here is a basic example of usage:

const mcServer = require('flying-squid')

mcServer.createMCServer({
  'motd': 'A Minecraft Server \nRunning flying-squid',
  'port': 25565,
  'max-players': 10,
  'online-mode': true,
  'logging': true,
  'gameMode': 1,
  'difficulty': 1,
  'worldFolder': 'world',
  'generation': {
    'name': 'diamond_square',
    'options': {
      'worldHeight': 80
    }
  },
  'kickTimeout': 10000,
  'plugins': {

  },
  'modpe': false,
  'view-distance': 10,
  'player-list-text': {
    'header': 'Flying squid',
    'footer': 'Test server'
  },
  'everybody-op': true,
  'max-entities': 100,
  'version': '1.16.5'
})

You can add server plugins and player plugins in your package, following CONTRIBUTE.md.

For further examples, see the examples page.

Contributors

  • @mhsjlw creator of flying-squid
  • @roblabla for helping out with the protocols
  • @rom1504 for massive contributions to the code
  • @demipixel
  • The PrismarineJS team for creating prismarine-chunk and node-minecraft-protocol
  • wiki.vg for documenting minecraft protocols
  • All of our other awesome contributors!

flying-squid's People

Contributors

109c avatar bitknox avatar creeplays avatar darksunlight avatar demipixel avatar dependabot-preview[bot] avatar dependabot[bot] avatar deudly avatar extremeheat avatar falcog avatar greenkeeperio-bot avatar groobledierne avatar idanho avatar jvyden avatar jwo1f avatar kaffinpx avatar karang avatar kf106 avatar kotinash avatar louis030195 avatar rom1504 avatar rom1504bot avatar rrwr avatar rtm516 avatar saiv46 avatar shin-jaeheon avatar somucheffort avatar thealan404 avatar u9g avatar zardoy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

flying-squid's Issues

The "how should plugins work" problem

https://gist.github.com/demipixel/6532869a9fb7454a5a19

Only read below once you have read the whole gist:

Using this method, we can actually HAVE core plugins. The core plugin will:

  • Emit the X_cancel event and after the X event.
  • Act as a default if no plugin intervenes

For example, blockPlace.js would do the above. Nobody should ever have to remove blockPlace.js because otherwise you're basically saying "I'm going to either handle it myself or screw over any plugin that attempts to use this event". In addition, you'll simply have to rewrite the default (if you need it).

This is why I suggest having core plugins which cannot be edited for this reason. They are important for all plugins to use. Also, how would you even manage that? If one plugin needed to use the blockPlace.js plugin and the other wanted to rewrite it, it's not like one could simply remove the blockPlace.js one. There is absolutely no reason to remove a core plugin, and hence I believe that they should be separate. This is great, because now it cleans out basic plugins from node_modules so you're left only with the plugins you need :)

The only possible case where this would not work is if a plugin needed to overwrite a default but didn't want to act as a cancel. Almost no plugin should EVER have to do that, but if for one reason or another they do, we might add a secretCancel() which allows you to stop the default without the cancelled variable being true (unless, of course, another plugin does cancel()). I can't think of any time this would happen, so I'm not too worried if it's something clunky like that.

Thanks for your time,

DemiPixel

Improving commands

  1. Make server commands work the same as player commands
    handleCommand shouldn't assume the command is coming from a player : change player.chat in it by an answer function passed in argument of handleCommand or something like that
  2. A better API : there probably should be a serv.addCommands("setBlock","(~|~?-?[0-9]*) (~|~?-?[0-9]*) (~|~?-?[0-9]*) ([0-9]{1,3}",function(...); so we can generate the result of the help command easily.

Only send chunks close to the player at login

That's what the vanilla server does : "when you login while looking at the bed rock which is 64m from you at first it's blue then only a few seconds later it loads and you can see the bedrock"

So the idea is sending the first chunks close of the player at login, not the whole column.
And then later send the chunks that are more far away.

See https://gist.github.com/rom1504/dc8d18abc1b9734926f4 for ideas into how to send chunks in a second time (the vanilla client disconnect if you send too many chunk to it too fast)

VBOs

Turn on VBOs in video settings and watch the massacre begin.

  • Chunks can sometimes disappear on the side of your view
  • Sometimes flying too high will make all chunks disappear (only about 20 blocks above the surface)
  • Sometimes chunks will not appear until you step into them
  • Sometimes chunks will randomly disappear (sort of like the second) and will randomly appear or will appear when entered.

So since this doesn't happen in vanilla, clearly we're doing something wrong, however this all seems client side (turning off VBOs, none of this happens) so I'm curious as to what we could do to fix this.

modpe should be a plugin

It doesn't work so well, and it's hard to maintain, it's probably better if it's not in the main repo.

Compiling

Hopefully many people will be using this, which means lots of people unfamiliar with node.js will be using it. Something to do this exists however there are a few things to note:

  • Look at the bottom. We might need to do special stuff with FS and account for that!
  • Cross compilation is not supported

So ideally, something like auto-squid is running but instead of pulling and then putting a server up, it pulls, runs encloseJS, puts the compiled version in a different folder, and then pushes it to ANOTHER repo (so that github is hosting it, not us).

So yeah, if we wanted to do this, the biggest issues are the file system and, more importantly, cross compilation (unless mac servers exist or people are willing to host on a mac).

The main reason I'm talking about fs is because

  • It gets used in serverPlugins.js
  • The compiled version would need to access a "plugins" folder in the same folder.

So there might be a plugin that auto-compile-squid needs to add that would run external plugins from OUTSIDE the compiled version.

TL;DR It's not an emergency or anything but it would be cool to have and useful for 50% of our users

Figure out how to provide the "real position" of entities in the API

Currently entity.position is in the fixed point format which is position*32.

Possible solutions :

  1. have both a entity.fixedPosition and a entity.position and update both when needed
  2. keep entity.position as the fixed point number and make a entity.normalPosition() method

I think 1 is probably the more practical solution, but it means we probably need a entity.setPosition method to do the updating (so we don't have to convert manually every time we need to update the position)

World generation

Interface :

Each world generation file should expose its stuff by doing :

module.exports = function(opt, seed) {
  function initialGeneration()
  {
   // return a World (can use opt and seed)
  }

  function chunkGeneration(chunkX,chunkZ)
  {
  // return a chunk
  }
  return {
    initialGeneration:initialGeneration,
    chunkGeneration:chunkGeneration
  };
}

chunkGeneration would be used after the first generation when needed.

random number generator

Please add a quick pseudo-random number sequences with a large cycle. It will be very useful to write generators landscape.

Docker

Would simplify deployment and setup

Fix dying 2 times

Currently the health is not getting set back to 20, updateHealth should be created (see login.js) and used to do that in respawn.js.
@mhsjlw is working on it

Implement PVP

Working on it...

EDIT: Scratch that, Fighting with someone works fine with no neck movement.

error in sample code

roman@station:~/games/minecraft/servers/flying-squid/examples> node basic.js
October 11th 2015, 13:59:50 [MPE]: Modpe support is not enabled, disabling injecting...
/home/roman/games/minecraft/servers/flying-squid/dist/lib/serverPlugins/world.js:18
options["generation"].options.seed = options["generation"].options.seed || M
^
TypeError: Cannot read property 'options' of undefined
at Object.inject as world
at MCServer.connect (/home/roman/games/minecraft/servers/flying-squid/dist/index.js:35:30)
at Object.createMCServer (/home/roman/games/minecraft/servers/flying-squid/dist/index.js:20:12)
at Object. (/home/roman/games/minecraft/servers/flying-squid/examples/basic.js:3:10)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
at node.js:814:3

Implement player leaving

Malformed JSON when players are logging back in, we need to start removing players from the tab menu and the player array so that they can log back in

Reddit Builds a House

The original: https://www.reddit.com/r/Minecraft/comments/3ilm3b/reddit_builds_a_house/

The idea: https://www.reddit.com/r/Minecraft/comments/3iz6fw/help_plan_reddit_builds_a_house_2/

The basic idea:

  • Empty terrain on server (at least something to build off of), ~20 slots on server
  • Player joins and has three minutes to place a block. They can edit terrain but it will only be displayed locally.
  • Use /reset (or something) to reset all blocks (removes all local blocks).
  • Use /confirm to get a confirmation message for the latest block placed (e.g. "Place block X at 5, 63, 4? Use /confirm yes/no")
  • Using /confirm yes will "place" the block and all users will see it (and it will be saved to the world). The user will be kicked with the message "Join back to spectate!"
  • If you join and have already placed a block, you will be placed in a spectator mode. If you have been on for over 60 seconds and someone is trying to join, you will be kicked

The exact "slot management" system is rough since we only have 20 slots and I'm sure a LOT more people will be coming than that, however this should give a basic idea of what I'm trying to do.

TL;DR 3 minutes to place block, local editing until /reset or /confirm, join back to spectate temporarily

I'm assuming the local place/destroy will be the hardest part of this

Plug player plugins in a server plugin + other kind of plugins

It would be better to put the code (currently in index.js) to plug the player plugins in a server plugin (say players.js or something). It would also be interesting to emit a "newPlayer" (player) server event, to allow external player plugins.

An other interesting thing about plugins would be to make some other kind of plugins, for example npc plugins which would be put at entity creation and would handle the action of the npc (/mob).
These new kind of plugins would be plugged in server plugins.

When implementing NPC plugins, make sure that it makes more sense to create npc plugins vs just implementing the action and logic of npc in a server plugin directly (I guess it depends how much code would be needed for npc)

Prevent squids from taking over

Currently when you hit a squid the server crashes.

/root/workspace/flying-squid/lib/playerPlugins/pvp.js:17
    var attackedPlayer = serv.entities[entityId].player;
                                            ^
TypeError: Cannot read property 'player' of undefined
    at attackEntity (/root/workspace/flying-squid/lib/playerPlugins/pvp.js:17:49)
    at Client.<anonymous> (/root/workspace/flying-squid/lib/playerPlugins/pvp.js:35:7)
    at Client.EventEmitter.emit (events.js:95:17)
    at Deserializer.<anonymous> (/root/workspace/flying-squid/node_modules/minecraft-   protocol/dist/client.js:149:12)
    at Deserializer.EventEmitter.emit (events.js:95:17)
    at readableAddChunk (/root/workspace/flying-squid/node_modules/minecraft- protocol/node_modules/readable-stream/lib/_stream_readable.js:195:16)
    at Deserializer.Readable.push (/root/workspace/flying-squid/node_modules/minecraft-protocol/node_modules/readable-stream/lib/_stream_readable.js:162:10)
    at Deserializer.Transform.push (/root/workspace/flying-squid/node_modules/minecraft-protocol/node_modules/readable-stream/lib/_stream_transform.js:145:32)
    at Deserializer._transform (/root/workspace/flying-squid/node_modules/minecraft-protocol/dist/transforms/serializer.js:255:14)
    at Deserializer.Transform._read (/root/workspace/flying-squid/node_modules/minecraft-    protocol/node_modules/readable-stream/lib/_stream_transform.js:184:10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.