mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-22 03:55:18 -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).
|
||||
/// -1 means this property has not been set by the user before
|
||||
/// </summary>
|
||||
[ConfigInt(null, null, -1, -1, 15)] public int Brightness;
|
||||
[ConfigInt(null, null, -1, -1, 15)] public int Brightness = -1;
|
||||
/// <summary>
|
||||
/// Does this block use the lamplight environment color for light casting? (for fancy lighting option)
|
||||
/// If false, uses the lavalight environment color
|
||||
@ -102,14 +102,6 @@ namespace MCGalaxy {
|
||||
def.Brightness = Brightness; def.UseLampBrightness = UseLampBrightness;
|
||||
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;
|
||||
public static BlockDefinition[] Load(string path) {
|
||||
@ -124,7 +116,6 @@ namespace MCGalaxy {
|
||||
reader.OnMember = (obj, key, value) => {
|
||||
if (obj.Meta == null) obj.Meta = new BlockDefinition();
|
||||
ConfigElement.Parse(elems, obj.Meta, key, (string)value);
|
||||
((BlockDefinition)obj.Meta).OnParsed();
|
||||
};
|
||||
|
||||
JsonArray array = (JsonArray)reader.Parse();
|
||||
@ -146,6 +137,11 @@ namespace MCGalaxy {
|
||||
|
||||
// In case user manually edited fallback in the json file
|
||||
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) {
|
||||
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++] = def.WalkSound;
|
||||
|
||||
// 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
|
||||
// Less than zero shouldn't happen, but just in case
|
||||
if (def.Brightness <= 0) {
|
||||
buffer[i++] = 0;
|
||||
} 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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user