Laike-Endaril / Dynamic-Stealth

Introducing actual stealth mechanics to Minecraft
https://minecraft.curseforge.com/projects/dynamic-stealth
18 stars 2 forks source link

Dynamic lighting in general #75

Open Phorcis opened 5 years ago

Phorcis commented 5 years ago

I thought that these mods are perfect for each other and this is true in SP, but in MP i have some troubles:

Laike-Endaril commented 5 years ago

It sounds like Realistic Torches is using entity-based lighting for held lights instead of "the proper way" (ie. block-based lighting).

This being the case, the only already-existing workaround is to make sure the entity with the light is always "visible" to the player. The easiest way of doing this is to disable player senses, though that makes DS less interesting imo. (server settings -> senses -> use player senses)

A more solid solution would fit better into Realistic Torches than DS, which is to say...use block-based lighting that doesn't rely on client-side entities. I can only assume Realistic Torches' handheld lights don't actually affect light levels anyway, as they are now (eg. if you stand next to a mob spawner while holding one, I bet it still spawns mobs, doesn't it?)

Phorcis commented 5 years ago

Player senses are my main reason for using DS, so I don’t want to disable them.

Idk about mob spawners, but I set the maximum effect of lighting on the entity viewing range, i.e. in complete darkness player will see the mob only from distance of 1-2 blocks. And I am delighted with this functionality. With optifine or dynamic lights torch lighting doesnt work and mob is still visible only from 1-2 blocks. But with Realistic Torches all works fine.

Laike-Endaril commented 5 years ago

Interesting! If the held lights with realistic torches are affecting visual stealth, then they probably are changing server-side block light levels...

I wonder if the block light level changes being done this way are not directly synced to clients though, and instead it uses the entity holding the light to change the light levels client-side...

I'll see if the mod dev is active, and whether he/she can provide more info.

Edit: It looks like the Realistic Torches dev is working on non-MC stuff lately, but Realistic Torches is open source, and this particular compat is pretty interesting, so I'll give it a more detailed look when I can. Might be a while though.

tacusin commented 5 years ago

Hello, I actually have a suggestion for this in terms of a possible way to add compatibility to this, or any other mod that adds visible light to handheld/worn objects.

I would like to go ahead and apologize for the lengthy message. I tried to be about as descriptive as I could with the idea.

Anyways, you could a section under (server settings->Items->Light Sources) where players/server owners/modpack creators, can add items and the amount of "light" they give off.

For example "minecraft:torch, 15" Would give off a light source of 15. Or "minecraft:redstone_torch, 7" Giving off a light source of 7.

You wouldn't need to actually "render" the light, but could instead make the mod react to the values as if the light was rendered (whether or not is it) whenever the item is in their hand/offhand/worn.

For added compatibility with Dynamic Lights by atomicstrykergrumpy. They have it so you can also have handheld&worn lights, by default their mod has minecraft:golden_helmet give off a light value of 14. Which continues to work if you wear the helmet instead of hold it. They also have a feature where certain light sources will not work underwater (such as torches). Could either have a separate section for classifying items that don't give off light underwater. Or could add it as a true/false. Ex "minecraft:torch, 15, false" For not working underwater. And "minecraft:redstone_torch, 7, true" for an Item that does work underwater.

Either way, Just an idea ^^, though I would like to know what you think about it. And if you think you might implement it into the mod. I'm actually in the process of putting together a new modpack for my clan members and would like to use this mod without using vanilla senses for the players.

Also, your light gauge seems to pick up on atomicstrykergrumpy's light sources, But it doesn't seem to reflect with actually being able to see the mob.

Laike-Endaril commented 5 years ago

The only issue I see with this approach is that I would have to simulate the same light propagation as MC to stay accurate. I feel like it would be better to alter the actual light levels, if possible (which it sounds like Realistic Torches might be doing; I'll have to do more testing on that), though I do appreciate the suggestion.

I've made a new thread for the possible light gauge issue, as seen in the link above. I'm still currently working on that other project for now though.

Phorcis commented 5 years ago

After one bug (I don’t remember which one) I found out that Realistic Torches sets lighting level for the block ( air ) the player is standing on.

The bug was that the lighting level wasnt reset for block in which the player stood - when moving, there was a trace of lighting blocks of air

Laike-Endaril commented 5 years ago

In other words, it occasionally sets the light level of the block at your feet? Possibly only when that block is air?

Phorcis commented 5 years ago

not occasionally, but always. Apparently this is the principle of the mod. Torch is just for sight - actually block (at head height) emits the light on which the player stands.

This is my vision of how the mod works based on a bug

Laike-Endaril commented 5 years ago

After fixing my light gauge I came back to this, and can confirm that Realistic Torches actually changes the server-side light level, via a tile entity (or block entity if you prefer that name).

Can confirm it works for SP. Have not tested dedicated mode yet

Laike-Endaril commented 5 years ago

Based on what I'm seeing, in dedicated mode, said tile entities are not synced from server to client.

Instead, he has the tile entities created separately on the server side and the on each client...which depends on the entity holding the dynamic light source existing on each client (which they do not when you can't see them with DS player senses enabled).

So basically since light sources are only created by the entity when it exists and is moving on the client, if you hold a light source and move around while your friend is looking at you, it will look right. If you then hold still while he's still looking at you, it will still be fine...but if he looks away and then looks back, it will be dark.

Theoretically an easy fix...from the Realistic Torches side. Instead of creating/deleting the TE client-side based on an entity, a simple packet can be sent from server to client when a TE is created or deleted, containing a position. The client can then use the position in the packet to set or remove a TE there.

This is all just my theory of what's happening, but it's probably pretty close to right. I'll look into this more in the near future and see if a fix can be done.

Since the dev seems to be inactive though, I'm not sure even a PR to Realistic Torches would go through, so this may possibly end up as a "create a new mod" type issue. If that happens, it may take a bit longer.

Laike-Endaril commented 5 years ago

I decided to create my own dynamic lighting mod, due to

  1. Realistic Torches being the only existing one that works server-side, afaik
  2. Realistic Torches does this using a combination of a temporary block and a temporary TE, which causes some bugs (eg. you will never suffocate in sand or gravel; try it)

Ie. it might be a while before I get around to finishing it, but it's an interesting topic for me, so I do plan to do it when I can

Phorcis commented 5 years ago

Wow! Good luck! Take your time, there is no hurry.

kappa-maintainer commented 4 years ago

I found a mod call Moving Light Sources, which work by changing the light level, but this mod haven't updated for a long time.

Laike-Endaril commented 4 years ago

It looks like another possible option to try for sure. At the very least, the description says it's using server-side lighting.

@Phorcis If you try out Moving Light Sources, maybe tell me how it goes...I've been super busy lately and haven't gotten around to messing with this at all

Laike-Endaril commented 3 years ago

This has been recently mentioned again (elsewhere, but I linked to this thread in response), so I figured I'd give an update.

The core systems of "Luminous" are actually working already...in my dev environment. But it's currently done in a way that doesn't export correctly into a jar that can be run alongside a normal forge install.

("Luminous" being the dynamic lighting mod I'm working on)

I'll eventually get it working, but still no ETA

Derpford commented 2 years ago

I know the project is discontinued, but: What if, instead of trying to detect the light level of dynamic lights, you just detected the light that would be emitted by the items in the player's hand? This would cover most of the items that are made into dynamic lights by, for example, OptiFine. It wouldn't be perfect for AtomicStryker's dynamic lights mod, or for stuff like the Mining Lantern mod or Mining Helmet mods, but it would go a pretty long way. You could also add a config file override line, similar to the overrides for other options.

I swore an oath to never touch Java again, sadly, so I don't know if I can contribute for this feature.