Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.7.10] Negative Light Level


Velken Iakov
 Share

Recommended Posts

I'm trying to create a block that REDUCES the light level around him.

It is the Impure Potatium Block in this git: https://github.com/Velken/PotatiumCraft

Is that even possible to create that effect with the current forge?

Creating Potatium Craft, please wait.

For a better (and yet poor explanation of my WIP mod, go to: Potatium Craft Overview )

Link to comment
Share on other sites

I'm trying to create a block that REDUCES the light level around him.

It is the Impure Potatium Block in this git: https://github.com/Velken/PotatiumCraft

Is that even possible to create that effect with the current forge?

 

I wanted to do this too a couple days ago and after some research it looked like negative light levels aren't normally possible in Minecraft. I'm not sure if you can do it another way but I've seen a negative light effect achieved by changing gamma levels but I don't know if Forge can even use that.

Link to comment
Share on other sites

You can set the light level for (air) blocks using:

worldObj.setLightFor(EnumSkyBlock.BLOCK, pos, LightLevel)
worldObj.setLightFor(EnumSkyBlock.SKY, pos, LightLevel)

 

BLOCK creates yellow-ish light

SKY creates blue-ish light

 

You would have to do this constantly to prevent newly placed torches from stopping the effect.

You could also calculate the SKY and BLOCK light from the light levels around the anti torch.

You can get those values with:

entityItem.worldObj.getLightFor(EnumSkyBlock, pos)

 

It would also be better to check for changes before updating the light in such a large area since it is very resource intensive.

 

EDIT: If you want the effect to be just optical do it client only. When you do it on the server it will also change mob spawn behavior.

PM's regarding modding questions should belong in the Modder Support sub-forum and won't be answered.

Link to comment
Share on other sites

If you want the effect to be just optical do it client only. When you do it on the server it will also change mob spawn behavior.

I want it to be on the server, but some research made me found that it would cause a lot of lag and probally a lot of crashes.

Creating Potatium Craft, please wait.

For a better (and yet poor explanation of my WIP mod, go to: Potatium Craft Overview )

Link to comment
Share on other sites

It should not be too resource intensive as long as the change only occurs once and not constantly. Other mods do it all the time. There are many examples of light sources that spread further out. (Factorisation Wrathlamp / Thaumcraft Arcane Lamp etc.)

You can do this with other light levels too...

And there wont be any crashes as long as you mind the y height limit. (No light Changes underneath or on top of the world as there is no light there)

PM's regarding modding questions should belong in the Modder Support sub-forum and won't be answered.

Link to comment
Share on other sites

Moving light sources are another deal, as minecraft takes a lot of time updating light.

I have a throwable light source in my mod and actually did it without modifying Vanilla. (Not as smooth though)

PM's regarding modding questions should belong in the Modder Support sub-forum and won't be answered.

Link to comment
Share on other sites

Moving light sources are another deal, as minecraft takes a lot of time updating light.

I have a throwable light source in my mod and actually did it without modifying Vanilla. (Not as smooth though)

I my mod I have a block that I want to every tick check for light in the edge of it radius, them reduce 2 light levels every radius, untill reach 0, then, keep 0 in inner radius, if there are any.

I´m making a new github repository for 1.8 version, soon I post the link. Any one who could help with the "negative light" coding part would made me really glad and recieve credits at the mod.

Creating Potatium Craft, please wait.

For a better (and yet poor explanation of my WIP mod, go to: Potatium Craft Overview )

Link to comment
Share on other sites

I had a need where I wanted certain dimensions to look really dark.  After playing with the light levels, I went another route.  I took control of the brightness level on the client and when in that dimension dimmed it so that the world seemed really dark and creepy.  Could do the same thing by looking for being near a block and doing it.

 

From your description, I don't think that is what you are after, but thought I would offer it up as another option.

Long time Bukkit & Forge Programmer

Happy to try and help

Link to comment
Share on other sites

I had a need where I wanted certain dimensions to look really dark.  After playing with the light levels, I went another route.  I took control of the brightness level on the client and when in that dimension dimmed it so that the world seemed really dark and creepy.  Could do the same thing by looking for being near a block and doing it.

 

From your description, I don't think that is what you are after, but thought I would offer it up as another option.

I want to the game know that is dark in there, so mobs can spawn and etc. If I were to make it only visual, it would be a lot easier.

Creating Potatium Craft, please wait.

For a better (and yet poor explanation of my WIP mod, go to: Potatium Craft Overview )

Link to comment
Share on other sites

I've been away for about 10 months from minecraft programming so my memory is a bit filled up with Arma 2 / Dayz code references, so forgive me if I lead you astray.

 

I am traveling to the end of the week, so I can't access my setup, but I know for that same custom dimension that I mentioned, I changed the rules for what light level mobs spawned in.  Would be simple to do a check for proximity to a block to do that.  In my case, it was just a creeper world, so nothing burned up in sunlight. 

 

That probably won't work for you.

Long time Bukkit & Forge Programmer

Happy to try and help

Link to comment
Share on other sites

I've been away for about 10 months from minecraft programming so my memory is a bit filled up with Arma 2 / Dayz code references, so forgive me if I lead you astray.

 

I am traveling to the end of the week, so I can't access my setup, but I know for that same custom dimension that I mentioned, I changed the rules for what light level mobs spawned in.  Would be simple to do a check for proximity to a block to do that.  In my case, it was just a creeper world, so nothing burned up in sunlight. 

 

That probably won't work for you.

I've been for moer than one year without even toutching Java :v My mind is filled with GECK for FoNV.

The mob spawning would be one way to work around, but other mods may have feaures that need a dark place (Ex: Cursed Earth don't spawn <buffed> mobs if there is light). The Impure Potatium Block (the one in my mod I want to have the  "negative light") would reduce the light level accodirng to one of the two designs (probally the bottom one, that reduces 2 levels per radius), allowing the Cursed Earth to spawn <buffed> mobs.

Creating Potatium Craft, please wait.

For a better (and yet poor explanation of my WIP mod, go to: Potatium Craft Overview )

Link to comment
Share on other sites

Here is some code that should, when placed in the update function in a tileentity make the area around it pitch black.

for (int x = xPos-5; x < xPos + 5; x++) {
    for (int y = xPos-5; y < yPos + 5; y++) {
        for (int z = xPos-5; z < zPos + 5; z++) {
            BlockPos pos = new BlockPos(xPos, yPos, zPos);
            worldObj.setLightFor(EnumSkyBlock.BLOCK, pos, LightLevel);
            worldObj.setLightFor(EnumSkyBlock.SKY, pos, LightLevel);
        }
    }
}

 

This should also make mobs spawn.

 

Sorry if this throws any errors. I haven't tested this yet.

 

Use the methods I described earlier to optimize it for performance and or change its shape.

 

EDIT: You dont even need a tileentity. Just coordinates and a world Object

PM's regarding modding questions should belong in the Modder Support sub-forum and won't be answered.

Link to comment
Share on other sites

Here is some code that should, when placed in the update function in a tileentity make the area around it pitch black.

for (int x = xPos-5; x < xPos + 5; x++) {
    for (int y = xPos-5; y < yPos + 5; y++) {
        for (int z = xPos-5; z < zPos + 5; z++) {
            BlockPos pos = new BlockPos(xPos, yPos, zPos);
            worldObj.setLightFor(EnumSkyBlock.BLOCK, pos, LightLevel);
            worldObj.setLightFor(EnumSkyBlock.SKY, pos, LightLevel);
        }
    }
}

 

This should also make mobs spawn.

 

Sorry if this throws any errors. I haven't tested this yet.

 

Use the methods I described earlier to optimize it for performance and or change its shape.

 

EDIT: You dont even need a tileentity. Just coordinates and a world Object

 

Thank you Busti, I wil give it a try. I'll be sure to credit you c:

Creating Potatium Craft, please wait.

For a better (and yet poor explanation of my WIP mod, go to: Potatium Craft Overview )

Link to comment
Share on other sites

Busti,

question for you on that.

 

How long will it hold onto the value that you set?  I think I tried it once before and it hung onto it for good.  How do you reset to normal?

Long time Bukkit & Forge Programmer

Happy to try and help

Link to comment
Share on other sites

When another block that gives of light gets placed, Minecraft updates the light around it, and resetting the light values set from

worldObj.setLightFor()

.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Link to comment
Share on other sites

Busti,

question for you on that.

 

How long will it hold onto the value that you set?  I think I tried it once before and it hung onto it for good.  How do you reset to normal?

 

It will stay that way until an update occurs. This might be a newly placed light source which will actually update the whole lit space around it, but also a block which will only update the spaces around it. But it might cause a chain reaction which will update the whole area. The light Errors we can mostly see in newly spawned ravines work that way.

In order to minimize the lag caused by this you should check if anything has changed before making the area dark again. (Try to minimize the call number of setLightFor() and you will be fine.)

Also update the changed blocks light level with worldObj.checkLight(pos) * when the block was destroyed in order to get back to normal.

 

 

* This is a 1.8 function the 1.7 one has a different name and uses coordinates. Just search for "light" in the world object

PM's regarding modding questions should belong in the Modder Support sub-forum and won't be answered.

Link to comment
Share on other sites

I agree that the light updating can cause a lot of processing slowdown, even when simply placing a regular block if that block is high in the sky. I have a mod where you can spawn a castle in the sky and it was extremely slow. After playing with placing it at different heights and then also playing with disabling the light updates I found that it was the lighting update causing serious lag. My work around in that case was to disable updates except for every occasional block placed (since I knew I was going to spawn a bunch).

 

Anyway, my point is that you would have to handle the automatic updates that happen after a block changes, in addition to just the movement of the torch.

 

And also I confirm that unfortunately the simple way to do the moving torch (i.e. placing invisible light-emitting block as you move) will probably cause lag.  However, if you don't mind it being a bit inconsistent, you might get away with doing it occasionally. Like if you time how long it takes to update you can just update every so many ticks. If a person is moving quickly it might create a flickery effect but that might be okay for a torch, and once they stop it would catch up fairly quickly.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

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.

Guest
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.

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.