mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-22 20:16:36 -04:00
Fix blockdef brightness mistakes
This commit is contained in:
parent
003ad37acb
commit
b77da60b00
@ -67,7 +67,7 @@ namespace MCGalaxy {
|
|||||||
/// 0-15 value for how far this block casts light (for fancy lighting option).
|
/// 0-15 value for how far this block casts light (for fancy lighting option).
|
||||||
/// -1 means this property has not been set by the user before
|
/// -1 means this property has not been set by the user before
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[ConfigInt(null, null, -1, -1, 15)] public int Brightness;
|
[ConfigInt(null, null, -1, -1, 15)] public int Brightness = -1;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Does this block use the lamplight environment color for light casting? (for fancy lighting option)
|
/// Does this block use the lamplight environment color for light casting? (for fancy lighting option)
|
||||||
/// If false, uses the lavalight environment color
|
/// If false, uses the lavalight environment color
|
||||||
@ -103,14 +103,6 @@ namespace MCGalaxy {
|
|||||||
return def;
|
return def;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Called on this instance after it has been parsed from its json file
|
|
||||||
/// </summary>
|
|
||||||
void OnParsed() {
|
|
||||||
//Sync Brightness setting logically to max brightness if it has not been set before but this block is fullbright
|
|
||||||
if (Brightness == -1 && FullBright) Brightness = 15;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ConfigElement[] elems;
|
static ConfigElement[] elems;
|
||||||
public static BlockDefinition[] Load(string path) {
|
public static BlockDefinition[] Load(string path) {
|
||||||
BlockDefinition[] defs = new BlockDefinition[Block.SUPPORTED_COUNT];
|
BlockDefinition[] defs = new BlockDefinition[Block.SUPPORTED_COUNT];
|
||||||
@ -124,7 +116,6 @@ namespace MCGalaxy {
|
|||||||
reader.OnMember = (obj, key, value) => {
|
reader.OnMember = (obj, key, value) => {
|
||||||
if (obj.Meta == null) obj.Meta = new BlockDefinition();
|
if (obj.Meta == null) obj.Meta = new BlockDefinition();
|
||||||
ConfigElement.Parse(elems, obj.Meta, key, (string)value);
|
ConfigElement.Parse(elems, obj.Meta, key, (string)value);
|
||||||
((BlockDefinition)obj.Meta).OnParsed();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
JsonArray array = (JsonArray)reader.Parse();
|
JsonArray array = (JsonArray)reader.Parse();
|
||||||
@ -146,6 +137,11 @@ namespace MCGalaxy {
|
|||||||
|
|
||||||
// In case user manually edited fallback in the json file
|
// In case user manually edited fallback in the json file
|
||||||
def.FallBack = Math.Min(def.FallBack, Block.CPE_MAX_BLOCK);
|
def.FallBack = Math.Min(def.FallBack, Block.CPE_MAX_BLOCK);
|
||||||
|
|
||||||
|
// Sync Brightness setting it has not been set before
|
||||||
|
if (def.Brightness == -1) {
|
||||||
|
if (def.FullBright) { def.Brightness = 15; } else { def.Brightness = 0; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Logger.LogError("Error Loading block defs from " + path, ex);
|
Logger.LogError("Error Loading block defs from " + path, ex);
|
||||||
|
@ -748,12 +748,17 @@ namespace MCGalaxy.Network
|
|||||||
buffer[i++] = (byte)(def.BlocksLight ? 0 : 1);
|
buffer[i++] = (byte)(def.BlocksLight ? 0 : 1);
|
||||||
buffer[i++] = def.WalkSound;
|
buffer[i++] = def.WalkSound;
|
||||||
|
|
||||||
// 0b_US--_LLLL where U = uses modern brightness, S = uses lamplight color, and L = brightness */
|
// Less than zero shouldn't happen, but just in case
|
||||||
byte brightness = (byte)Math.Max(0, Math.Min(def.Brightness, 15));
|
if (def.Brightness <= 0) {
|
||||||
brightness |= 1 << 7; // Insert "use modern brightness" flag (otherwise client will interpret it as either 0 or 15 lava brightness)
|
buffer[i++] = 0;
|
||||||
if (def.UseLampBrightness) brightness |= 1 << 6; // Insert "use lamplight color" flag
|
} else {
|
||||||
|
// 0b_US--_LLLL where U = uses modern brightness, S = uses lamplight color, and L = brightness */
|
||||||
|
byte brightness = (byte)Math.Max(0, Math.Min(def.Brightness, 15));
|
||||||
|
brightness |= 1 << 7; // Insert "use modern brightness" flag (otherwise client will interpret it as either 0 or 15 lava brightness)
|
||||||
|
if (def.UseLampBrightness) brightness |= 1 << 6; // Insert "use lamplight color" flag
|
||||||
|
|
||||||
buffer[i++] = brightness;
|
buffer[i++] = brightness;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MakeDefineBlockEnd(BlockDefinition def, ref int i, byte[] buffer) {
|
static void MakeDefineBlockEnd(BlockDefinition def, ref int i, byte[] buffer) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user