mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-25 06:04:46 -04:00
Core: Allow changing more properties with /blockprops
This commit is contained in:
parent
d406ab2cea
commit
b316d14859
@ -221,7 +221,7 @@ namespace MCGalaxy {
|
||||
|
||||
static void SetDeath(byte block, string message, bool collideKill = true) {
|
||||
Props[block].DeathMessage = message;
|
||||
Props[block].CollisionDeath = collideKill;
|
||||
Props[block].KillerBlock = collideKill;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -153,6 +153,7 @@ namespace MCGalaxy
|
||||
public const byte door_tnt = 120;
|
||||
public const byte door_stair = 121;
|
||||
|
||||
// tdoors
|
||||
public const byte tdoor = 122;
|
||||
public const byte tdoor2 = 123;
|
||||
public const byte tdoor3 = 124;
|
||||
@ -162,20 +163,21 @@ namespace MCGalaxy
|
||||
public const byte tdoor7 = 128;
|
||||
public const byte tdoor8 = 129;
|
||||
|
||||
//Messages
|
||||
// Message blocks
|
||||
public const byte MsgWhite = 130;
|
||||
public const byte MsgBlack = 131;
|
||||
public const byte MsgAir = 132;
|
||||
public const byte MsgWater = 133;
|
||||
public const byte MsgLava = 134;
|
||||
|
||||
// More tdoors
|
||||
public const byte tdoor9 = 135;
|
||||
public const byte tdoor10 = 136;
|
||||
public const byte tdoor11 = 137;
|
||||
public const byte tdoor12 = 138;
|
||||
public const byte tdoor13 = 139;
|
||||
|
||||
//"finite"
|
||||
// "finite" liquids
|
||||
public const byte WaterDown = 140;
|
||||
public const byte LavaDown = 141;
|
||||
public const byte WaterFaucet = 143;
|
||||
@ -198,13 +200,14 @@ namespace MCGalaxy
|
||||
public const byte odoor11 = 158;
|
||||
public const byte odoor12 = 159;
|
||||
|
||||
//movement
|
||||
// Movement portals
|
||||
public const byte air_portal = 160;
|
||||
public const byte water_portal = 161;
|
||||
public const byte lava_portal = 162;
|
||||
|
||||
//BlockDefinitions
|
||||
// BlockDefinitions
|
||||
public const byte custom_block = 163;
|
||||
|
||||
//Movement doors
|
||||
public const byte air_door = 164;
|
||||
public const byte air_switch = 165;
|
||||
@ -233,11 +236,8 @@ namespace MCGalaxy
|
||||
public const byte smalltnt = 182;
|
||||
public const byte bigtnt = 183;
|
||||
public const byte tntexplosion = 184;
|
||||
|
||||
public const byte lava_fire = 185;
|
||||
|
||||
public const byte lava_fire = 185;
|
||||
public const byte nuketnt = 186;
|
||||
|
||||
public const byte rocketstart = 187;
|
||||
public const byte rockethead = 188;
|
||||
public const byte firework = 189;
|
||||
@ -246,7 +246,6 @@ namespace MCGalaxy
|
||||
public const byte deathlava = 190;
|
||||
public const byte deathwater = 191;
|
||||
public const byte deathair = 192;
|
||||
|
||||
public const byte activedeathwater = 193;
|
||||
public const byte activedeathlava = 194;
|
||||
|
||||
@ -254,6 +253,7 @@ namespace MCGalaxy
|
||||
public const byte geyser = 196;
|
||||
public const byte checkpoint = 197;
|
||||
|
||||
// Air type blocks
|
||||
public const byte air_flood = 200;
|
||||
public const byte door_tree_air = 201;
|
||||
public const byte air_flood_layer = 202;
|
||||
@ -290,6 +290,7 @@ namespace MCGalaxy
|
||||
public const byte zombiebody = 232;
|
||||
public const byte zombiehead = 233;
|
||||
|
||||
// Bird blocks
|
||||
public const byte birdwhite = 235;
|
||||
public const byte birdblack = 236;
|
||||
public const byte birdwater = 237;
|
||||
@ -298,6 +299,7 @@ namespace MCGalaxy
|
||||
public const byte birdblue = 240;
|
||||
public const byte birdkill = 242;
|
||||
|
||||
// Fish/Shark blocks
|
||||
public const byte fishgold = 245;
|
||||
public const byte fishsponge = 246;
|
||||
public const byte fishshark = 247;
|
||||
|
@ -97,7 +97,7 @@ namespace MCGalaxy
|
||||
|
||||
public static bool OPBlocks(byte block) { return Props[block].OPBlock; }
|
||||
|
||||
public static bool Death(byte block) { return Props[block].CollisionDeath; }
|
||||
public static bool Death(byte block) { return Props[block].KillerBlock; }
|
||||
|
||||
public static bool BuildIn(byte block) {
|
||||
if (block == op_water || block == op_lava || portal(block) || mb(block)) return false;
|
||||
|
@ -36,8 +36,8 @@ namespace MCGalaxy.Blocks {
|
||||
/// <summary> Message shown to the level when the player is killed by this block. Can be null. </summary>
|
||||
public string DeathMessage;
|
||||
|
||||
/// <summary> Whether colliding with this block kills the player. </summary>
|
||||
public bool CollisionDeath;
|
||||
/// <summary> Whether colliding/walking through this block kills the player. </summary>
|
||||
public bool KillerBlock;
|
||||
|
||||
/// <summary> Whether this block is considered a tdoor. </summary>
|
||||
public bool IsTDoor;
|
||||
@ -55,9 +55,6 @@ namespace MCGalaxy.Blocks {
|
||||
/// <summary> Whether this block is overwritten/killed by lava blocks. </summary>
|
||||
public bool LavaKills;
|
||||
|
||||
/// <summary> Whether walkinhg through this block causes the death of that player. </summary>
|
||||
public bool CausesDeath;
|
||||
|
||||
/// <summary> Whether this block is an OP block (cannot be replaced by physics changes). </summary>
|
||||
public bool OPBlock;
|
||||
|
||||
|
@ -32,7 +32,7 @@ namespace MCGalaxy.Commands.World {
|
||||
if (args.Length < 3) { Help(p); return; }
|
||||
|
||||
string scope = args[0].ToLower();
|
||||
if (scope != "core" && scope != "global" && scope != "level") {
|
||||
if (scope != "core" && scope != "global" && scope != "level") {
|
||||
Player.Message(p, "&cScope must \"core\", \"global\", or \"level\""); return;
|
||||
}
|
||||
byte id;
|
||||
@ -43,36 +43,56 @@ namespace MCGalaxy.Commands.World {
|
||||
|
||||
// TODO: global and level custom blocks
|
||||
// TODO: adding core blocks, changing core block names
|
||||
if (scope != "core") {
|
||||
Player.Message(p, "Sorry! Custom blocks still a WIP."); return;
|
||||
}
|
||||
if (scope != "core") {
|
||||
Player.Message(p, "Sorry! Custom blocks still a WIP."); return;
|
||||
}
|
||||
if (Block.Name(id).CaselessEq("unknown")) {
|
||||
Player.Message(p, "Sorry! Adding blocks still a WIP."); return;
|
||||
}
|
||||
|
||||
if (prop == "portal") {
|
||||
ToggleBool(p, id, "a portal",
|
||||
(ref BlockProps props) => props.IsPortal = !props.IsPortal,
|
||||
(BlockProps props) => props.IsPortal);
|
||||
ToggleBool(p, id, "a portal",
|
||||
(ref BlockProps props) => props.IsPortal = !props.IsPortal,
|
||||
(BlockProps props) => props.IsPortal);
|
||||
} else if (prop == "rails") {
|
||||
ToggleBool(p, id, "train rails",
|
||||
(ref BlockProps props) => props.IsRails = !props.IsRails,
|
||||
(BlockProps props) => props.IsRails);
|
||||
ToggleBool(p, id, "train rails",
|
||||
(ref BlockProps props) => props.IsRails = !props.IsRails,
|
||||
(BlockProps props) => props.IsRails);
|
||||
} else if (prop == "mb" || prop == "messageblock") {
|
||||
ToggleBool(p, id, "a message block",
|
||||
(ref BlockProps props) => props.IsMessageBlock = !props.IsMessageBlock,
|
||||
(BlockProps props) => props.IsMessageBlock);
|
||||
ToggleBool(p, id, "a message block",
|
||||
(ref BlockProps props) => props.IsMessageBlock = !props.IsMessageBlock,
|
||||
(BlockProps props) => props.IsMessageBlock);
|
||||
} else if (prop == "waterkills") {
|
||||
ToggleBool(p, id, "killed by water",
|
||||
(ref BlockProps props) => props.WaterKills = !props.WaterKills,
|
||||
(BlockProps props) => props.WaterKills);
|
||||
} else if (prop == "lavakills") {
|
||||
ToggleBool(p, id, "killed by lava",
|
||||
(ref BlockProps props) => props.LavaKills = !props.LavaKills,
|
||||
(BlockProps props) => props.LavaKills);
|
||||
} else if (prop == "killer" || prop == "death") {
|
||||
ToggleBool(p, id, "a killer block",
|
||||
(ref BlockProps props) => props.KillerBlock = !props.KillerBlock,
|
||||
(BlockProps props) => props.KillerBlock);
|
||||
} else if (prop == "deathmsg" || prop == "deathmessage") {
|
||||
string msg = args.Length > 3 ? args[3] : null;
|
||||
Block.Props[id].DeathMessage = msg;
|
||||
if (msg == null) {
|
||||
Player.Message(p, "Death message for {0} removed.", Block.Name(id));
|
||||
} else {
|
||||
Player.Message(p, "Death message for {0} set to: {1}", Block.Name(id), msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
delegate void BoolSetter(ref BlockProps props);
|
||||
static void ToggleBool(Player p, byte id, string name, BoolSetter setter,
|
||||
delegate void BoolSetter(ref BlockProps props);
|
||||
static void ToggleBool(Player p, byte id, string name, BoolSetter setter,
|
||||
Func<BlockProps, bool> getter) {
|
||||
BlockProps props = Block.Props[id];
|
||||
setter(ref props);
|
||||
Block.Props[id] = props;
|
||||
|
||||
Player.Message(p, "Block {0} is {1}: {2}", Block.Name(id),
|
||||
Player.Message(p, "Block {0} is {1}: {2}", Block.Name(id),
|
||||
name, getter(props) ? "&aYes" : "&cNo");
|
||||
BlockBehaviour.SetupCoreHandlers();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user