1 package me.shedaniel.lightoverlay.forge;
3 import com.google.common.collect.Lists;
4 import com.google.common.collect.Maps;
5 import com.mojang.blaze3d.platform.GlStateManager;
6 import com.mojang.blaze3d.systems.RenderSystem;
7 import it.unimi.dsi.fastutil.longs.Long2ReferenceMap;
8 import it.unimi.dsi.fastutil.longs.Long2ReferenceOpenHashMap;
9 import net.minecraft.block.Block;
10 import net.minecraft.block.BlockState;
11 import net.minecraft.client.Minecraft;
12 import net.minecraft.client.entity.player.ClientPlayerEntity;
13 import net.minecraft.client.gui.FontRenderer;
14 import net.minecraft.client.renderer.ActiveRenderInfo;
15 import net.minecraft.client.renderer.IRenderTypeBuffer;
16 import net.minecraft.client.renderer.Tessellator;
17 import net.minecraft.client.renderer.culling.ClippingHelper;
18 import net.minecraft.client.settings.KeyBinding;
19 import net.minecraft.client.util.InputMappings;
20 import net.minecraft.client.world.ClientWorld;
21 import net.minecraft.entity.Entity;
22 import net.minecraft.entity.EntityClassification;
23 import net.minecraft.entity.EntityType;
24 import net.minecraft.network.IPacket;
25 import net.minecraft.network.play.server.SChangeBlockPacket;
26 import net.minecraft.network.play.server.SChunkDataPacket;
27 import net.minecraft.network.play.server.SMultiBlockChangePacket;
28 import net.minecraft.network.play.server.SUpdateLightPacket;
29 import net.minecraft.tags.BlockTags;
30 import net.minecraft.util.Direction;
31 import net.minecraft.util.ResourceLocation;
32 import net.minecraft.util.math.BlockPos;
33 import net.minecraft.util.math.ChunkPos;
34 import net.minecraft.util.math.MathHelper;
35 import net.minecraft.util.math.shapes.ISelectionContext;
36 import net.minecraft.util.math.shapes.VoxelShape;
37 import net.minecraft.util.math.vector.TransformationMatrix;
38 import net.minecraft.util.math.vector.Vector3d;
39 import net.minecraft.world.IBlockReader;
40 import net.minecraft.world.LightType;
41 import net.minecraft.world.World;
42 import net.minecraft.world.chunk.Chunk;
43 import net.minecraft.world.chunk.ChunkStatus;
44 import net.minecraft.world.lighting.IWorldLightListener;
45 import net.minecraftforge.api.distmarker.Dist;
46 import net.minecraftforge.client.event.InputEvent;
47 import net.minecraftforge.client.settings.KeyConflictContext;
48 import net.minecraftforge.client.settings.KeyModifier;
49 import net.minecraftforge.common.MinecraftForge;
50 import net.minecraftforge.event.TickEvent;
51 import net.minecraftforge.eventbus.api.SubscribeEvent;
52 import net.minecraftforge.fml.DistExecutor;
53 import net.minecraftforge.fml.client.registry.ClientRegistry;
54 import org.apache.logging.log4j.LogManager;
55 import org.lwjgl.opengl.GL11;
58 import java.io.FileInputStream;
59 import java.io.FileOutputStream;
60 import java.io.IOException;
61 import java.text.DecimalFormat;
62 import java.util.Comparator;
63 import java.util.List;
65 import java.util.Properties;
66 import java.util.concurrent.ExecutorService;
67 import java.util.concurrent.Executors;
69 public class LightOverlayClient {
70 static final DecimalFormat FORMAT = new DecimalFormat("#.#");
71 private static final String KEYBIND_CATEGORY = "key.lightoverlay.category";
72 private static final ResourceLocation ENABLE_OVERLAY_KEYBIND = new ResourceLocation("lightoverlay", "enable_overlay");
73 static int reach = 12;
74 static int crossLevel = 7;
75 static int secondaryLevel = -1;
76 static int lowerCrossLevel = -1;
77 static int higherCrossLevel = -1;
78 static boolean caching = false;
79 static boolean showNumber = false;
80 static boolean smoothLines = true;
81 static boolean underwater = false;
82 static float lineWidth = 1.0F;
83 static int yellowColor = 0xFFFF00, redColor = 0xFF0000, secondaryColor = 0x0000FF;
84 static File configFile = new File(new File(Minecraft.getInstance().gameDir, "config"), "lightoverlay.properties");
85 private static final KeyBinding ENABLE_OVERLAY;
86 private static boolean enabled = false;
87 private static EntityType<Entity> testingEntityType;
88 private static int threadNumber = 0;
89 public static ClippingHelper frustum;
90 private static final ExecutorService EXECUTOR = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors(), r -> {
91 Thread thread = new Thread(r, "light-overlay-" + threadNumber++);
92 thread.setDaemon(true);
95 private static final List<ChunkPos> POS = Lists.newCopyOnWriteArrayList();
96 private static final Map<ChunkPos, Long2ReferenceMap<Object>> CHUNK_MAP = Maps.newConcurrentMap();
97 private static long ticks = 0;
100 ENABLE_OVERLAY = registerKeybind(ENABLE_OVERLAY_KEYBIND, InputMappings.Type.KEYSYM, 296, KEYBIND_CATEGORY);
103 public static void register() {
105 loadConfig(configFile);
108 testingEntityType = EntityType.Builder.create(EntityClassification.MONSTER).size(0f, 0f).disableSerialization().build(null);
109 MinecraftForge.EVENT_BUS.register(LightOverlayClient.class);
112 //noinspection Convert2MethodRef
113 DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> LightOverlayCloth.register());
114 } catch (Exception e) {
119 public static CrossType getCrossType(BlockPos pos, BlockPos down, IBlockReader reader, IWorldLightListener block, IWorldLightListener sky, ISelectionContext selectionContext) {
120 BlockState blockBelowState = reader.getBlockState(down);
121 BlockState blockUpperState = reader.getBlockState(pos);
122 VoxelShape upperCollisionShape = blockUpperState.getCollisionShape(reader, pos, selectionContext);
123 if (!underwater && !blockUpperState.getFluidState().isEmpty())
124 return CrossType.NONE;
125 // Check if the outline is full
126 if (Block.doesSideFillSquare(upperCollisionShape, Direction.UP))
127 return CrossType.NONE;
128 // Check if there is power
129 if (blockUpperState.canProvidePower())
130 return CrossType.NONE;
131 // Check if the collision has a bump
132 if (upperCollisionShape.getEnd(Direction.Axis.Y) > 0)
133 return CrossType.NONE;
134 if (blockUpperState.getBlock().isIn(BlockTags.RAILS))
135 return CrossType.NONE;
136 // Check block state allow spawning (excludes bedrock and barriers automatically)
137 if (!blockBelowState.canEntitySpawn(reader, down, testingEntityType))
138 return CrossType.NONE;
139 int blockLightLevel = block.getLightFor(pos);
140 int skyLightLevel = sky.getLightFor(pos);
141 if (blockLightLevel > higherCrossLevel)
142 return CrossType.NONE;
143 if (skyLightLevel > higherCrossLevel)
144 return CrossType.YELLOW;
145 return lowerCrossLevel >= 0 && blockLightLevel > lowerCrossLevel ? CrossType.SECONDARY : CrossType.RED;
148 public static int getCrossLevel(BlockPos pos, BlockPos down, IBlockReader reader, IWorldLightListener light, ISelectionContext context) {
149 BlockState blockBelowState = reader.getBlockState(down);
150 BlockState blockUpperState = reader.getBlockState(pos);
151 VoxelShape collisionShape = blockBelowState.getCollisionShape(reader, down, context);
152 VoxelShape upperCollisionShape = blockUpperState.getCollisionShape(reader, pos, context);
153 if (!underwater && !blockUpperState.getFluidState().isEmpty())
155 if (!blockBelowState.getFluidState().isEmpty())
157 if (blockBelowState.isAir(reader, down))
159 if (Block.doesSideFillSquare(upperCollisionShape, Direction.DOWN))
161 return light.getLightFor(pos);
164 public static void renderCross(ActiveRenderInfo info, World world, BlockPos pos, int color, ISelectionContext context) {
165 double d0 = info.getProjectedView().x;
166 double d1 = info.getProjectedView().y - .005D;
167 VoxelShape upperOutlineShape = world.getBlockState(pos).getShape(world, pos, context);
168 if (!upperOutlineShape.isEmpty())
169 d1 -= upperOutlineShape.getEnd(Direction.Axis.Y);
170 double d2 = info.getProjectedView().z;
171 int red = (color >> 16) & 255;
172 int green = (color >> 8) & 255;
173 int blue = color & 255;
177 RenderSystem.color4f(red / 255f, green / 255f, blue / 255f, 1f);
178 GL11.glVertex3d(x + .01 - d0, y - d1, z + .01 - d2);
179 GL11.glVertex3d(x - .01 + 1 - d0, y - d1, z - .01 + 1 - d2);
180 GL11.glVertex3d(x - .01 + 1 - d0, y - d1, z + .01 - d2);
181 GL11.glVertex3d(x + .01 - d0, y - d1, z - .01 + 1 - d2);
184 public static void renderLevel(Minecraft minecraft, ActiveRenderInfo info, World world, BlockPos pos, BlockPos down, int level, ISelectionContext context) {
185 String string_1 = String.valueOf(level);
186 FontRenderer fontRenderer = minecraft.fontRenderer;
187 double double_4 = info.getProjectedView().x;
188 double double_5 = info.getProjectedView().y;
189 VoxelShape upperOutlineShape = world.getBlockState(down).getShape(world, down, context);
190 if (!upperOutlineShape.isEmpty())
191 double_5 += 1 - upperOutlineShape.getEnd(Direction.Axis.Y);
192 double double_6 = info.getProjectedView().z;
193 RenderSystem.pushMatrix();
194 RenderSystem.translatef((float) (pos.getX() + 0.5f - double_4), (float) (pos.getY() - double_5) + 0.005f, (float) (pos.getZ() + 0.5f - double_6));
195 RenderSystem.rotatef(90, 1, 0, 0);
196 RenderSystem.normal3f(0.0F, 1.0F, 0.0F);
198 RenderSystem.scalef(-size, -size, size);
199 float float_3 = (float) (-fontRenderer.getStringWidth(string_1)) / 2.0F + 0.4f;
200 RenderSystem.enableAlphaTest();
201 IRenderTypeBuffer.Impl vertexConsumerProvider$Immediate_1 = IRenderTypeBuffer.getImpl(Tessellator.getInstance().getBuffer());
202 fontRenderer.renderString(string_1, float_3, -3.5f, level > higherCrossLevel ? 0xff042404 : (lowerCrossLevel >= 0 && level > lowerCrossLevel ? 0xff0066ff : 0xff731111), false, TransformationMatrix.identity().getMatrix(), vertexConsumerProvider$Immediate_1, false, 0, 15728880);
203 vertexConsumerProvider$Immediate_1.finish();
204 RenderSystem.popMatrix();
207 @SubscribeEvent(receiveCanceled = true)
208 public static void handleInput(InputEvent.KeyInputEvent event) {
209 if (ENABLE_OVERLAY.isPressed())
213 public static void queueChunkAndNear(ChunkPos pos) {
214 for (int xOffset = -1; xOffset <= 1; xOffset++) {
215 for (int zOffset = -1; zOffset <= 1; zOffset++) {
216 queueChunk(new ChunkPos(pos.x + xOffset, pos.z + zOffset));
221 public static void queueChunk(ChunkPos pos) {
223 if (!POS.contains(pos))
227 public static int getChunkRange() {
228 return Math.max(MathHelper.ceil(reach / 16f), 1);
232 public static void tick(TickEvent.ClientTickEvent event) {
233 if (event.phase == TickEvent.Phase.END) {
235 Minecraft minecraft = Minecraft.getInstance();
237 if (minecraft.player == null || !enabled) {
244 ClientPlayerEntity player = minecraft.player;
245 ClientWorld world = minecraft.world;
246 BlockPos playerPos = player.getPosition();
247 ISelectionContext entityContext = ISelectionContext.forEntity(player);
248 IWorldLightListener block = world.getLightManager().getLightEngine(LightType.BLOCK);
249 IWorldLightListener sky = showNumber ? null : world.getLightManager().getLightEngine(LightType.SKY);
250 BlockPos.Mutable downPos = new BlockPos.Mutable();
251 Iterable<BlockPos> iterate = BlockPos.getAllInBoxMutable(playerPos.getX() - reach, playerPos.getY() - reach, playerPos.getZ() - reach,
252 playerPos.getX() + reach, playerPos.getY() + reach, playerPos.getZ() + reach);
253 Long2ReferenceMap<Object> map = new Long2ReferenceOpenHashMap<>();
254 CHUNK_MAP.put(new ChunkPos(0, 0), map);
255 for (BlockPos blockPos : iterate) {
256 downPos.setPos(blockPos.getX(), blockPos.getY() - 1, blockPos.getZ());
258 int level = getCrossLevel(blockPos, downPos, world, block, entityContext);
260 map.put(blockPos.toLong(), Integer.valueOf(level));
263 CrossType type = getCrossType(blockPos, downPos, world, block, sky, entityContext);
264 if (type != CrossType.NONE) {
265 map.put(blockPos.toLong(), type);
270 ClientPlayerEntity player = minecraft.player;
271 ClientWorld world = minecraft.world;
272 ISelectionContext selectionContext = ISelectionContext.forEntity(player);
273 Vector3d[] playerPos = {null};
274 int playerPosX = ((int) player.getPosX()) >> 4;
275 int playerPosZ = ((int) player.getPosZ()) >> 4;
276 if (ticks % 20 == 0) {
277 for (int chunkX = playerPosX - getChunkRange(); chunkX <= playerPosX + getChunkRange(); chunkX++) {
278 for (int chunkZ = playerPosZ - getChunkRange(); chunkZ <= playerPosZ + getChunkRange(); chunkZ++) {
279 ChunkPos chunkPos = new ChunkPos(chunkX, chunkZ);
280 if (!CHUNK_MAP.containsKey(chunkPos))
281 queueChunk(chunkPos);
285 POS.removeIf(pos -> MathHelper.abs(pos.x - playerPosX) > getChunkRange() || MathHelper.abs(pos.z - playerPosZ) > getChunkRange());
286 for (int k = 0; k < 2; k++) {
287 if (!POS.isEmpty()) {
288 if (playerPos[0] == null) {
289 playerPos[0] = player.getPositionVec();
291 ChunkPos pos = POS.stream().min(Comparator.comparingDouble(value -> {
292 int i = Math.abs(value.x - playerPosX);
293 int j = Math.abs(value.z - playerPosZ);
294 return i * i + j * j;
297 EXECUTOR.submit(() -> {
299 calculateChunk(world.getChunkProvider().getChunk(pos.x, pos.z, ChunkStatus.FULL, false), world, pos, selectionContext);
300 } catch (Throwable throwable) {
301 LogManager.getLogger().throwing(throwable);
306 if (ticks % 50 == 0) {
307 CHUNK_MAP.entrySet().removeIf(pos -> MathHelper.abs(pos.getKey().x - playerPosX) > getChunkRange() * 2 || MathHelper.abs(pos.getKey().z - playerPosZ) > getChunkRange() * 2);
311 } catch (Exception e) {
312 LogManager.getLogger().throwing(e);
317 public static void updateFrustum(ClippingHelper helper) {
321 private static void calculateChunk(Chunk chunk, World world, ChunkPos chunkPos, ISelectionContext selectionContext) {
322 if (world != null && chunk != null) {
323 Long2ReferenceMap<Object> map = new Long2ReferenceOpenHashMap<>();
324 IWorldLightListener block = chunk.getWorldLightManager().getLightEngine(LightType.BLOCK);
325 IWorldLightListener sky = showNumber ? null : chunk.getWorldLightManager().getLightEngine(LightType.SKY);
326 for (BlockPos pos : BlockPos.getAllInBoxMutable(chunkPos.getXStart(), 0, chunkPos.getZStart(), chunkPos.getXEnd(), 256, chunkPos.getZEnd())) {
327 BlockPos down = pos.down();
329 int level = LightOverlayClient.getCrossLevel(pos, down, chunk, block, selectionContext);
331 map.put(pos.toLong(), Integer.valueOf(level));
334 CrossType type = LightOverlayClient.getCrossType(pos, down, chunk, block, sky, selectionContext);
335 if (type != CrossType.NONE) {
336 map.put(pos.toLong(), type);
340 CHUNK_MAP.put(chunkPos, map);
342 CHUNK_MAP.remove(chunkPos);
346 public static void renderWorldLast() {
347 if (LightOverlayClient.enabled) {
348 RenderSystem.pushMatrix();
349 Minecraft client = Minecraft.getInstance();
350 ClientPlayerEntity playerEntity = client.player;
351 int playerPosX = ((int) playerEntity.getPosX()) >> 4;
352 int playerPosZ = ((int) playerEntity.getPosZ()) >> 4;
353 ISelectionContext selectionContext = ISelectionContext.forEntity(playerEntity);
354 World world = client.world;
355 BlockPos playerPos = playerEntity.getPosition();
356 ActiveRenderInfo info = client.gameRenderer.getActiveRenderInfo();
358 RenderSystem.enableTexture();
359 RenderSystem.depthMask(true);
360 BlockPos.Mutable mutable = new BlockPos.Mutable();
361 BlockPos.Mutable downMutable = new BlockPos.Mutable();
362 for (Map.Entry<ChunkPos, Long2ReferenceMap<Object>> entry : CHUNK_MAP.entrySet()) {
363 if (caching && (MathHelper.abs(entry.getKey().x - playerPosX) > getChunkRange() || MathHelper.abs(entry.getKey().z - playerPosZ) > getChunkRange())) {
366 for (Long2ReferenceMap.Entry<Object> objectEntry : entry.getValue().long2ReferenceEntrySet()) {
367 if (objectEntry.getValue() instanceof Integer) {
368 mutable.setPos(BlockPos.unpackX(objectEntry.getLongKey()), BlockPos.unpackY(objectEntry.getLongKey()), BlockPos.unpackZ(objectEntry.getLongKey()));
369 if (mutable.withinDistance(playerPos, reach)) {
370 if (frustum == null || FrustumHelper.isVisible(frustum, mutable.getX(), mutable.getY(), mutable.getZ(), mutable.getX() + 1, mutable.getX() + 1, mutable.getX() + 1)) {
371 downMutable.setPos(mutable.getX(), mutable.getY() - 1, mutable.getZ());
372 LightOverlayClient.renderLevel(client, info, world, mutable, downMutable, (Integer) objectEntry.getValue(), selectionContext);
378 RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
379 RenderSystem.enableDepthTest();
381 RenderSystem.enableDepthTest();
382 RenderSystem.disableTexture();
383 RenderSystem.enableBlend();
384 RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
385 if (smoothLines) GL11.glEnable(GL11.GL_LINE_SMOOTH);
386 GL11.glLineWidth(lineWidth);
387 GL11.glBegin(GL11.GL_LINES);
388 BlockPos.Mutable mutable = new BlockPos.Mutable();
389 for (Map.Entry<ChunkPos, Long2ReferenceMap<Object>> entry : CHUNK_MAP.entrySet()) {
390 if (caching && (MathHelper.abs(entry.getKey().x - playerPosX) > getChunkRange() || MathHelper.abs(entry.getKey().z - playerPosZ) > getChunkRange())) {
393 for (Long2ReferenceMap.Entry<Object> objectEntry : entry.getValue().long2ReferenceEntrySet()) {
394 if (objectEntry.getValue() instanceof CrossType) {
395 mutable.setPos(BlockPos.unpackX(objectEntry.getLongKey()), BlockPos.unpackY(objectEntry.getLongKey()), BlockPos.unpackZ(objectEntry.getLongKey()));
396 if (mutable.withinDistance(playerPos, reach)) {
397 if (frustum == null || FrustumHelper.isVisible(frustum, mutable.getX(), mutable.getY(), mutable.getZ(), mutable.getX() + 1, mutable.getX() + 1, mutable.getX() + 1)) {
398 int color = objectEntry.getValue() == CrossType.RED ? redColor : objectEntry.getValue() == CrossType.YELLOW ? yellowColor : secondaryColor;
399 renderCross(info, world, mutable, color, selectionContext);
406 RenderSystem.disableBlend();
407 RenderSystem.enableTexture();
408 if (smoothLines) GL11.glDisable(GL11.GL_LINE_SMOOTH);
410 RenderSystem.popMatrix();
414 private static KeyBinding registerKeybind(ResourceLocation resourceLocation, InputMappings.Type type, int keyCode, String category) {
415 KeyBinding keyBinding = new KeyBinding("key." + resourceLocation.getNamespace() + "." + resourceLocation.getPath(), KeyConflictContext.IN_GAME, KeyModifier.NONE, type, keyCode, category);
416 ClientRegistry.registerKeyBinding(keyBinding);
420 static void loadConfig(File file) {
423 yellowColor = 0xFFFF00;
424 secondaryColor = 0x0000FF;
425 if (!file.exists() || !file.canRead())
427 FileInputStream fis = new FileInputStream(file);
428 Properties properties = new Properties();
429 properties.load(fis);
431 reach = Integer.parseInt((String) properties.computeIfAbsent("reach", a -> "12"));
432 crossLevel = Integer.parseInt((String) properties.computeIfAbsent("crossLevel", a -> "7"));
433 secondaryLevel = Integer.parseInt((String) properties.computeIfAbsent("secondaryLevel", a -> "-1"));
434 caching = ((String) properties.computeIfAbsent("caching", a -> "false")).equalsIgnoreCase("true");
435 showNumber = ((String) properties.computeIfAbsent("showNumber", a -> "false")).equalsIgnoreCase("true");
436 smoothLines = ((String) properties.computeIfAbsent("smoothLines", a -> "true")).equalsIgnoreCase("true");
437 underwater = ((String) properties.computeIfAbsent("underwater", a -> "false")).equalsIgnoreCase("true");
438 lineWidth = Float.parseFloat((String) properties.computeIfAbsent("lineWidth", a -> "1"));
441 r = Integer.parseInt((String) properties.computeIfAbsent("yellowColorRed", a -> "255"));
442 g = Integer.parseInt((String) properties.computeIfAbsent("yellowColorGreen", a -> "255"));
443 b = Integer.parseInt((String) properties.computeIfAbsent("yellowColorBlue", a -> "0"));
444 yellowColor = (r << 16) + (g << 8) + b;
448 r = Integer.parseInt((String) properties.computeIfAbsent("redColorRed", a -> "255"));
449 g = Integer.parseInt((String) properties.computeIfAbsent("redColorGreen", a -> "0"));
450 b = Integer.parseInt((String) properties.computeIfAbsent("redColorBlue", a -> "0"));
451 redColor = (r << 16) + (g << 8) + b;
455 r = Integer.parseInt((String) properties.computeIfAbsent("secondaryColorRed", a -> "0"));
456 g = Integer.parseInt((String) properties.computeIfAbsent("secondaryColorGreen", a -> "0"));
457 b = Integer.parseInt((String) properties.computeIfAbsent("secondaryColorBlue", a -> "255"));
458 secondaryColor = (r << 16) + (g << 8) + b;
461 } catch (Exception e) {
468 yellowColor = 0xFFFF00;
469 secondaryColor = 0x0000FF;
476 } catch (IOException ex) {
477 ex.printStackTrace();
480 if (secondaryLevel >= crossLevel) System.err.println("[Light Overlay] Secondary Level is higher than Cross Level");
481 lowerCrossLevel = Math.min(crossLevel, secondaryLevel);
482 higherCrossLevel = Math.max(crossLevel, secondaryLevel);
487 static void saveConfig(File file) throws IOException {
488 FileOutputStream fos = new FileOutputStream(file, false);
489 fos.write("# Light Overlay Config".getBytes());
490 fos.write("\n".getBytes());
491 fos.write(("reach=" + reach).getBytes());
492 fos.write("\n".getBytes());
493 fos.write(("crossLevel=" + crossLevel).getBytes());
494 fos.write("\n".getBytes());
495 fos.write(("secondaryLevel=" + secondaryLevel).getBytes());
496 fos.write("\n".getBytes());
497 fos.write(("caching=" + caching).getBytes());
498 fos.write("\n".getBytes());
499 fos.write(("showNumber=" + showNumber).getBytes());
500 fos.write("\n".getBytes());
501 fos.write(("smoothLines=" + smoothLines).getBytes());
502 fos.write("\n".getBytes());
503 fos.write(("underwater=" + underwater).getBytes());
504 fos.write("\n".getBytes());
505 fos.write(("lineWidth=" + FORMAT.format(lineWidth)).getBytes());
506 fos.write("\n".getBytes());
507 fos.write(("yellowColorRed=" + ((yellowColor >> 16) & 255)).getBytes());
508 fos.write("\n".getBytes());
509 fos.write(("yellowColorGreen=" + ((yellowColor >> 8) & 255)).getBytes());
510 fos.write("\n".getBytes());
511 fos.write(("yellowColorBlue=" + (yellowColor & 255)).getBytes());
512 fos.write("\n".getBytes());
513 fos.write(("redColorRed=" + ((redColor >> 16) & 255)).getBytes());
514 fos.write("\n".getBytes());
515 fos.write(("redColorGreen=" + ((redColor >> 8) & 255)).getBytes());
516 fos.write("\n".getBytes());
517 fos.write(("redColorBlue=" + (redColor & 255)).getBytes());
518 fos.write("\n".getBytes());
519 fos.write(("secondaryColorRed=" + ((secondaryColor >> 16) & 255)).getBytes());
520 fos.write("\n".getBytes());
521 fos.write(("secondaryColorGreen=" + ((secondaryColor >> 8) & 255)).getBytes());
522 fos.write("\n".getBytes());
523 fos.write(("secondaryColorBlue=" + (secondaryColor & 255)).getBytes());
527 public static void processPacket(IPacket<?> packet) {
528 if (packet instanceof SChangeBlockPacket) {
529 LightOverlayClient.queueChunkAndNear(new ChunkPos(((SChangeBlockPacket) packet).getPos()));
530 } else if (packet instanceof SChunkDataPacket) {
531 LightOverlayClient.queueChunkAndNear(new ChunkPos(((SChunkDataPacket) packet).getChunkX(), ((SChunkDataPacket) packet).getChunkZ()));
532 } else if (packet instanceof SMultiBlockChangePacket) {
533 LightOverlayClient.queueChunkAndNear(new ChunkPos(((SMultiBlockChangePacket) packet).field_244305_a.getSectionX(), ((SMultiBlockChangePacket) packet).field_244305_a.getSectionZ()));
534 } else if (packet instanceof SUpdateLightPacket) {
535 LightOverlayClient.queueChunkAndNear(new ChunkPos(((SUpdateLightPacket) packet).getChunkX(), ((SUpdateLightPacket) packet).getChunkZ()));
539 private enum CrossType {