Jump to content

Recommended Posts

Posted

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.

Posted

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.

Posted

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 )

Posted

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.

Posted

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.

Posted

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 )

Posted

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

Posted

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 )

Posted

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

Posted

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 )

Posted

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.

Posted

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 )

Posted

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

Posted

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/

Posted

Another odd question that isn't really on topic.

 

How are folks getting the 'Forge Modder' below their name?

Long time Bukkit & Forge Programmer

Happy to try and help

Posted

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.

Posted

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/

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

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • that happens every time I enter a new dimension.
    • This is the last line before the crash: [ebwizardry]: Synchronising spell emitters for PixelTraveler But I have no idea what this means
    • What in particular? I barely used that mod this time around, and it's never been a problem in the past.
    • Im trying to build my mod using shade since i use the luaj library however i keep getting this error Reason: Task ':reobfJar' uses this output of task ':shadowJar' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. So i try adding reobfJar.dependsOn shadowJar  Could not get unknown property 'reobfJar' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler. my gradle file plugins { id 'eclipse' id 'idea' id 'maven-publish' id 'net.minecraftforge.gradle' version '[6.0,6.2)' id 'com.github.johnrengelman.shadow' version '7.1.2' id 'org.spongepowered.mixin' version '0.7.+' } apply plugin: 'net.minecraftforge.gradle' apply plugin: 'org.spongepowered.mixin' apply plugin: 'com.github.johnrengelman.shadow' version = mod_version group = mod_group_id base { archivesName = mod_id } // Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17. java.toolchain.languageVersion = JavaLanguageVersion.of(17) //jarJar.enable() println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}" minecraft { mappings channel: mapping_channel, version: mapping_version copyIdeResources = true runs { configureEach { workingDirectory project.file('run') property 'forge.logging.markers', 'REGISTRIES' property 'forge.logging.console.level', 'debug' arg "-mixin.config=derp.mixin.json" mods { "${mod_id}" { source sourceSets.main } } } client { // Comma-separated list of namespaces to load gametests from. Empty = all namespaces. property 'forge.enabledGameTestNamespaces', mod_id } server { property 'forge.enabledGameTestNamespaces', mod_id args '--nogui' } gameTestServer { property 'forge.enabledGameTestNamespaces', mod_id } data { workingDirectory project.file('run-data') args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') } } } sourceSets.main.resources { srcDir 'src/generated/resources' } repositories { flatDir { dirs './libs' } maven { url = "https://jitpack.io" } } configurations { shade implementation.extendsFrom shade } dependencies { minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" implementation 'org.luaj:luaj-jse-3.0.2' implementation fg.deobf("com.github.Virtuoel:Pehkui:${pehkui_version}") annotationProcessor 'org.spongepowered:mixin:0.8.5:processor' minecraftLibrary 'luaj:luaj-jse:3.0.2' shade 'luaj:luaj-jse:3.0.2' } // Example for how to get properties into the manifest for reading at runtime. tasks.named('jar', Jar).configure { manifest { attributes([ 'Specification-Title' : mod_id, 'Specification-Vendor' : mod_authors, 'Specification-Version' : '1', // We are version 1 of ourselves 'Implementation-Title' : project.name, 'Implementation-Version' : project.jar.archiveVersion, 'Implementation-Vendor' : mod_authors, 'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), "TweakClass" : "org.spongepowered.asm.launch.MixinTweaker", "TweakOrder" : 0, "MixinConfigs" : "derp.mixin.json" ]) } rename 'mixin.refmap.json', 'derp.mixin-refmap.json' } shadowJar { archiveClassifier = '' configurations = [project.configurations.shade] finalizedBy 'reobfShadowJar' } assemble.dependsOn shadowJar reobf { re shadowJar {} } publishing { publications { mavenJava(MavenPublication) { artifact jar } } repositories { maven { url "file://${project.projectDir}/mcmodsrepo" } } } my entire project:https://github.com/kevin051606/DERP-Mod/tree/Derp-1.0-1.20
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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