1 package me.shedaniel.lightoverlay.fabric;
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 me.shedaniel.cloth.api.client.events.v0.ClothClientHooks;
10 import net.fabricmc.api.ClientModInitializer;
11 import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
12 import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
13 import net.fabricmc.loader.api.FabricLoader;
14 import net.minecraft.block.Block;
15 import net.minecraft.block.BlockState;
16 import net.minecraft.client.MinecraftClient;
17 import net.minecraft.client.font.TextRenderer;
18 import net.minecraft.client.network.ClientPlayerEntity;
19 import net.minecraft.client.options.KeyBinding;
20 import net.minecraft.client.render.Camera;
21 import net.minecraft.client.render.Frustum;
22 import net.minecraft.client.render.Tessellator;
23 import net.minecraft.client.render.VertexConsumerProvider;
24 import net.minecraft.client.util.InputUtil;
25 import net.minecraft.client.util.math.Rotation3;
26 import net.minecraft.client.world.ClientWorld;
27 import net.minecraft.entity.Entity;
28 import net.minecraft.entity.EntityCategory;
29 import net.minecraft.entity.EntityContext;
30 import net.minecraft.entity.EntityType;
31 import net.minecraft.entity.player.PlayerEntity;
32 import net.minecraft.tag.BlockTags;
33 import net.minecraft.util.Identifier;
34 import net.minecraft.util.math.*;
35 import net.minecraft.util.shape.VoxelShape;
36 import net.minecraft.world.BlockView;
37 import net.minecraft.world.LightType;
38 import net.minecraft.world.World;
39 import net.minecraft.world.biome.SpawnSettings;
40 import net.minecraft.world.chunk.ChunkStatus;
41 import net.minecraft.world.chunk.WorldChunk;
42 import net.minecraft.world.chunk.light.ChunkLightingView;
43 import org.apache.logging.log4j.LogManager;
44 import org.lwjgl.opengl.GL11;
47 import java.io.FileInputStream;
48 import java.io.FileOutputStream;
49 import java.io.IOException;
50 import java.text.DecimalFormat;
51 import java.util.Comparator;
52 import java.util.List;
54 import java.util.Properties;
55 import java.util.concurrent.Executors;
56 import java.util.concurrent.ThreadPoolExecutor;
58 public class LightOverlay implements ClientModInitializer {
60 static final DecimalFormat FORMAT = new DecimalFormat("#.#");
61 private static final String KEYBIND_CATEGORY = "key.lightoverlay.category";
62 private static final Identifier ENABLE_OVERLAY_KEYBIND = new Identifier("lightoverlay", "enable_overlay");
63 static int reach = 12;
64 static int crossLevel = 7;
65 static int secondaryLevel = -1;
66 static int lowerCrossLevel = -1;
67 static int higherCrossLevel = -1;
68 static boolean caching = false;
69 static boolean showNumber = false;
70 static boolean smoothLines = true;
71 static boolean underwater = false;
72 static float lineWidth = 1.0F;
73 static int yellowColor = 0xFFFF00, redColor = 0xFF0000, secondaryColor = 0x0000FF;
74 static File configFile = new File(FabricLoader.getInstance().getConfigDir().toFile(), "lightoverlay.properties");
75 private static final KeyBinding ENABLE_OVERLAY = createKeyBinding(ENABLE_OVERLAY_KEYBIND, InputUtil.Type.KEYSYM, 296, KEYBIND_CATEGORY);
76 private static boolean enabled = false;
77 private static EntityType<Entity> testingEntityType;
78 private static int threadNumber = 0;
79 public static Frustum frustum;
80 private static final ThreadPoolExecutor EXECUTOR = (ThreadPoolExecutor) Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors(), r -> {
81 Thread thread = new Thread(r, "light-overlay-" + threadNumber++);
82 thread.setDaemon(true);
85 private static final List<ChunkPos> POS = Lists.newCopyOnWriteArrayList();
86 private static final Map<ChunkPos, Long2ReferenceMap<Object>> CHUNK_MAP = Maps.newConcurrentMap();
87 private static final MinecraftClient CLIENT = MinecraftClient.getInstance();
88 private static long ticks = 0;
91 ClientTickEvents.END_CLIENT_TICK.register(client -> {
94 if (CLIENT.player == null || !enabled) {
101 ClientPlayerEntity player = CLIENT.player;
102 ClientWorld world = CLIENT.world;
103 BlockPos playerPos = player.getSenseCenterPos();
104 EntityContext entityContext = EntityContext.of(player);
105 ChunkLightingView block = world.getLightingProvider().get(LightType.BLOCK);
106 ChunkLightingView sky = showNumber ? null : world.getLightingProvider().get(LightType.SKY);
107 BlockPos.Mutable downPos = new BlockPos.Mutable();
108 Iterable<BlockPos> iterate = BlockPos.iterate(playerPos.getX() - reach, playerPos.getY() - reach, playerPos.getZ() - reach,
109 playerPos.getX() + reach, playerPos.getY() + reach, playerPos.getZ() + reach);
110 Long2ReferenceMap<Object> map = new Long2ReferenceOpenHashMap<>();
111 CHUNK_MAP.put(new ChunkPos(0, 0), map);
112 for (BlockPos blockPos : iterate) {
113 downPos.set(blockPos.getX(), blockPos.getY() - 1, blockPos.getZ());
115 int level = getCrossLevel(blockPos, downPos, world, block, entityContext);
117 map.put(blockPos.asLong(), Integer.valueOf(level));
120 CrossType type = getCrossType(blockPos, downPos, world, block, sky, entityContext);
121 if (type != CrossType.NONE) {
122 map.put(blockPos.asLong(), type);
127 ClientPlayerEntity player = CLIENT.player;
128 ClientWorld world = CLIENT.world;
129 EntityContext entityContext = EntityContext.of(player);
130 Vec3d[] playerPos = {null};
131 int playerPosX = ((int) player.getX()) >> 4;
132 int playerPosZ = ((int) player.getZ()) >> 4;
133 if (ticks % 20 == 0) {
134 for (int chunkX = playerPosX - getChunkRange(); chunkX <= playerPosX + getChunkRange(); chunkX++) {
135 for (int chunkZ = playerPosZ - getChunkRange(); chunkZ <= playerPosZ + getChunkRange(); chunkZ++) {
136 ChunkPos chunkPos = new ChunkPos(chunkX, chunkZ);
137 if (!CHUNK_MAP.containsKey(chunkPos))
138 queueChunk(chunkPos);
142 POS.removeIf(pos -> MathHelper.abs(pos.x - playerPosX) > getChunkRange() || MathHelper.abs(pos.z - playerPosZ) > getChunkRange());
143 for (int k = 0; k < 2; k++) {
144 if (!POS.isEmpty()) {
145 if (playerPos[0] == null) {
146 playerPos[0] = player.getPos();
148 ChunkPos pos = POS.stream().min(Comparator.comparingDouble(value -> {
149 int i = Math.abs(value.x - playerPosX);
150 int j = Math.abs(value.z - playerPosZ);
151 return i * i + j * j;
154 EXECUTOR.submit(() -> {
156 calculateChunk(world.getChunkManager().getChunk(pos.x, pos.z, ChunkStatus.FULL, false), world, pos, entityContext);
157 } catch (Throwable throwable) {
158 LogManager.getLogger().throwing(throwable);
163 if (ticks % 50 == 0) {
164 CHUNK_MAP.entrySet().removeIf(pos -> MathHelper.abs(pos.getKey().x - playerPosX) > getChunkRange() * 2 || MathHelper.abs(pos.getKey().z - playerPosZ) > getChunkRange() * 2);
168 } catch (Throwable throwable) {
169 LogManager.getLogger().throwing(throwable);
174 public static void queueChunkAndNear(ChunkPos pos) {
175 for (int xOffset = -1; xOffset <= 1; xOffset++) {
176 for (int zOffset = -1; zOffset <= 1; zOffset++) {
177 queueChunk(new ChunkPos(pos.x + xOffset, pos.z + zOffset));
182 public static void queueChunk(ChunkPos pos) {
184 if (!POS.contains(pos))
188 public static int getChunkRange() {
189 return Math.max(MathHelper.ceil(reach / 16f), 1);
192 private static void calculateChunk(WorldChunk chunk, World world, ChunkPos chunkPos, EntityContext entityContext) {
193 if (world != null && chunk != null) {
194 Long2ReferenceMap<Object> map = new Long2ReferenceOpenHashMap<>();
195 ChunkLightingView block = world.getLightingProvider().get(LightType.BLOCK);
196 ChunkLightingView sky = showNumber ? null : world.getLightingProvider().get(LightType.SKY);
197 for (BlockPos pos : BlockPos.iterate(chunkPos.getStartX(), 0, chunkPos.getStartZ(), chunkPos.getEndX(), 256, chunkPos.getEndZ())) {
198 BlockPos down = pos.down();
200 int level = LightOverlay.getCrossLevel(pos, down, chunk, block, entityContext);
202 map.put(pos.asLong(), Integer.valueOf(level));
205 SpawnSettings spawnSettings = world.getBiomeAccess().getBiome(pos).getSpawnSettings();
206 if (spawnSettings.getCreatureSpawnProbability() > 0 && !spawnSettings.getSpawnEntry(EntityCategory.MONSTER).isEmpty()) {
207 CrossType type = LightOverlay.getCrossType(pos, down, chunk, block, sky, entityContext);
208 if (type != CrossType.NONE) {
209 map.put(pos.asLong(), type);
214 CHUNK_MAP.put(chunkPos, map);
216 CHUNK_MAP.remove(chunkPos);
220 public static CrossType getCrossType(BlockPos pos, BlockPos down, BlockView world, ChunkLightingView block, ChunkLightingView sky, EntityContext entityContext) {
221 BlockState blockBelowState = world.getBlockState(down);
222 BlockState blockUpperState = world.getBlockState(pos);
223 VoxelShape upperCollisionShape = blockUpperState.getCollisionShape(world, pos, entityContext);
224 if (!underwater && !blockUpperState.getFluidState().isEmpty())
225 return CrossType.NONE;
226 // Check if the outline is full
227 if (Block.isFaceFullSquare(upperCollisionShape, Direction.UP))
228 return CrossType.NONE;
229 // TODO: Not to hard code no redstone
230 if (blockUpperState.emitsRedstonePower())
231 return CrossType.NONE;
232 // Check if the collision has a bump
233 if (upperCollisionShape.getMaximum(Direction.Axis.Y) > 0)
234 return CrossType.NONE;
235 if (blockUpperState.getBlock().isIn(BlockTags.RAILS))
236 return CrossType.NONE;
237 // Check block state allow spawning (excludes bedrock and barriers automatically)
238 if (!blockBelowState.allowsSpawning(world, down, testingEntityType))
239 return CrossType.NONE;
240 int blockLightLevel = block.getLightLevel(pos);
241 int skyLightLevel = sky.getLightLevel(pos);
242 if (blockLightLevel > higherCrossLevel)
243 return CrossType.NONE;
244 if (skyLightLevel > higherCrossLevel)
245 return CrossType.YELLOW;
246 return lowerCrossLevel >= 0 && blockLightLevel > lowerCrossLevel ? CrossType.SECONDARY : CrossType.RED;
249 public static int getCrossLevel(BlockPos pos, BlockPos down, BlockView world, ChunkLightingView view, EntityContext entityContext) {
250 BlockState blockBelowState = world.getBlockState(down);
251 BlockState blockUpperState = world.getBlockState(pos);
252 VoxelShape collisionShape = blockBelowState.getCollisionShape(world, down, entityContext);
253 VoxelShape upperCollisionShape = blockUpperState.getCollisionShape(world, pos, entityContext);
254 if (!underwater && !blockUpperState.getFluidState().isEmpty())
256 if (!blockBelowState.getFluidState().isEmpty())
258 if (blockBelowState.isAir())
260 if (Block.isFaceFullSquare(upperCollisionShape, Direction.DOWN))
262 return view.getLightLevel(pos);
265 public static void renderCross(Camera camera, World world, BlockPos pos, int color, EntityContext entityContext) {
266 double d0 = camera.getPos().x;
267 double d1 = camera.getPos().y - .005D;
268 VoxelShape upperOutlineShape = world.getBlockState(pos).getOutlineShape(world, pos, entityContext);
269 if (!upperOutlineShape.isEmpty())
270 d1 -= upperOutlineShape.getMaximum(Direction.Axis.Y);
271 double d2 = camera.getPos().z;
273 int red = (color >> 16) & 255;
274 int green = (color >> 8) & 255;
275 int blue = color & 255;
279 RenderSystem.color4f(red / 255f, green / 255f, blue / 255f, 1f);
280 GL11.glVertex3d(x + .01 - d0, y - d1, z + .01 - d2);
281 GL11.glVertex3d(x - .01 + 1 - d0, y - d1, z - .01 + 1 - d2);
282 GL11.glVertex3d(x - .01 + 1 - d0, y - d1, z + .01 - d2);
283 GL11.glVertex3d(x + .01 - d0, y - d1, z - .01 + 1 - d2);
286 @SuppressWarnings("deprecation")
287 public static void renderLevel(MinecraftClient client, Camera camera, World world, BlockPos pos, BlockPos down, int level, EntityContext entityContext) {
288 String text = String.valueOf(level);
289 TextRenderer textRenderer_1 = client.textRenderer;
290 double double_4 = camera.getPos().x;
291 double double_5 = camera.getPos().y;
292 VoxelShape upperOutlineShape = world.getBlockState(down).getOutlineShape(world, down, entityContext);
293 if (!upperOutlineShape.isEmpty())
294 double_5 += 1 - upperOutlineShape.getMaximum(Direction.Axis.Y);
295 double double_6 = camera.getPos().z;
296 RenderSystem.pushMatrix();
297 RenderSystem.translatef((float) (pos.getX() + 0.5f - double_4), (float) (pos.getY() - double_5) + 0.005f, (float) (pos.getZ() + 0.5f - double_6));
298 RenderSystem.rotatef(90, 1, 0, 0);
299 RenderSystem.normal3f(0.0F, 1.0F, 0.0F);
301 RenderSystem.scalef(-size, -size, size);
302 float float_3 = (float) (-textRenderer_1.getStringWidth(text)) / 2.0F + 0.4f;
303 RenderSystem.enableAlphaTest();
304 VertexConsumerProvider.Immediate immediate = VertexConsumerProvider.immediate(Tessellator.getInstance().getBuffer());
305 textRenderer_1.draw(text, float_3, -3.5f, level > higherCrossLevel ? 0xff042404 : (lowerCrossLevel >= 0 && level > lowerCrossLevel ? 0xff0066ff : 0xff731111), false, Rotation3.identity().getMatrix(), immediate, false, 0, 15728880);
307 RenderSystem.popMatrix();
310 static void loadConfig(File file) {
313 yellowColor = 0xFFFF00;
314 secondaryColor = 0x0000FF;
315 if (!file.exists() || !file.canRead())
317 FileInputStream fis = new FileInputStream(file);
318 Properties properties = new Properties();
319 properties.load(fis);
321 reach = Integer.parseInt((String) properties.computeIfAbsent("reach", a -> "12"));
322 crossLevel = Integer.parseInt((String) properties.computeIfAbsent("crossLevel", a -> "7"));
323 secondaryLevel = Integer.parseInt((String) properties.computeIfAbsent("secondaryLevel", a -> "-1"));
324 caching = ((String) properties.computeIfAbsent("caching", a -> "false")).equalsIgnoreCase("true");
325 showNumber = ((String) properties.computeIfAbsent("showNumber", a -> "false")).equalsIgnoreCase("true");
326 smoothLines = ((String) properties.computeIfAbsent("smoothLines", a -> "true")).equalsIgnoreCase("true");
327 underwater = ((String) properties.computeIfAbsent("underwater", a -> "false")).equalsIgnoreCase("true");
328 lineWidth = Float.parseFloat((String) properties.computeIfAbsent("lineWidth", a -> "1"));
331 r = Integer.parseInt((String) properties.computeIfAbsent("yellowColorRed", a -> "255"));
332 g = Integer.parseInt((String) properties.computeIfAbsent("yellowColorGreen", a -> "255"));
333 b = Integer.parseInt((String) properties.computeIfAbsent("yellowColorBlue", a -> "0"));
334 yellowColor = (r << 16) + (g << 8) + b;
338 r = Integer.parseInt((String) properties.computeIfAbsent("redColorRed", a -> "255"));
339 g = Integer.parseInt((String) properties.computeIfAbsent("redColorGreen", a -> "0"));
340 b = Integer.parseInt((String) properties.computeIfAbsent("redColorBlue", a -> "0"));
341 redColor = (r << 16) + (g << 8) + b;
345 r = Integer.parseInt((String) properties.computeIfAbsent("secondaryColorRed", a -> "0"));
346 g = Integer.parseInt((String) properties.computeIfAbsent("secondaryColorGreen", a -> "0"));
347 b = Integer.parseInt((String) properties.computeIfAbsent("secondaryColorBlue", a -> "255"));
348 secondaryColor = (r << 16) + (g << 8) + b;
351 } catch (Exception e) {
358 yellowColor = 0xFFFF00;
359 secondaryColor = 0x0000FF;
366 } catch (IOException ex) {
367 ex.printStackTrace();
370 if (secondaryLevel >= crossLevel) System.err.println("[Light Overlay] Secondary Level is higher than Cross Level");
371 lowerCrossLevel = Math.min(crossLevel, secondaryLevel);
372 higherCrossLevel = Math.max(crossLevel, secondaryLevel);
377 static void saveConfig(File file) throws IOException {
378 FileOutputStream fos = new FileOutputStream(file, false);
379 fos.write("# Light Overlay Config".getBytes());
380 fos.write("\n".getBytes());
381 fos.write(("reach=" + reach).getBytes());
382 fos.write("\n".getBytes());
383 fos.write(("crossLevel=" + crossLevel).getBytes());
384 fos.write("\n".getBytes());
385 fos.write(("secondaryLevel=" + secondaryLevel).getBytes());
386 fos.write("\n".getBytes());
387 fos.write(("caching=" + caching).getBytes());
388 fos.write("\n".getBytes());
389 fos.write(("showNumber=" + showNumber).getBytes());
390 fos.write("\n".getBytes());
391 fos.write(("smoothLines=" + smoothLines).getBytes());
392 fos.write("\n".getBytes());
393 fos.write(("underwater=" + underwater).getBytes());
394 fos.write("\n".getBytes());
395 fos.write(("lineWidth=" + FORMAT.format(lineWidth)).getBytes());
396 fos.write("\n".getBytes());
397 fos.write(("yellowColorRed=" + ((yellowColor >> 16) & 255)).getBytes());
398 fos.write("\n".getBytes());
399 fos.write(("yellowColorGreen=" + ((yellowColor >> 8) & 255)).getBytes());
400 fos.write("\n".getBytes());
401 fos.write(("yellowColorBlue=" + (yellowColor & 255)).getBytes());
402 fos.write("\n".getBytes());
403 fos.write(("redColorRed=" + ((redColor >> 16) & 255)).getBytes());
404 fos.write("\n".getBytes());
405 fos.write(("redColorGreen=" + ((redColor >> 8) & 255)).getBytes());
406 fos.write("\n".getBytes());
407 fos.write(("redColorBlue=" + (redColor & 255)).getBytes());
408 fos.write("\n".getBytes());
409 fos.write(("secondaryColorRed=" + ((secondaryColor >> 16) & 255)).getBytes());
410 fos.write("\n".getBytes());
411 fos.write(("secondaryColorGreen=" + ((secondaryColor >> 8) & 255)).getBytes());
412 fos.write("\n".getBytes());
413 fos.write(("secondaryColorBlue=" + (secondaryColor & 255)).getBytes());
417 private static KeyBinding createKeyBinding(Identifier id, InputUtil.Type type, int code, String category) {
418 return KeyBindingHelper.registerKeyBinding(new KeyBinding("key." + id.getNamespace() + "." + id.getPath(), type, code, category));
422 public void onInitializeClient() {
424 loadConfig(configFile);
427 testingEntityType = EntityType.Builder.create(EntityCategory.MONSTER).setDimensions(0f, 0f).disableSaving().build(null);
428 ClientTickEvents.END_CLIENT_TICK.register(minecraftClient -> {
429 while (ENABLE_OVERLAY.wasPressed())
432 ClothClientHooks.DEBUG_RENDER_PRE.register(() -> {
433 if (LightOverlay.enabled) {
434 PlayerEntity playerEntity = CLIENT.player;
435 int playerPosX = ((int) playerEntity.getX()) >> 4;
436 int playerPosZ = ((int) playerEntity.getZ()) >> 4;
437 EntityContext entityContext = EntityContext.of(playerEntity);
438 World world = CLIENT.world;
439 BlockPos playerPos = new BlockPos(playerEntity.getX(), playerEntity.getY(), playerEntity.getZ());
440 Camera camera = CLIENT.gameRenderer.getCamera();
442 RenderSystem.enableTexture();
443 RenderSystem.depthMask(true);
444 BlockPos.Mutable mutable = new BlockPos.Mutable();
445 BlockPos.Mutable downMutable = new BlockPos.Mutable();
446 for (Map.Entry<ChunkPos, Long2ReferenceMap<Object>> entry : CHUNK_MAP.entrySet()) {
447 if (caching && (MathHelper.abs(entry.getKey().x - playerPosX) > getChunkRange() || MathHelper.abs(entry.getKey().z - playerPosZ) > getChunkRange())) {
450 for (Long2ReferenceMap.Entry<Object> objectEntry : entry.getValue().long2ReferenceEntrySet()) {
451 if (objectEntry.getValue() instanceof Integer) {
452 mutable.set(BlockPos.unpackLongX(objectEntry.getLongKey()), BlockPos.unpackLongY(objectEntry.getLongKey()), BlockPos.unpackLongZ(objectEntry.getLongKey()));
453 if (mutable.isWithinDistance(playerPos, reach)) {
454 if (frustum == null || FrustumHelper.isVisible(frustum, mutable.getX(), mutable.getY(), mutable.getZ(), mutable.getX() + 1, mutable.getX() + 1, mutable.getX() + 1)) {
455 downMutable.set(mutable.getX(), mutable.getY() - 1, mutable.getZ());
456 LightOverlay.renderLevel(CLIENT, camera, world, mutable, downMutable, (Integer) objectEntry.getValue(), entityContext);
462 RenderSystem.enableDepthTest();
464 RenderSystem.enableDepthTest();
465 RenderSystem.disableTexture();
466 RenderSystem.enableBlend();
467 RenderSystem.blendFunc(GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA);
468 if (smoothLines) GL11.glEnable(GL11.GL_LINE_SMOOTH);
469 GL11.glLineWidth(lineWidth);
470 GL11.glBegin(GL11.GL_LINES);
471 BlockPos.Mutable mutable = new BlockPos.Mutable();
472 for (Map.Entry<ChunkPos, Long2ReferenceMap<Object>> entry : CHUNK_MAP.entrySet()) {
473 if (caching && (MathHelper.abs(entry.getKey().x - playerPosX) > getChunkRange() || MathHelper.abs(entry.getKey().z - playerPosZ) > getChunkRange())) {
476 for (Long2ReferenceMap.Entry<Object> objectEntry : entry.getValue().long2ReferenceEntrySet()) {
477 if (objectEntry.getValue() instanceof CrossType) {
478 mutable.set(BlockPos.unpackLongX(objectEntry.getLongKey()), BlockPos.unpackLongY(objectEntry.getLongKey()), BlockPos.unpackLongZ(objectEntry.getLongKey()));
479 if (mutable.isWithinDistance(playerPos, reach)) {
480 if (frustum == null || FrustumHelper.isVisible(frustum, mutable.getX(), mutable.getY(), mutable.getZ(), mutable.getX() + 1, mutable.getX() + 1, mutable.getX() + 1)) {
481 int color = objectEntry.getValue() == CrossType.RED ? redColor : objectEntry.getValue() == CrossType.YELLOW ? yellowColor : secondaryColor;
482 LightOverlay.renderCross(camera, world, mutable, color, entityContext);
489 RenderSystem.disableBlend();
490 RenderSystem.enableTexture();
491 if (smoothLines) GL11.glDisable(GL11.GL_LINE_SMOOTH);
497 private enum CrossType {