diff --git a/Blocks/Block.CoreProps.cs b/Blocks/Block.CoreProps.cs
index 09f7e12ae..0ec519414 100644
--- a/Blocks/Block.CoreProps.cs
+++ b/Blocks/Block.CoreProps.cs
@@ -19,16 +19,30 @@ using System;
using MCGalaxy.Blocks;
namespace MCGalaxy {
+
public sealed partial class Block {
+
public static BlockProps[] Properties = new BlockProps[256];
- static void SetDefaultProperties() {
+ static void SetCoreProperties() {
for (int i = 0; i < 256; i++) {
Properties[i] = new BlockProps((byte)i);
// Fallback for unrecognised physics blocks
- if (i >= Block.CpeCount)
- Properties[i].ConvertId = Block.orange;
+ if (i >= CpeCount) Properties[i].ConvertId = Block.orange;
+
+ if ((i >= op_glass && i <= op_lava) || i == Zero || i == rocketstart || i == blackrock)
+ Properties[i].OPBlock = true;
+
+ if ((i >= tdoor && i <= tdoor8) || (i >= tdoor9 && i <= tdoor13))
+ Properties[i].IsTDoor = true;
+
+ if (i >= MsgWhite && i <= MsgLava)
+ Properties[i].IsMessageBlock = true;
+
+ if (i == blue_portal || i == orange_portal || (i >= air_portal && i <= lava_portal))
+ Properties[i].IsPortal = true;
}
+
}
}
}
diff --git a/Blocks/Block.Permissions.cs b/Blocks/Block.Permissions.cs
index f77bada8d..d33e920b4 100644
--- a/Blocks/Block.Permissions.cs
+++ b/Blocks/Block.Permissions.cs
@@ -46,8 +46,10 @@ namespace MCGalaxy
}
public static void SetBlocks() {
- SetupCoreHandlers();
+ SetCoreProperties();
+ SetupCoreHandlers();
InitDefaults();
+
// Custom permissions set by the user.
if (File.Exists("properties/block.properties")) {
string[] lines = File.ReadAllLines("properties/block.properties");
diff --git a/Blocks/Block.cs b/Blocks/Block.cs
index e3913f559..a363b5b38 100644
--- a/Blocks/Block.cs
+++ b/Blocks/Block.cs
@@ -1,19 +1,19 @@
/*
- Copyright 2010 MCSharp team (Modified for use with MCZall/MCLawl/MCGalaxy)
-
- Dual-licensed under the Educational Community License, Version 2.0 and
- the GNU General Public License, Version 3 (the "Licenses"); you may
- not use this file except in compliance with the Licenses. You may
- obtain a copy of the Licenses at
-
- http://www.opensource.org/licenses/ecl2.php
- http://www.gnu.org/licenses/gpl-3.0.html
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the Licenses are distributed on an "AS IS"
- BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- or implied. See the Licenses for the specific language governing
- permissions and limitations under the Licenses.
+ Copyright 2010 MCSharp team (Modified for use with MCZall/MCLawl/MCGalaxy)
+
+ Dual-licensed under the Educational Community License, Version 2.0 and
+ the GNU General Public License, Version 3 (the "Licenses"); you may
+ not use this file except in compliance with the Licenses. You may
+ obtain a copy of the Licenses at
+
+ http://www.opensource.org/licenses/ecl2.php
+ http://www.gnu.org/licenses/gpl-3.0.html
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the Licenses are distributed on an "AS IS"
+ BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ or implied. See the Licenses for the specific language governing
+ permissions and limitations under the Licenses.
*/
using System;
@@ -61,7 +61,7 @@ namespace MCGalaxy
case Block.door_tnt:
case Block.door_stair:
case door_iron:
- case door_gold:
+ case door_gold:
case door_dirt:
case door_grass:
case door_blue:
@@ -102,14 +102,14 @@ namespace MCGalaxy
{
switch (type)
{
- // case Block.air:
- // case Block.grass:
- case Block.blackrock:
- case Block.water:
- case Block.waterstill:
- case Block.lava:
- case Block.lavastill:
- return false;
+ // case Block.air:
+ // case Block.grass:
+ case Block.blackrock:
+ case Block.water:
+ case Block.waterstill:
+ case Block.lava:
+ case Block.lavastill:
+ return false;
}
return type < Block.CpeCount;
}
@@ -129,26 +129,7 @@ namespace MCGalaxy
return false;
}
- public static bool OPBlocks(byte type)
- {
- switch (type)
- {
- case Block.blackrock:
- case Block.op_air:
- case Block.op_brick:
- case Block.op_cobblestone:
- case Block.op_glass:
- case Block.op_stone:
- case Block.op_water:
- case Block.op_lava:
- case Block.opsidian:
- case Block.rocketstart:
-
- case Block.Zero:
- return true;
- }
- return false;
- }
+ public static bool OPBlocks(byte type) { return Properties[type].OPBlock; }
public static bool Death(byte type)
{
@@ -202,18 +183,18 @@ namespace MCGalaxy
public static bool Mover(byte type)
{
- return walkthroughHandlers[type] != null;
+ return walkthroughHandlers[type] != null;
}
public static bool FireKill(byte type) {
- return type != Block.air && LavaKill(type);
+ return type != Block.air && LavaKill(type);
}
public static bool LavaKill(byte type)
{
switch (type)
{
- case Block.air:
+ case Block.air:
case Block.wood:
case Block.shrub:
case Block.trunk:
@@ -318,32 +299,9 @@ namespace MCGalaxy
return false;
}
- public static bool portal(byte type)
- {
- switch (type)
- {
- case Block.blue_portal:
- case Block.orange_portal:
- case Block.air_portal:
- case Block.water_portal:
- case Block.lava_portal:
- return true;
- }
- return false;
- }
- public static bool mb(byte type)
- {
- switch (type)
- {
- case Block.MsgAir:
- case Block.MsgWater:
- case Block.MsgLava:
- case Block.MsgBlack:
- case Block.MsgWhite:
- return true;
- }
- return false;
- }
+ public static bool portal(byte type) { return Properties[type].IsPortal; }
+
+ public static bool mb(byte type) { return Properties[type].IsMessageBlock; }
public static bool Physics(byte type) //returns false if placing block cant actualy cause any physics to happen
{
@@ -385,7 +343,7 @@ namespace MCGalaxy
case Block.door_tnt:
case Block.door_stair:
case door_iron:
- case door_gold:
+ case door_gold:
case door_dirt:
case door_grass:
case door_blue:
@@ -469,7 +427,7 @@ namespace MCGalaxy
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_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;
@@ -484,27 +442,7 @@ namespace MCGalaxy
}
}
- public static bool tDoor(byte b)
- {
- switch (b)
- {
- case tdoor:
- case tdoor2:
- case tdoor3:
- case tdoor4:
- case tdoor5:
- case tdoor6:
- case tdoor7:
- case tdoor8:
- case tdoor9:
- case tdoor10:
- case tdoor11:
- case tdoor12:
- case tdoor13:
- return true;
- }
- return false;
- }
+ public static bool tDoor(byte type) { return Properties[type].IsTDoor; }
public static byte odoor(byte b)
{
diff --git a/Blocks/BlockProps.cs b/Blocks/BlockProps.cs
index f875823a8..d2239886c 100644
--- a/Blocks/BlockProps.cs
+++ b/Blocks/BlockProps.cs
@@ -18,39 +18,43 @@
using System;
namespace MCGalaxy.Blocks {
-
- public struct BlockProps {
-
- /// Standard block id sent to clients in map and block update packets.
- public byte ConvertId;
-
- /// Block id converted to when the map is saved to a .lvl file.
- public byte SaveConvertId;
-
- /// Block name used for in commands.
- public string Name;
-
- /// Whether this block is considered a tdoor.
- public bool IsTDoor;
- /// Whether this block is considered a message block.
- public bool IsMessageBlock;
- /// Whether this block is considered a portal.
- public bool IsPortal;
-
- /// Whether walkinhg through this block causes the death of that player.
- public bool CausesDeath;
-
- /// Whether light passes through this block.
- public bool LightPasses;
-
- /// Whether this block is an OP block (cannot be replaced by physics changes).
- public bool OPBlock;
-
- public BlockProps(byte type) {
- this = default(BlockProps);
- ConvertId = type;
- SaveConvertId = type;
- Name = "unknown";
- }
- }
+
+ public struct BlockProps {
+
+ /// ID of block these properties are associated with.
+ public byte BlockId;
+
+ /// Standard block id sent to clients in map and block update packets.
+ public byte ConvertId;
+
+ /// Block id converted to when the map is saved to a .lvl file.
+ public byte SaveConvertId;
+
+ /// Block name used for in commands.
+ public string Name;
+
+ /// Whether this block is considered a tdoor.
+ public bool IsTDoor;
+ /// Whether this block is considered a message block.
+ public bool IsMessageBlock;
+ /// Whether this block is considered a portal.
+ public bool IsPortal;
+
+ /// Whether walkinhg through this block causes the death of that player.
+ public bool CausesDeath;
+
+ /// Whether light passes through this block.
+ public bool LightPasses;
+
+ /// Whether this block is an OP block (cannot be replaced by physics changes).
+ public bool OPBlock;
+
+ public BlockProps(byte type) {
+ this = default(BlockProps);
+ BlockId = type;
+ ConvertId = type;
+ SaveConvertId = type;
+ Name = "unknown";
+ }
+ }
}
diff --git a/MCGalaxy_.csproj b/MCGalaxy_.csproj
index be1bed2b9..1f8578e12 100644
--- a/MCGalaxy_.csproj
+++ b/MCGalaxy_.csproj
@@ -106,6 +106,7 @@
+