Core: Now WaterKills and LavaKills work with custom blocks.

This commit is contained in:
UnknownShadow200 2016-10-21 15:00:25 +11:00
parent 1b2ff8c9b3
commit c032c8b88e
5 changed files with 35 additions and 18 deletions

View File

@ -70,16 +70,5 @@ namespace MCGalaxy.Blocks {
Name = "unknown";
ODoorId = Block.Zero;
}
public static IEnumerable<BlockProps> AllBlockProps(Player p) {
return Block.Props; // TODO: fix this
/*foreach (BlockProps props in Block.Props)
yield return props;
if (Player.IsSuper(p)) yield break;
foreach (BlockProps props in p.level.CustomBlockProps)
yield return props;*/
}
}
}

View File

@ -204,7 +204,7 @@ namespace MCGalaxy.Commands.Building {
Player.Message(p, "%T/mb [block] [message]");
Player.Message(p, "%HPlaces a message in your next block.");
var allProps = BlockProps.AllBlockProps(p);
var allProps = Block.Props;
Player.Message(p, "%H Supported blocks: %S{0}",
allProps.Join(props => Format(props)));
Player.Message(p, "%H Use | to separate commands, e.g. /say 1 |/say 2");

View File

@ -200,7 +200,7 @@ namespace MCGalaxy.Commands.Building {
Player.Message(p, "%T/portal [block] multi");
Player.Message(p, "%HPlace multiple blocks for entries, then a red block for exit.");
var allProps = BlockProps.AllBlockProps(p);
var allProps = Block.Props;
Player.Message(p, "%H Supported blocks: %S{0}",
allProps.Join(props => Format(props)));
Player.Message(p, "%T/portal show %H- Shows portals (green = entry, red = exit)");

View File

@ -45,7 +45,14 @@ namespace MCGalaxy.BlockPhysics {
default:
// //Adv physics kills flowers and mushrooms in water
if (!Block.Props[lvl.blocks[b]].WaterKills) break;
byte block = lvl.blocks[b];
if (block != Block.custom_block) {
if (!Block.Props[block].WaterKills) break;
} else {
block = lvl.GetExtTile(b);
if (!lvl.CustomBlockProps[block].WaterKills) break;
}
if (lvl.physics > 1 && !lvl.CheckSpongeWater(x, y, z))
lvl.AddUpdate(b, Block.air);
break;
@ -80,7 +87,14 @@ namespace MCGalaxy.BlockPhysics {
default:
//Adv physics kills flowers, wool, mushrooms, and wood type blocks in lava
if (!Block.Props[lvl.blocks[b]].LavaKills) break;
byte block = lvl.blocks[b];
if (block != Block.custom_block) {
if (!Block.Props[block].LavaKills) break;
} else {
block = lvl.GetExtTile(b);
if (!lvl.CustomBlockProps[block].LavaKills) break;
}
if (lvl.physics > 1 && !lvl.CheckSpongeLava(x, y, z))
lvl.AddUpdate(b, Block.air);
break;

View File

@ -126,7 +126,7 @@ namespace MCGalaxy.BlockPhysics {
}
static void DoWaterUniformFlow(Level lvl, ref Check C) {
Random rand = lvl.physRandom;
Random rand = lvl.physRandom;
lvl.liquids.Remove(C.b);
ushort x, y, z;
lvl.IntToPos(C.b, out x, out y, out z);
@ -168,7 +168,14 @@ namespace MCGalaxy.BlockPhysics {
default:
//Adv physics kills flowers, mushroom blocks in water
if (!Block.Props[lvl.blocks[b]].WaterKills) return true;
byte block = lvl.blocks[b];
if (block != Block.custom_block) {
if (!Block.Props[block].WaterKills) return true;
} else {
block = lvl.GetExtTile(b);
if (!lvl.CustomBlockProps[block].WaterKills) return true;
}
if (lvl.physics > 1 && !lvl.CheckSpongeWater(x, y, z)) return false;
break;
}
@ -275,7 +282,14 @@ namespace MCGalaxy.BlockPhysics {
default:
//Adv physics kills flowers, wool, mushrooms, and wood type blocks in lava
if (!Block.Props[lvl.blocks[b]].LavaKills) return true;
byte block = lvl.blocks[b];
if (block != Block.custom_block) {
if (!Block.Props[block].LavaKills) return true;
} else {
block = lvl.GetExtTile(b);
if (!lvl.CustomBlockProps[block].LavaKills) return true;
}
if (lvl.physics > 1 && !lvl.CheckSpongeLava(x, y, z)) return false;
break;
}