mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-25 14:17:29 -04:00
And so it begins round 2.. start making block properties extensible.
This commit is contained in:
parent
4645049cf6
commit
f36ca95686
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -46,8 +46,10 @@ namespace MCGalaxy
|
||||
}
|
||||
|
||||
public static void SetBlocks() {
|
||||
SetCoreProperties();
|
||||
SetupCoreHandlers();
|
||||
InitDefaults();
|
||||
|
||||
// Custom permissions set by the user.
|
||||
if (File.Exists("properties/block.properties")) {
|
||||
string[] lines = File.ReadAllLines("properties/block.properties");
|
||||
|
@ -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)
|
||||
{
|
||||
@ -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
|
||||
{
|
||||
@ -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)
|
||||
{
|
||||
|
@ -21,6 +21,9 @@ namespace MCGalaxy.Blocks {
|
||||
|
||||
public struct BlockProps {
|
||||
|
||||
/// <summary> ID of block these properties are associated with. </summary>
|
||||
public byte BlockId;
|
||||
|
||||
/// <summary> Standard block id sent to clients in map and block update packets. </summary>
|
||||
public byte ConvertId;
|
||||
|
||||
@ -48,6 +51,7 @@ namespace MCGalaxy.Blocks {
|
||||
|
||||
public BlockProps(byte type) {
|
||||
this = default(BlockProps);
|
||||
BlockId = type;
|
||||
ConvertId = type;
|
||||
SaveConvertId = type;
|
||||
Name = "unknown";
|
||||
|
@ -106,6 +106,7 @@
|
||||
<Compile Include="Blocks\Behaviour\PlaceBehaviour.cs" />
|
||||
<Compile Include="Blocks\Behaviour\WalkthroughBehaviour.cs" />
|
||||
<Compile Include="Blocks\Block.Convert.cs" />
|
||||
<Compile Include="Blocks\Block.CoreProps.cs" />
|
||||
<Compile Include="Blocks\Block.cs" />
|
||||
<Compile Include="Blocks\Block.ID.cs" />
|
||||
<Compile Include="Blocks\Block.Permissions.cs" />
|
||||
|
Loading…
x
Reference in New Issue
Block a user