Commits

DerFrZocker authored and md_5 committed 64d149a5a9d
SPIGOT-1753: ChunkGenerator lighting updates
No tags

src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java

Modified
15 15 import org.bukkit.material.MaterialData;
16 16
17 17 /**
18 18 * Data to be used for the block types and data in a newly generated chunk.
19 19 */
20 20 public final class CraftChunkData implements ChunkGenerator.ChunkData {
21 21 private final int minHeight;
22 22 private final int maxHeight;
23 23 private final ChunkSection[] sections;
24 24 private Set<BlockPosition> tiles;
25 + private final Set<BlockPosition> lights = new HashSet<>();
25 26
26 27 public CraftChunkData(World world) {
27 28 this(world.getMinHeight(), world.getMaxHeight());
28 29 }
29 30
30 31 /* pp for tests */ CraftChunkData(int minHeight, int maxHeight) {
31 32 this.minHeight = minHeight;
32 33 this.maxHeight = maxHeight;
33 34 sections = new ChunkSection[(((maxHeight - 1) >> 4) + 1) - (minHeight >> 4)];
34 35 }
142 143 return CraftMagicNumbers.toLegacyData(getTypeId(x, y, z));
143 144 }
144 145
145 146 private void setBlock(int x, int y, int z, IBlockData type) {
146 147 if (x != (x & 0xf) || y < minHeight || y >= maxHeight || z != (z & 0xf)) {
147 148 return;
148 149 }
149 150 ChunkSection section = getChunkSection(y, true);
150 151 section.setType(x, y & 0xf, z, type);
151 152
153 + // SPIGOT-1753: Capture light blocks, for light updates
154 + if (type.f() > 0) { // PAIL rename getLightEmission
155 + lights.add(new BlockPosition(x, y, z));
156 + } else {
157 + lights.remove(new BlockPosition(x, y, z));
158 + }
159 +
152 160 if (type.isTileEntity()) {
153 161 if (tiles == null) {
154 162 tiles = new HashSet<>();
155 163 }
156 164
157 165 tiles.add(new BlockPosition(x, y, z));
158 166 }
159 167 }
160 168
161 169 private ChunkSection getChunkSection(int y, boolean create) {
167 175 return section;
168 176 }
169 177
170 178 ChunkSection[] getRawChunkData() {
171 179 return sections;
172 180 }
173 181
174 182 Set<BlockPosition> getTiles() {
175 183 return tiles;
176 184 }
185 +
186 + Set<BlockPosition> getLights() {
187 + return lights;
188 + }
177 189 }

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut