Giter VIP home page Giter VIP logo

minecraft-scripting-samples's Introduction

Project

This project contains samples of @minecraft/server scripting APIs that are part of the Beta APIs experimental capability of Minecraft. For more information, see the Minecraft: Bedrock Edition Creator Documentation

Current Samples

  • ts-starter - A starter project that lets you use TypeScript, alongside a tutorial on how to use more @minecraft/server APIs.
  • ts-starter-complete-cotta - A completed version of the ts-starter tutorial, featuring the Break the Cotta simple arena game.
  • howto-gallery - A set of small code snippets that can be played back within the game.
  • build-challenge - A more complex starter script map with the ability to form teams that build structures, that can then be voted on.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

Trademarks

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.

minecraft-scripting-samples's People

Contributors

bricelam avatar devjmd avatar frgarc avatar gradddev avatar mammerla avatar microsoft-github-operations[bot] avatar microsoftopensource avatar purofle avatar sblmikedemone avatar wraithgar 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

minecraft-scripting-samples's Issues

source location

Is the scripting API open source? If so where is it's location? can MR be created? assuming they are just N-API or NAN wrappers of the underlying c/c++ implementation?

requesting invalid module version 1.4.0-beta

I was trying to run the ts-starter, I've followed each step correctly and as it is. but i'm getting this error in the content log history

[Scripting][error]-Plugin [Cotta Behavior Pack] - module [Cotta Behavior Pack - 0.0.1] requesting invalid module version [@minecraft/server - 1.4.0-beta].
Available versions:
@minecraft/server - 0.1.0
@minecraft/server - 1.0.0
@minecraft/server - 1.1.0
@minecraft/server - 1.2.0
@minecraft/server - 1.3.0-beta

My mincraft version is 1.20

Chat export

May I kindly inquire if there are additional resources available to enhance my understanding of scripting with Minecraft? I must express my appreciation for the current resource, as it has provided me with a solid foundation in the basics. However, I am eager to explore further and learn how to export in-game chat for my bot. It would be immensely helpful if you could kindly guide me in the right direction. I have already delved into the @minecraft/server modules and classes, but I am still uncertain about the necessary steps. Thank you sincerely for your assistance!

Running these scripts on a dedicated bedrock server on linux

Hi,

First, thank you so much for the great resources! I'm very excited to try to build some custom minecraft experiences for my kiddo and his friends.

This isn't an issue with the repo, but I'm new to minecraft development and I'm not sure where to go to ask this type of question.

I'm trying to get the ts-starter project running but I've run into a couple problems.

First, I've modified my gulp file to tell it that I'm running a dedicated server and have set up my paths such that when I run gulp build I can see the staterbp ending up built and copied to the correct spot.

From there I cannot figure out how to get the behavior pack to get picked up by the game. I've tried having it copied to both development_behavior_packs and also behavior_packs but I'm not seeing it in either case. I connect to my dedicated server and do not see the 'Hello starter!' printed out.

I also modified the code to reset the tickIndex counter to 0 every time it gets to 100, wondering if the printout was happening before I was able to load into my server, but alas, this didn't help either.

I've tried restarting the server and reconnecting with no luck.

Are there some settings I need to configure on my server to enable the loading of development_behavior_packs?

Thanks so much!

Jared

I have an error when I use the module "@minecraft/server-net"

I have this error:
image

However, I believe my code is correct.

here is my code:

import * as net from "@minecraft/server-net";
net.http.get("http://localhost/grush/views/index.php").then(r => {
    event.sender.tell("body:"+r.body.length);
})

normally the query should return:

<?php
$data = ["a" => "b"];
header('Content-Type: application/json; charset=utf-8');
echo json_encode($data);

return an array with key "a" and value "b"

Error: You must provide the URL of lib/mappings.wasm by calling SourceMapConsumer.initialize({ 'lib/mappings.wasm': ... }) before using SourceMapConsumer

Error: You must provide the URL of lib/mappings.wasm by calling SourceMapConsumer.initialize({ 'lib/mappings.wasm': ... }) before using SourceMapConsumer
at readWasm (D:\bedev\ts-starter-complete-cotta\node_modules\gulp-typescript\node_modules\source-map\lib\read-wasm.js:8:13)
at wasm (D:\bedev\ts-starter-complete-cotta\node_modules\gulp-typescript\node_modules\source-map\lib\wasm.js:25:16)
at D:\bedev\ts-starter-complete-cotta\node_modules\gulp-typescript\node_modules\source-map\lib\source-map-consumer.js:264:14
at process.processTicksAndRejections (node:internal/process/task_queues:95:5

Error

In the main.ts file on line 1 it said

Module '"mojang-minecraft"' has no exported member 'world'.
and does nothing when I use it in Minecraft but also has no errors.

scoreboard::addObjective method is throwing an error.

Since the minecraft 1.20.0.1 I am having this problem. I am also having this problem when trying to use Player::playSound.
Code:

import { Faction } from '../classes/factionClasses';
import { FactionExceptions } from '../system/customExceptions'
import { Player } from '../classes/playerClasses';
import { Logger } from '../system/logger';
import { world } from '@minecraft/server';


class FactionHandler {
    /**
     * Create a faction.
     * @throws {FactionExceptions.IllegalFactionName} when name validation no match.
     * @throws {FactionExceptions.PlayerAlreadyInFactionException} when plyaer already in faction.
     * @throws {FactionExceptions.DuplicateFactionException} when faction exists.
     * @param {String} factionName faction name to create.
     * @param {Player} factionLeader the player who is creating the faction.
     */
    static createFaction(factionName, factionLeader) {
        const nameValidationRegex = /^(?=.*[a-z])[a-z0-9_ ]{3,15}$/i;
        const factionInfo = {
            name: factionName,
            leader: 'leader:' + factionLeader.name + '§r',
        }

        if (!nameValidationRegex.test(factionInfo.name)) {
            throw new FactionExceptions.IllegalFactionName();
        } else if (factionLeader.belongsToAnyFaction()) {
            throw new FactionExceptions.PlayerAlreadyInFactionException();
        } else if (this.#doesFactionExist(factionInfo.name)) {
            throw new FactionExceptions.DuplicateFactionException();
        } else {
            // Create a new faction and set the creator as leader.
            try {
                const createdFaction = Faction(world.scoreboard.addObjective(factionInfo.name, factionInfo.leader));
                createdFaction.setScore(factionLeader.scoreboardIdentity, -1);
            } catch(e) {
                console.warn(e.message + ' ' + e.stack);
            }

            Logger.INFO(`The faction "${factionInfo.name}" was just created by "${factionInfo.leader}".`);
        }
    }

image

Block and BlockEvent samples rely on removed withState

Block permutations.withState() has been removed in server 1.4.0 and 1.5.0, returning in 1.6.0-beta according to the server change log.

Because of this, the two Block sample scripts are not using stable available APIs compatible with latest retail client 1.20.30 due to their reliance on setting blockstates with withState()

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.