mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-26 06:43:25 -04:00
Door block ids now less hardcoded.
This commit is contained in:
parent
5b9f2d9bc8
commit
3ebb37d142
@ -60,12 +60,12 @@ namespace MCGalaxy {
|
||||
walkthroughHandlers[Block.lava_door] = WalkthroughBehaviour.Door;
|
||||
|
||||
for (int i = 0; i < 256; i++) {
|
||||
if (Block.mb((byte)i)) {
|
||||
if (Properties[i].IsMessageBlock) {
|
||||
walkthroughHandlers[i] = (p, block, x, y, z) =>
|
||||
WalkthroughBehaviour.MessageBlock(p, block, x, y, z, true);
|
||||
deleteHandlers[i] = (p, block, x, y, z) =>
|
||||
WalkthroughBehaviour.MessageBlock(p, block, x, y, z, false);
|
||||
} else if (Block.portal((byte)i)) {
|
||||
} else if (Properties[i].IsPortal) {
|
||||
walkthroughHandlers[i] = (p, block, x, y, z) =>
|
||||
WalkthroughBehaviour.Portal(p, block, x, y, z, true);
|
||||
deleteHandlers[i] = (p, block, x, y, z) =>
|
||||
@ -73,7 +73,7 @@ namespace MCGalaxy {
|
||||
}
|
||||
|
||||
byte doorAir = Block.DoorAirs((byte)i); // if not 0, means i is a door block
|
||||
if (Block.tDoor((byte)i)) {
|
||||
if (Block.Properties[i].IsTDoor) {
|
||||
deleteHandlers[i] = DeleteBehaviour.RevertDoor;
|
||||
} else if (Block.odoor((byte)i) != Block.Zero) {
|
||||
deleteHandlers[i] = DeleteBehaviour.ODoor;
|
||||
|
@ -87,15 +87,15 @@ namespace MCGalaxy.BlockBehaviour {
|
||||
|
||||
internal static bool Door(Player p, byte block, ushort x, ushort y, ushort z) {
|
||||
if (p.level.physics != 0) {
|
||||
p.level.Blockchange(x, y, z, Block.DoorAirs(block), 0); return false;
|
||||
p.level.Blockchange(x, y, z, Block.Properties[block].DoorAirId, 0); return false;
|
||||
} else {
|
||||
p.RevertBlock(x, y, z); return true;
|
||||
}
|
||||
}
|
||||
|
||||
internal static bool ODoor(Player p, byte block, ushort x, ushort y, ushort z) {
|
||||
if (block == Block.odoor8 || block == Block.odoor8_air ) {
|
||||
p.level.Blockchange(x, y, z, Block.odoor(block), 0); return false;
|
||||
if (block == Block.odoor8 || block == Block.odoor8_air) {
|
||||
p.level.Blockchange(x, y, z, Block.Properties[block].ODoorId, 0); return false;
|
||||
} else {
|
||||
p.RevertBlock(x, y, z); return true;
|
||||
}
|
||||
|
@ -263,57 +263,7 @@ namespace MCGalaxy
|
||||
return b < CpeCount ? b : orange;
|
||||
}
|
||||
}
|
||||
public static byte SaveConvert(byte b)
|
||||
{
|
||||
switch (b)
|
||||
{
|
||||
case air_flood:
|
||||
case air_flood_layer:
|
||||
case air_flood_down:
|
||||
case air_flood_up:
|
||||
return air; //air_flood must be converted to air on save to prevent issues
|
||||
case door_tree_air: return door_tree;
|
||||
case door_obsidian_air: return door_obsidian;
|
||||
case door_glass_air: return door_glass;
|
||||
case door_stone_air: return door_stone;
|
||||
case door_leaves_air: return door_leaves;
|
||||
case door_sand_air: return door_sand;
|
||||
case door_wood_air: return door_wood;
|
||||
case door_green_air: return door_green;
|
||||
case door_tnt_air: return door_tnt;
|
||||
case door_stair_air: return door_stair;
|
||||
case air_switch_air: return air_switch;
|
||||
case water_door_air: return water_door;
|
||||
case lava_door_air: return lava_door;
|
||||
case air_door_air: return air_door;
|
||||
case door_iron_air: return door_iron;
|
||||
case door_gold_air: return door_gold;
|
||||
case door_dirt_air: return door_dirt;
|
||||
case door_grass_air: return door_grass;
|
||||
case door_blue_air: return door_blue;
|
||||
case door_book_air: return door_book;
|
||||
case door_cobblestone_air: return door_cobblestone;
|
||||
case door_red_air: return door_red;
|
||||
case door_darkpink_air: return door_darkpink;
|
||||
case door_darkgrey_air: return door_darkgrey;
|
||||
case door_lightgrey_air: return door_lightgrey;
|
||||
case door_white_air: return door_white;
|
||||
|
||||
case odoor1_air: return odoor1;
|
||||
case odoor2_air: return odoor2;
|
||||
case odoor3_air: return odoor3;
|
||||
case odoor4_air: return odoor4;
|
||||
case odoor5_air: return odoor5;
|
||||
case odoor6_air: return odoor6;
|
||||
case odoor7_air: return odoor7;
|
||||
case odoor8_air: return odoor8;
|
||||
case odoor9_air: return odoor9;
|
||||
case odoor10_air: return odoor10;
|
||||
case odoor11_air: return odoor11;
|
||||
case odoor12_air: return odoor12;
|
||||
|
||||
default: return b;
|
||||
}
|
||||
}
|
||||
public static byte SaveConvert(byte b) { return Properties[b].SaveConvertId; }
|
||||
}
|
||||
}
|
||||
|
@ -49,10 +49,14 @@ namespace MCGalaxy {
|
||||
Properties[i].ODoorId = (byte)(odoor1_air + (i - odoor1));
|
||||
if (i >= odoor8 && i <= odoor12)
|
||||
Properties[i].ODoorId = (byte)(odoor8_air + (i - odoor8));
|
||||
if (i >= odoor1_air && i <= odoor7_air)
|
||||
if (i >= odoor1_air && i <= odoor7_air) {
|
||||
Properties[i].ODoorId = (byte)(odoor1 + (i - odoor1_air));
|
||||
if (i >= odoor8_air && i <= odoor12_air)
|
||||
Properties[i].SaveConvertId = Properties[i].ODoorId;
|
||||
}
|
||||
if (i >= odoor8_air && i <= odoor12_air) {
|
||||
Properties[i].ODoorId = (byte)(odoor8 + (i - odoor8_air));
|
||||
Properties[i].SaveConvertId = Properties[i].ODoorId;
|
||||
}
|
||||
|
||||
if (i >= red && i <= white)
|
||||
Properties[i].KilledByLava = true;
|
||||
@ -60,13 +64,42 @@ namespace MCGalaxy {
|
||||
Properties[i].KilledByLava = true;
|
||||
Properties[i].KilledByWater = true;
|
||||
}
|
||||
|
||||
// Door blocks
|
||||
if (i >= door_obsidian && i <= door_stair)
|
||||
Door((byte)i, (byte)(door_obsidian_air + (i - door_obsidian)));
|
||||
if (i >= door_iron && i <= door_book)
|
||||
Door((byte)i, (byte)(door_iron_air + (i - door_iron)));
|
||||
if (i >= door_darkpink && i <= door_white)
|
||||
Door((byte)i, (byte)(door_darkpink_air + (i - door_darkpink)));
|
||||
}
|
||||
// Other door blocks, since they aren't in a consistent order
|
||||
Door(door_tree, door_tree_air);
|
||||
Door(door_red, door_red_air);
|
||||
Door(door_cobblestone, door_cobblestone_air);
|
||||
Door(door_gold, door_gold_air);
|
||||
Door(air_door, air_door_air);
|
||||
Door(air_switch, air_switch_air);
|
||||
Door(water_door, water_door_air);
|
||||
Door(lava_door, lava_door_air);
|
||||
|
||||
// Block specific properties
|
||||
Properties[air_flood].SaveConvertId = air;
|
||||
Properties[air_flood_down].SaveConvertId = air;
|
||||
Properties[air_flood_layer].SaveConvertId = air;
|
||||
Properties[air_flood_up].SaveConvertId = air;
|
||||
Properties[wood].KilledByLava = true; Properties[trunk].KilledByLava = true;
|
||||
Properties[sponge].KilledByLava = true; Properties[bookcase].KilledByLava = true;
|
||||
SetupDefaultNames();
|
||||
}
|
||||
|
||||
static void Door(byte doorId, byte airId, bool saveConvert = true) {
|
||||
Properties[doorId].DoorAirId = airId;
|
||||
Properties[airId].DoorId = doorId;
|
||||
if (saveConvert)
|
||||
Properties[airId].SaveConvertId = doorId;
|
||||
}
|
||||
|
||||
static void SetupDefaultNames() {
|
||||
string[] names = { "air", "stone", "grass", "dirt", "cobblestone", "wood", "plant",
|
||||
"adminium", "active_water", "water", "active_lava", "lava", "sand", "gravel",
|
||||
|
@ -16,6 +16,7 @@
|
||||
permissions and limitations under the Licenses.
|
||||
*/
|
||||
using System;
|
||||
using MCGalaxy.Blocks;
|
||||
|
||||
namespace MCGalaxy
|
||||
{
|
||||
@ -313,39 +314,7 @@ namespace MCGalaxy
|
||||
}
|
||||
}
|
||||
|
||||
public static byte DoorAirs(byte b)
|
||||
{
|
||||
switch (b)
|
||||
{
|
||||
case door_tree: return door_tree_air;
|
||||
case door_obsidian: return door_obsidian_air;
|
||||
case door_glass: return door_glass_air;
|
||||
case door_stone: return door_stone_air;
|
||||
case door_leaves: return door_leaves_air;
|
||||
case door_sand: return door_sand_air;
|
||||
case door_wood: return door_wood_air;
|
||||
case door_green: return door_green_air;
|
||||
case door_tnt: return door_tnt_air;
|
||||
case door_stair: return door_stair_air;
|
||||
case air_switch: return air_switch_air;
|
||||
case water_door: return water_door_air;
|
||||
case lava_door: return lava_door_air;
|
||||
case air_door: return air_door_air;
|
||||
case door_iron: return door_iron_air;
|
||||
case door_gold: return door_gold_air;
|
||||
case door_dirt: return door_dirt_air;
|
||||
case door_grass: return door_grass_air;
|
||||
case door_blue: return door_blue_air;
|
||||
case door_book: return door_book_air;
|
||||
case door_cobblestone: return door_cobblestone_air;
|
||||
case door_red: return door_red_air;
|
||||
case door_darkpink: return door_darkpink_air;
|
||||
case door_darkgrey: return door_darkgrey_air;
|
||||
case door_lightgrey: return door_lightgrey_air;
|
||||
case door_white: return door_white_air;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
public static byte DoorAirs(byte b) { return Properties[b].DoorAirId; }
|
||||
|
||||
public static bool tDoor(byte type) { return Properties[type].IsTDoor; }
|
||||
|
||||
|
@ -37,6 +37,8 @@ namespace MCGalaxy.Blocks {
|
||||
public bool IsTDoor;
|
||||
/// <summary> Block id this block is converted to when toggled by a neighbouring door. </summary>
|
||||
public byte ODoorId;
|
||||
public byte DoorId;
|
||||
public byte DoorAirId;
|
||||
|
||||
/// <summary> Whether this block is considered a message block. </summary>
|
||||
public bool IsMessageBlock;
|
||||
|
@ -16,6 +16,8 @@
|
||||
permissions and limitations under the Licenses.
|
||||
*/
|
||||
using System;
|
||||
using MCGalaxy.Blocks;
|
||||
|
||||
namespace MCGalaxy.Commands
|
||||
{
|
||||
public sealed class CmdBlocks : Command
|
||||
@ -92,6 +94,7 @@ namespace MCGalaxy.Commands
|
||||
{
|
||||
Player.SendMessage(p, "&bComplex information for \"" + message + "\":");
|
||||
Player.SendMessage(p, "&cBlock will appear as a \"" + Block.Name(Block.Convert(b)) + "\" block");
|
||||
BlockProps props = Block.Properties[b];
|
||||
|
||||
if (Block.LightPass(b, 0, BlockDefinition.GlobalDefs))
|
||||
Player.SendMessage(p, "Block will allow light through");
|
||||
@ -99,15 +102,15 @@ namespace MCGalaxy.Commands
|
||||
else Player.SendMessage(p, "Block will not affect physics in any way"); //It's AFFECT!
|
||||
if (Block.NeedRestart(b)) Player.SendMessage(p, "The block's physics will auto-start");
|
||||
|
||||
if (Block.OPBlocks(b)) Player.SendMessage(p, "Block is unaffected by explosions");
|
||||
if (props.OPBlock) Player.SendMessage(p, "Block is unaffected by explosions");
|
||||
|
||||
if (Block.AllowBreak(b)) Player.SendMessage(p, "Anybody can activate the block");
|
||||
if (Block.Walkthrough(b)) Player.SendMessage(p, "Block can be walked through");
|
||||
if (Block.Death(b)) Player.SendMessage(p, "Walking through block will kill you");
|
||||
|
||||
if (Block.DoorAirs(b) != (byte)0) Player.SendMessage(p, "Block is an ordinary door");
|
||||
if (Block.tDoor(b)) Player.SendMessage(p, "Block is a tdoor, which allows other blocks through when open");
|
||||
if (Block.odoor(b) != Block.Zero) Player.SendMessage(p, "Block is an odoor, which toggles (GLITCHY)");
|
||||
if (props.DoorAirId != 0) Player.SendMessage(p, "Block is an ordinary door");
|
||||
if (props.IsTDoor) Player.SendMessage(p, "Block is a tdoor, which allows other blocks through when open");
|
||||
if (props.ODoorId != Block.Zero) Player.SendMessage(p, "Block is an odoor, which toggles (GLITCHY)");
|
||||
|
||||
if (Block.Mover(b)) Player.SendMessage(p, "Block can be activated by walking through it");
|
||||
}
|
||||
|
@ -341,7 +341,7 @@ namespace MCGalaxy {
|
||||
|
||||
errorLocation = "Adding physics";
|
||||
if (p.PlayingTntWars && type == Block.smalltnt) AddCheck(PosToInt(x, y, z), false);
|
||||
if (physics > 0) if (Block.Physics(type)) AddCheck(PosToInt(x, y, z), false);
|
||||
if (physics > 0 && Block.Physics(type)) AddCheck(PosToInt(x, y, z), false);
|
||||
|
||||
changed = true;
|
||||
backedup = false;
|
||||
@ -389,7 +389,8 @@ namespace MCGalaxy {
|
||||
try
|
||||
{
|
||||
if (!overRide)
|
||||
if (Block.OPBlocks(oldBlock) || (Block.OPBlocks(type) && data.Raw != 0)) return false;
|
||||
if (Block.Properties[oldBlock].OPBlock || (Block.Properties[type].OPBlock && data.Raw != 0))
|
||||
return false;
|
||||
|
||||
if (b == Block.sponge && physics > 0 && type != Block.sponge)
|
||||
OtherPhysics.DoSpongeRemoved(this, b);
|
||||
|
@ -105,7 +105,7 @@ namespace MCGalaxy.BlockPhysics {
|
||||
if (C.time < timer) {
|
||||
C.time++;
|
||||
} else {
|
||||
lvl.AddUpdate(C.b, Block.SaveConvert(lvl.blocks[C.b])); //turn back into door
|
||||
lvl.AddUpdate(C.b, Block.Properties[lvl.blocks[C.b]].DoorId);
|
||||
C.time = 255;
|
||||
}
|
||||
}
|
||||
@ -124,7 +124,7 @@ namespace MCGalaxy.BlockPhysics {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Block.tDoor(rawBlock)) {
|
||||
if (Block.Properties[rawBlock].IsTDoor) {
|
||||
PhysicsArgs args = default(PhysicsArgs);
|
||||
args.Type1 = PhysicsArgs.Wait; args.Value1 = 16;
|
||||
args.Type2 = PhysicsArgs.Revert; args.Value2 = rawBlock;
|
||||
|
@ -57,7 +57,7 @@ namespace MCGalaxy.BlockPhysics {
|
||||
if (index < 0 || index >= lvl.blocks.Length) return;
|
||||
byte block = lvl.blocks[index];
|
||||
|
||||
if (Block.tDoor(block)) {
|
||||
if (Block.Properties[block].IsTDoor) {
|
||||
PhysicsArgs args = default(PhysicsArgs);
|
||||
args.Type1 = PhysicsArgs.Wait; args.Value1 = 10;
|
||||
args.Type2 = PhysicsArgs.Revert; args.Value2 = block;
|
||||
|
@ -112,7 +112,7 @@ namespace MCGalaxy.BlockPhysics {
|
||||
Random rand = new Random();
|
||||
if ((lvl.physics < 2 || lvl.physics == 5) && !force) return;
|
||||
int index = lvl.PosToInt(x, y, z);
|
||||
if (index >= 0 && !Block.OPBlocks(lvl.blocks[index]))
|
||||
if (index >= 0 && !Block.Properties[lvl.blocks[index]].OPBlock)
|
||||
lvl.AddUpdate(index, Block.tntexplosion, true);
|
||||
|
||||
Explode(lvl, x, y, z, size + 1, rand, -1, game);
|
||||
|
Loading…
x
Reference in New Issue
Block a user