Giter Site home page Giter Site logo

mcq's Introduction

MCQ (Minecraft Query)

Library to query anything in a minecraft world.

Examples

Find all written/writable books in the world

world := core.NewWorld("/path/to/minecraft/saves/world")
mcq.Q(world).Targets(mc.WrittenBookID, mc.WritableBookID).Find(func(result mcq.Result) {
    if bookItem, ok := result.Item.(*mc.BookItem); ok {
        switch book := bookItem.Book.(type) {
        case *mc.WrittenBook:
            fmt.Printf("WRITTEN BOOK: %s %v %v\n", result.Coord(), result.Description, book)
        case *mc.WritableBook:
            fmt.Printf("WRITABLE BOOK: %s %v %v\n", result.Coord(), result.Description, book)
        }
    }
})

Find all ShulkerBox in a region

bbox := mcq.New2DBBox(mc.Overworld, 170, 160, 266, 226)
mcq.Q(world).BBox(bbox).Targets(mc.ShulkerBoxID).Find(func(result mcq.Result) {
    if container, ok := result.Item.(mc.IContainerEntity); ok {
        fmt.Printf("SHULKER: %s %s %v\n", result.Coord(), result.Description, container)
    }
})

Find all ShulkerBox in a region where the first slot is an Apple

bbox := mcq.New2DBBox(mc.Overworld, 170, 160, 266, 226)
mcq.Q(world).BBox(bbox).Targets(mc.ShulkerBoxID).Find(func(result mcq.Result) {
    if shulkerBox, ok := result.Item.(mc.IContainerEntity); ok {
        shulkerBox.Items().Each(func(item mc.IItem) {
            if item.Slot() == 0 && item.ID() == mc.AppleID {
                fmt.Printf("Found ShulkerBox with apple in first slot at %s\n", result.Coord())
            }
        })
    }
})

Find all named items/entities

mcq.Q(world).Find(func(result mcq.Result) {
    if i, ok := result.Item.(mc.INamed); ok {
        fmt.Printf("%s %v %s\n", result.Coord(), result, i.CustomName())
    }
}, mcq.WithCustomName(true))

Find all Sign with text

mcq.Q(world).Targets(mc.SignID).Find(func(result mcq.Result) {
    if sign, ok := result.Item.(*mc.Sign); ok {
        if sign.HasText() {
            fmt.Printf("%s %v\n", result.Coord(), sign.InlineText())
        }
    }
})

Find all Diamond-ore blocks

bbox := mcq.New2DBBox(mc.Overworld, 0, 0, 100, 100)
mcq.Q(world).BBox(bbox).Targets(mc.DiamondOreID).Find(func(result mcq.Result) {
    fmt.Printf("Found diamond ore at %s\n", result.Coord())
}, mcq.WithBlocks)

mcq's People

Contributors

alaingilbert avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

kpfaulkner

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.