Skip to content

Commit

Permalink
Java lighting
Browse files Browse the repository at this point in the history
  • Loading branch information
PREMIEREHELL committed Jun 7, 2024
1 parent 5819920 commit 6cf6e25
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
32 changes: 32 additions & 0 deletions amulet/level/interfaces/chunk/anvil/anvil_1934.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,52 @@
from __future__ import annotations

from typing import List, Tuple, TYPE_CHECKING

if TYPE_CHECKING:
from amulet.api.chunk import Chunk

from amulet_nbt import CompoundTag, ByteTag

from .base_anvil_interface import ChunkDataType, ChunkPathType

from .anvil_1912 import Anvil1912Interface as ParentInterface


class Anvil1934Interface(ParentInterface):
"""
Made lighting optional
Made game recalculate lighting
"""

isLightOn: ChunkPathType = (
"region",
[("Level", CompoundTag), ("isLightOn", ByteTag)],
ByteTag,
)

def __init__(self):
super().__init__()
self._set_feature("light_optional", "true")
self._register_encoder(self._encode_islighton)
self._register_decoder(self._decode_islighton)

@staticmethod
def minor_is_valid(key: int):
return 1934 <= key < 2203

def _decode_islighton(
self, chunk: Chunk, data: ChunkDataType, floor_cy: int, height_cy: int
):
chunk.misc["isLightOn"] = self.get_layer_obj(
data, self.isLightOn, pop_last=True
)

def _encode_islighton(
self, chunk: Chunk, data: ChunkDataType, floor_cy: int, height_cy: int
):

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


export = Anvil1934Interface
2 changes: 1 addition & 1 deletion amulet/level/interfaces/chunk/anvil/anvil_2844.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class Anvil2844Interface(ParentInterface):
OldLevel: ChunkPathType = ("region", [("Level", CompoundTag)], CompoundTag)
Level: ChunkPathType = ("region", [], CompoundTag)
Sections: ChunkPathType = ("region", [("sections", ListTag)], ListTag)

isLightOn: ChunkPathType = ("region", [("isLightOn", ByteTag)], ByteTag)
Entities: ChunkPathType = ("region", [("entities", ListTag)], ListTag)
BlockEntities: ChunkPathType = ("region", [("block_entities", ListTag)], ListTag)
BlockTicks: ChunkPathType = ("region", [("block_ticks", ListTag)], ListTag)
Expand Down

0 comments on commit 6cf6e25

Please sign in to comment.