Jump to content

Refresh Block Light ??


Recommended Posts

Hello, how I can update the current light level?...This is my code:




    public void NearUraniumEvent(PlayerEvent event) {
        int blockX = event.entityPlayer.getPosition().getX();
        int blockY = event.entityPlayer.getPosition().down().getY();
        int blockZ = event.entityPlayer.getPosition().getZ();
        BlockPos pos = new BlockPos(blockX, blockY, blockZ);
        Block block = event.entityPlayer.worldObj.getBlockState(pos).getBlock();
        if(block == NukeMod.uranium_grass) {
            System.out.println("Uranium_grass down!");
        }else {
        int light = event.entityPlayer.worldObj.getBlockState(pos).getBlock().getLightValue();
        System.out.println("Light: " + light);



The light value changes correctly (There is the print in console...), but I don't know hoe to refresh the block :( Help me please.


Link to comment
Share on other sites

that you cannot, is one thing.


first, let me explain what you tried to do. (later we'll see what you may have wanted to do.)

getBlock() returns a Block - but not an individual instance (as seen by player). object that you have there represents all blocks in the world of the same type (including variations, for example wooden log orientation and before 1.13 wood types). now if you change its hardness, resistance, light level (if you manage to), inside the game that would affect ALL blocks of the same type, anywhere in the world. in other words, not what you want. i hope.



but what is it that you want to do? different blockstates of the same block can have different light intensities.

if that is what you want, just do SetBlockState() to change your block to the correct/new state. for the last parameter put 3 (or was it 11? can't remember. let's go with 3), one of those two flags (inside "3") tells the game to update what the players see).

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

By using this site, you agree to our Terms of Use.