Git Product home page Git Product logo

Comments (6)

Qveshn avatar Qveshn commented on September 18, 2024

Hi
Could you tell me what kind of plugin are you planning? What for lights will be created? And how often are you going to destroy/create lights?

from lightapi.

drdeee avatar drdeee commented on September 18, 2024

I am planning a plugin that will allow builders to place light sources from a server.

from lightapi.

Qveshn avatar Qveshn commented on September 18, 2024

permanently?

from lightapi.

Qveshn avatar Qveshn commented on September 18, 2024

This plugin was not designed for permanent light sources. Instead of this plugin, I propose to consider the capabilities of another VarLight plugin. It not only exposes the lights in the world, but saves them in a separate world map (files are like mca)

There are some limitations with creating lights in LightAPI plugin. This plugin only sets the light at the position of the block, but does not store information about the light source. Thus, standard minecraft mechanics can destroy the generated light during the update of the blocks. For example, if you put any block next to it, then the light in the adjacent block will be recalculated and the light will be destroyed, because there is no information that there was a light source in it.
Such loss of light must be checked separately from time to time and, if destroyed, re-created.
It's like putting an opened iron trapdoor somewhere, which will remain open until another block is placed next to it. After that, the neighboring blocks will be updated and the trapdoor will be closed.

There is also a problem when placing lights next to each other. In order for the light to spread over 15 blocks around, the plugin triggers the internal mechanics of minecraft to recount the six side blocks, which will cause the destruction of the light installed in them. In other words, the plugin does not allow the lights to be placed next to each other.

from lightapi.

Qveshn avatar Qveshn commented on September 18, 2024

For example, I can bring a code that allows you to expose the light in the desired block.

import ru.beykerykt.lightapi.LightType;
import ru.beykerykt.lightapi.LightAPI;
...
void setLight(Location location, int lightLevel, LightType lightType) {
    Block block = location.getBlock();
    int oldLightLevel = lightType == LightType.BLOCK ? block.getLightFromBlocks() : block.getLightFromSky();
    if (oldLightLevel != lightLevel) {
        if (lightLevel > 0) {
            LightAPI.createLight(location, lightType, lightLevel, false);
        } else {
            LightAPI.deleteLight(location, lightType, false);
        }
        for (ChunkInfo chunkInfo : LightAPI.collectChunks(location, lightType, Math.max(lightLevel, oldLightLevel))) {
            LightAPI.updateChunk(chunkInfo, lightType);
        }
    }
}

You can experiment with this code. Put the light somewhere and then check how it disappears if you put another block next to it.

from lightapi.

drdeee avatar drdeee commented on September 18, 2024

@Qveshn Thanks for your quick reply and for pointing out VarLight, I'll suggest that to the server team.

from lightapi.

Related Issues (20)

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.