mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-24 05:03:34 -04:00
More fixes for recent few commits
This commit is contained in:
parent
5f3be2b529
commit
b8625b0a22
@ -120,10 +120,6 @@ namespace MCGalaxy {
|
|||||||
GlobalDefs[Block.air] = DefaultSet.MakeCustomBlock(Block.air);
|
GlobalDefs[Block.air] = DefaultSet.MakeCustomBlock(Block.air);
|
||||||
GlobalDefs[Block.air].Name = "Air fallback";
|
GlobalDefs[Block.air].Name = "Air fallback";
|
||||||
|
|
||||||
GlobalProps = new BlockProps[Block.Count * 2];
|
|
||||||
for (int i = 0; i < Block.Count; i++)
|
|
||||||
GlobalProps[i] = Block.Props[i];
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (File.Exists(GlobalPath)) {
|
if (File.Exists(GlobalPath)) {
|
||||||
File.Copy(GlobalPath, GlobalBackupPath, true);
|
File.Copy(GlobalPath, GlobalBackupPath, true);
|
||||||
@ -133,13 +129,20 @@ namespace MCGalaxy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Save(true, null);
|
Save(true, null);
|
||||||
BlockProps.Load("global", BlockDefinition.GlobalProps, true);
|
|
||||||
|
|
||||||
// As the BlockDefinition instances in levels will now be different
|
// As the BlockDefinition instances in levels will now be different
|
||||||
// to the instances in GlobalDefs, we need to update them.
|
// to the instances in GlobalDefs, we need to update them.
|
||||||
if (oldDefs != null) UpdateLoadedLevels(oldDefs);
|
if (oldDefs != null) UpdateLoadedLevels(oldDefs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void LoadGlobalProps() {
|
||||||
|
GlobalProps = new BlockProps[Block.Count * 2];
|
||||||
|
for (int i = 0; i < Block.Count; i++) {
|
||||||
|
GlobalProps[i] = Block.Props[i];
|
||||||
|
GlobalProps[i + Block.Count] = new BlockProps((byte)i);
|
||||||
|
}
|
||||||
|
BlockProps.Load("global", GlobalProps, true);
|
||||||
|
}
|
||||||
|
|
||||||
static void UpdateLoadedLevels(BlockDefinition[] oldGlobalDefs) {
|
static void UpdateLoadedLevels(BlockDefinition[] oldGlobalDefs) {
|
||||||
Level[] loaded = LevelInfo.Loaded.Items;
|
Level[] loaded = LevelInfo.Loaded.Items;
|
||||||
foreach (Level lvl in loaded) {
|
foreach (Level lvl in loaded) {
|
||||||
|
@ -48,7 +48,7 @@ namespace MCGalaxy.Blocks {
|
|||||||
return perms;
|
return perms;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BlockPerms[] List = new BlockPerms[256];
|
public static BlockPerms[] List = new BlockPerms[Block.Count];
|
||||||
|
|
||||||
|
|
||||||
/// <summary> Returns whether the given rank can modify the given block. </summary>
|
/// <summary> Returns whether the given rank can modify the given block. </summary>
|
||||||
|
@ -92,7 +92,7 @@ namespace MCGalaxy.Blocks {
|
|||||||
// Don't save physics blocks
|
// Don't save physics blocks
|
||||||
if (custom && (i > Block.CpeCount && i < Block.Count)) continue;
|
if (custom && (i > Block.CpeCount && i < Block.Count)) continue;
|
||||||
// Convert ext to raw ids
|
// Convert ext to raw ids
|
||||||
int id = i >= Block.Count ? (i - 256) : i;
|
int id = i >= Block.Count ? (i - Block.Count) : i;
|
||||||
|
|
||||||
string deathMsg = props.DeathMessage == null ? "" : props.DeathMessage.Replace(":", "\\;");
|
string deathMsg = props.DeathMessage == null ? "" : props.DeathMessage.Replace(":", "\\;");
|
||||||
w.WriteLine(id + ":" + props.IsRails + ":" + props.IsTDoor + ":" + props.IsDoor + ":"
|
w.WriteLine(id + ":" + props.IsRails + ":" + props.IsTDoor + ":" + props.IsDoor + ":"
|
||||||
@ -124,7 +124,7 @@ namespace MCGalaxy.Blocks {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int idx = raw;
|
int idx = raw;
|
||||||
if (custom && raw >= Block.CpeCount) idx += 256;
|
if (custom && raw >= Block.CpeCount) idx += Block.Count;
|
||||||
|
|
||||||
bool.TryParse(parts[1], out scope[idx].IsRails);
|
bool.TryParse(parts[1], out scope[idx].IsRails);
|
||||||
bool.TryParse(parts[2], out scope[idx].IsTDoor);
|
bool.TryParse(parts[2], out scope[idx].IsTDoor);
|
||||||
|
@ -48,7 +48,7 @@ namespace MCGalaxy {
|
|||||||
public bool IsAir { get { return BlockID == Block.air; } }
|
public bool IsAir { get { return BlockID == Block.air; } }
|
||||||
|
|
||||||
/// <summary> Returns the index of this block within an array. </summary>
|
/// <summary> Returns the index of this block within an array. </summary>
|
||||||
public int Index { get { return BlockID != Block.custom_block ? BlockID : (ExtID + 256); } }
|
public int Index { get { return BlockID != Block.custom_block ? BlockID : (ExtID + Block.Count); } }
|
||||||
|
|
||||||
|
|
||||||
/// <summary> Returns the raw (for client side) block ID of this block. </summary>
|
/// <summary> Returns the raw (for client side) block ID of this block. </summary>
|
||||||
|
@ -30,7 +30,7 @@ namespace MCGalaxy.Blocks.Physics {
|
|||||||
if (!C.data.HasWait) return false;
|
if (!C.data.HasWait) return false;
|
||||||
|
|
||||||
if (C.data.Door && C.data.Data == 0) {
|
if (C.data.Door && C.data.Data == 0) {
|
||||||
int i = C.data.Value2 + (C.data.ExtBlock ? 256 : 0);
|
int i = C.data.Value2 + (C.data.ExtBlock ? Block.Count : 0);
|
||||||
bool tdoor = lvl.BlockProps[i].IsTDoor;
|
bool tdoor = lvl.BlockProps[i].IsTDoor;
|
||||||
|
|
||||||
if (tdoor) DoorPhysics.tDoor(lvl, ref C);
|
if (tdoor) DoorPhysics.tDoor(lvl, ref C);
|
||||||
@ -68,7 +68,7 @@ namespace MCGalaxy.Blocks.Physics {
|
|||||||
|
|
||||||
if (args.Wait) {
|
if (args.Wait) {
|
||||||
if (C.data.Door && C.data.Data == 0) {
|
if (C.data.Door && C.data.Data == 0) {
|
||||||
int i = C.data.Value2 + (C.data.ExtBlock ? 256 : 0);
|
int i = C.data.Value2 + (C.data.ExtBlock ? Block.Count : 0);
|
||||||
bool tdoor = lvl.BlockProps[i].IsTDoor;
|
bool tdoor = lvl.BlockProps[i].IsTDoor;
|
||||||
|
|
||||||
if (tdoor) DoorPhysics.tDoor(lvl, ref C);
|
if (tdoor) DoorPhysics.tDoor(lvl, ref C);
|
||||||
|
@ -121,7 +121,7 @@ namespace MCGalaxy.Commands.CPE {
|
|||||||
|
|
||||||
AddBlock(p, dstDef, global, cmd, props);
|
AddBlock(p, dstDef, global, cmd, props);
|
||||||
string scope = global ? "global" : "level";
|
string scope = global ? "global" : "level";
|
||||||
Player.Message(p, "Duplicated the {0} custom block with id \"{1}\" to \"{2}\".", scope, src, dst);
|
Player.Message(p, "Duplicated the {0} custom block with id \"{1}\" to \"{2}\".", scope, src.RawID, dst.RawID);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void InfoHandler(Player p, string[] parts, bool global, string cmd) {
|
static void InfoHandler(Player p, string[] parts, bool global, string cmd) {
|
||||||
|
@ -154,7 +154,10 @@ namespace MCGalaxy {
|
|||||||
OnPhysicsUpdateEvent.Call(x, y, z, C.data, this);
|
OnPhysicsUpdateEvent.Call(x, y, z, C.data, this);
|
||||||
|
|
||||||
if ((C.data.Raw & mask) == 0 || extraHandler(this, ref C)) {
|
if ((C.data.Raw & mask) == 0 || extraHandler(this, ref C)) {
|
||||||
HandlePhysics handler = handlers[blocks[C.b]];
|
int idx = blocks[C.b];
|
||||||
|
if (idx == Block.custom_block) idx = Block.Count + GetExtTileNoCheck(x, y, z);
|
||||||
|
|
||||||
|
HandlePhysics handler = handlers[idx];
|
||||||
if (handler != null) {
|
if (handler != null) {
|
||||||
handler(this, ref C);
|
handler(this, ref C);
|
||||||
} else if ((C.data.Raw & mask) == 0 || !C.data.HasWait) {
|
} else if ((C.data.Raw & mask) == 0 || !C.data.HasWait) {
|
||||||
|
@ -76,6 +76,7 @@ namespace MCGalaxy {
|
|||||||
BlockProps = new BlockProps[Block.Count * 2];
|
BlockProps = new BlockProps[Block.Count * 2];
|
||||||
for (int i = 0; i < BlockProps.Length; i++)
|
for (int i = 0; i < BlockProps.Length; i++)
|
||||||
BlockProps[i] = BlockDefinition.GlobalProps[i];
|
BlockProps[i] = BlockDefinition.GlobalProps[i];
|
||||||
|
SetBlockHandlers();
|
||||||
|
|
||||||
name = n; MapName = n.ToLower();
|
name = n; MapName = n.ToLower();
|
||||||
BlockDB = new BlockDB(this);
|
BlockDB = new BlockDB(this);
|
||||||
@ -92,7 +93,6 @@ namespace MCGalaxy {
|
|||||||
spawny = (ushort)(Height * 0.75f);
|
spawny = (ushort)(Height * 0.75f);
|
||||||
spawnz = (ushort)(Length / 2);
|
spawnz = (ushort)(Length / 2);
|
||||||
rotx = 0; roty = 0;
|
rotx = 0; roty = 0;
|
||||||
SetBlockHandlers();
|
|
||||||
|
|
||||||
ZoneList = new List<Zone>();
|
ZoneList = new List<Zone>();
|
||||||
VisitAccess = new LevelAccessController(this, true);
|
VisitAccess = new LevelAccessController(this, true);
|
||||||
@ -405,10 +405,8 @@ namespace MCGalaxy {
|
|||||||
lvl.CustomBlockDefs[i] = defs[i];
|
lvl.CustomBlockDefs[i] = defs[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < lvl.BlockProps.Length; i++) {
|
|
||||||
lvl.BlockProps[i] = BlockDefinition.GlobalProps[i];
|
|
||||||
}
|
|
||||||
MCGalaxy.Blocks.BlockProps.Load("lvl_" + lvl.MapName, lvl.BlockProps, true);
|
MCGalaxy.Blocks.BlockProps.Load("lvl_" + lvl.MapName, lvl.BlockProps, true);
|
||||||
|
lvl.SetBlockHandlers();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool CheckLoadOnGoto(string givenName) {
|
public static bool CheckLoadOnGoto(string givenName) {
|
||||||
@ -513,11 +511,8 @@ namespace MCGalaxy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void SetBlockHandler(ExtBlock block) {
|
public void SetBlockHandler(ExtBlock block) {
|
||||||
bool notCustom = !block.IsCustomType &&
|
|
||||||
(block.BlockID >= Block.CpeCount || CustomBlockDefs[block.BlockID] == null);
|
|
||||||
|
|
||||||
bool nonSolid;
|
bool nonSolid;
|
||||||
if (notCustom) {
|
if (GetBlockDef(block) == null) {
|
||||||
nonSolid = Block.Walkthrough(Block.Convert(block.BlockID));
|
nonSolid = Block.Walkthrough(Block.Convert(block.BlockID));
|
||||||
} else {
|
} else {
|
||||||
nonSolid = CustomBlockDefs[block.BlockID].CollideType != CollideType.Solid;
|
nonSolid = CustomBlockDefs[block.BlockID].CollideType != CollideType.Solid;
|
||||||
|
@ -195,6 +195,7 @@ namespace MCGalaxy {
|
|||||||
Command.InitAll();
|
Command.InitAll();
|
||||||
CommandPerms.Load();
|
CommandPerms.Load();
|
||||||
Block.SetBlocks();
|
Block.SetBlocks();
|
||||||
|
BlockDefinition.LoadGlobalProps();
|
||||||
Awards.Load();
|
Awards.Load();
|
||||||
Economy.Load();
|
Economy.Load();
|
||||||
WarpList.Global.Load(null);
|
WarpList.Global.Load(null);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user