Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ready Java Lighting #302

Closed

Conversation

PREMIEREHELL
Copy link
Contributor

@PREMIEREHELL PREMIEREHELL commented Jun 4, 2024

the game will recalculate the light levels for versions tested (19w08b) 1934 to 3949 (1.21.Pre2)

@PREMIEREHELL PREMIEREHELL force-pushed the latest-java-lighting branch 2 times, most recently from 679c616 to b758782 Compare June 4, 2024 21:55
the game will recalculate the light levels for (19w08b) 1934 <= 1.14 => 1.21
Fixed this issue where it always evaluates to true and adds the tag.
I think its better to set the value to 0 than to remove the tag,
the game will recalculate the light levels for (19w08b) 1934 <= 1.14 => 1.21

Fixed a typo, bug [Bug report] Amulet-Team#286

Updated

Fixed this issue where it always evaluates to true and adds the tag.
I think its better to set the value to 0 than to remove the tag,

Revert "Fixed a typo, bug [Bug report] Amulet-Team#286"

This reverts commit 16b0635.
self, chunk: Chunk, data: ChunkDataType, floor_cy: int, height_cy: int
):
if chunk.misc.get("isLightOn", None):
self.set_layer_obj(data, self.isLightOn, ByteTag(0))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ByteTag(1)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would tell the game that it does not need to be recalculated, it needs to be set to 0

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see what you mean. "only call this once. Store the value."

def _decode_islighton(
self, chunk: Chunk, data: ChunkDataType, floor_cy: int, height_cy: int
):
if self.get_layer_obj(data, self.isLightOn) == ByteTag(1):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only call this once. Store the value.

Copy link
Contributor Author

@PREMIEREHELL PREMIEREHELL Jun 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This checks if the tag and value exists in the chunk and if the set value is 1, if it is it stores it, then format.py,

changed_ |= chunk.misc.get("isLightOn", None) is not None  #true

if in format.py the above code, use's pop the below code is None and does not do anything,
I could put the if statement line 36 below, still would work the same.

if chunk.misc.get("isLightOn", None):  # is true
            self.set_layer_obj(data, self.isLightOn, ByteTag(0) ) # sets it to 0 

this is according to my tests
maybe

if chunk.misc.get("isLightOn", None) == ByteTag(1):
            self.set_layer_obj(data, self.isLightOn, ByteTag(0))

but then chunk change would always return true

Copy link
Contributor Author

@PREMIEREHELL PREMIEREHELL Jun 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like nothing gets committed to the originally loaded object data, even after a save it still returns true, until you reload the world in amulet. Does make it a little tedious when testing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The purpose of the decoder and encoder is to read the data and write it back exactly as it was found.
The lighting changes in the save operation are a separate step.

this will update only the chunks that have the isLightOn tag set to 1 ,
@@ -387,3 +389,14 @@ def misc(self) -> dict:
def misc(self, misc: dict):
assert isinstance(misc, dict), "misc must be a dictionary."
self._misc = misc

@property
def set_light_off(self) -> bool:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feature only exists in Java. I would prefer if this was left in the misc data.
The rewrite gives each format the ability to define its own chunk class so in the future we could have something like this but for now it should be left in misc.

@PREMIEREHELL PREMIEREHELL deleted the latest-java-lighting branch June 7, 2024 22:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants