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;
|
using MCGalaxy.Blocks;
|
||||||
|
|
||||||
namespace MCGalaxy {
|
namespace MCGalaxy {
|
||||||
|
|
||||||
public sealed partial class Block {
|
public sealed partial class Block {
|
||||||
|
|
||||||
public static BlockProps[] Properties = new BlockProps[256];
|
public static BlockProps[] Properties = new BlockProps[256];
|
||||||
|
|
||||||
static void SetDefaultProperties() {
|
static void SetCoreProperties() {
|
||||||
for (int i = 0; i < 256; i++) {
|
for (int i = 0; i < 256; i++) {
|
||||||
Properties[i] = new BlockProps((byte)i);
|
Properties[i] = new BlockProps((byte)i);
|
||||||
// Fallback for unrecognised physics blocks
|
// Fallback for unrecognised physics blocks
|
||||||
if (i >= Block.CpeCount)
|
if (i >= CpeCount) Properties[i].ConvertId = Block.orange;
|
||||||
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() {
|
public static void SetBlocks() {
|
||||||
SetupCoreHandlers();
|
SetCoreProperties();
|
||||||
|
SetupCoreHandlers();
|
||||||
InitDefaults();
|
InitDefaults();
|
||||||
|
|
||||||
// Custom permissions set by the user.
|
// Custom permissions set by the user.
|
||||||
if (File.Exists("properties/block.properties")) {
|
if (File.Exists("properties/block.properties")) {
|
||||||
string[] lines = File.ReadAllLines("properties/block.properties");
|
string[] lines = File.ReadAllLines("properties/block.properties");
|
||||||
|
130
Blocks/Block.cs
130
Blocks/Block.cs
@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2010 MCSharp team (Modified for use with MCZall/MCLawl/MCGalaxy)
|
Copyright 2010 MCSharp team (Modified for use with MCZall/MCLawl/MCGalaxy)
|
||||||
|
|
||||||
Dual-licensed under the Educational Community License, Version 2.0 and
|
Dual-licensed under the Educational Community License, Version 2.0 and
|
||||||
the GNU General Public License, Version 3 (the "Licenses"); you may
|
the GNU General Public License, Version 3 (the "Licenses"); you may
|
||||||
not use this file except in compliance with the Licenses. You may
|
not use this file except in compliance with the Licenses. You may
|
||||||
obtain a copy of the Licenses at
|
obtain a copy of the Licenses at
|
||||||
|
|
||||||
http://www.opensource.org/licenses/ecl2.php
|
http://www.opensource.org/licenses/ecl2.php
|
||||||
http://www.gnu.org/licenses/gpl-3.0.html
|
http://www.gnu.org/licenses/gpl-3.0.html
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing,
|
Unless required by applicable law or agreed to in writing,
|
||||||
software distributed under the Licenses are distributed on an "AS IS"
|
software distributed under the Licenses are distributed on an "AS IS"
|
||||||
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||||
or implied. See the Licenses for the specific language governing
|
or implied. See the Licenses for the specific language governing
|
||||||
permissions and limitations under the Licenses.
|
permissions and limitations under the Licenses.
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ namespace MCGalaxy
|
|||||||
case Block.door_tnt:
|
case Block.door_tnt:
|
||||||
case Block.door_stair:
|
case Block.door_stair:
|
||||||
case door_iron:
|
case door_iron:
|
||||||
case door_gold:
|
case door_gold:
|
||||||
case door_dirt:
|
case door_dirt:
|
||||||
case door_grass:
|
case door_grass:
|
||||||
case door_blue:
|
case door_blue:
|
||||||
@ -102,14 +102,14 @@ namespace MCGalaxy
|
|||||||
{
|
{
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
// case Block.air:
|
// case Block.air:
|
||||||
// case Block.grass:
|
// case Block.grass:
|
||||||
case Block.blackrock:
|
case Block.blackrock:
|
||||||
case Block.water:
|
case Block.water:
|
||||||
case Block.waterstill:
|
case Block.waterstill:
|
||||||
case Block.lava:
|
case Block.lava:
|
||||||
case Block.lavastill:
|
case Block.lavastill:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return type < Block.CpeCount;
|
return type < Block.CpeCount;
|
||||||
}
|
}
|
||||||
@ -129,26 +129,7 @@ namespace MCGalaxy
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool OPBlocks(byte type)
|
public static bool OPBlocks(byte type) { return Properties[type].OPBlock; }
|
||||||
{
|
|
||||||
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 Death(byte type)
|
public static bool Death(byte type)
|
||||||
{
|
{
|
||||||
@ -202,18 +183,18 @@ namespace MCGalaxy
|
|||||||
|
|
||||||
public static bool Mover(byte type)
|
public static bool Mover(byte type)
|
||||||
{
|
{
|
||||||
return walkthroughHandlers[type] != null;
|
return walkthroughHandlers[type] != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool FireKill(byte type) {
|
public static bool FireKill(byte type) {
|
||||||
return type != Block.air && LavaKill(type);
|
return type != Block.air && LavaKill(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool LavaKill(byte type)
|
public static bool LavaKill(byte type)
|
||||||
{
|
{
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case Block.air:
|
case Block.air:
|
||||||
case Block.wood:
|
case Block.wood:
|
||||||
case Block.shrub:
|
case Block.shrub:
|
||||||
case Block.trunk:
|
case Block.trunk:
|
||||||
@ -318,32 +299,9 @@ namespace MCGalaxy
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool portal(byte type)
|
public static bool portal(byte type) { return Properties[type].IsPortal; }
|
||||||
{
|
|
||||||
switch (type)
|
public static bool mb(byte type) { return Properties[type].IsMessageBlock; }
|
||||||
{
|
|
||||||
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 Physics(byte type) //returns false if placing block cant actualy cause any physics to happen
|
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_tnt:
|
||||||
case Block.door_stair:
|
case Block.door_stair:
|
||||||
case door_iron:
|
case door_iron:
|
||||||
case door_gold:
|
case door_gold:
|
||||||
case door_dirt:
|
case door_dirt:
|
||||||
case door_grass:
|
case door_grass:
|
||||||
case door_blue:
|
case door_blue:
|
||||||
@ -469,7 +427,7 @@ namespace MCGalaxy
|
|||||||
case lava_door: return lava_door_air;
|
case lava_door: return lava_door_air;
|
||||||
case air_door: return air_door_air;
|
case air_door: return air_door_air;
|
||||||
case door_iron: return door_iron_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_dirt: return door_dirt_air;
|
||||||
case door_grass: return door_grass_air;
|
case door_grass: return door_grass_air;
|
||||||
case door_blue: return door_blue_air;
|
case door_blue: return door_blue_air;
|
||||||
@ -484,27 +442,7 @@ namespace MCGalaxy
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool tDoor(byte b)
|
public static bool tDoor(byte type) { return Properties[type].IsTDoor; }
|
||||||
{
|
|
||||||
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 byte odoor(byte b)
|
public static byte odoor(byte b)
|
||||||
{
|
{
|
||||||
|
@ -18,39 +18,43 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace MCGalaxy.Blocks {
|
namespace MCGalaxy.Blocks {
|
||||||
|
|
||||||
public struct BlockProps {
|
public struct BlockProps {
|
||||||
|
|
||||||
/// <summary> Standard block id sent to clients in map and block update packets. </summary>
|
/// <summary> ID of block these properties are associated with. </summary>
|
||||||
public byte ConvertId;
|
public byte BlockId;
|
||||||
|
|
||||||
/// <summary> Block id converted to when the map is saved to a .lvl file. </summary>
|
/// <summary> Standard block id sent to clients in map and block update packets. </summary>
|
||||||
public byte SaveConvertId;
|
public byte ConvertId;
|
||||||
|
|
||||||
/// <summary> Block name used for in commands. </summary>
|
/// <summary> Block id converted to when the map is saved to a .lvl file. </summary>
|
||||||
public string Name;
|
public byte SaveConvertId;
|
||||||
|
|
||||||
/// <summary> Whether this block is considered a tdoor. </summary>
|
/// <summary> Block name used for in commands. </summary>
|
||||||
public bool IsTDoor;
|
public string Name;
|
||||||
/// <summary> Whether this block is considered a message block. </summary>
|
|
||||||
public bool IsMessageBlock;
|
/// <summary> Whether this block is considered a tdoor. </summary>
|
||||||
/// <summary> Whether this block is considered a portal. </summary>
|
public bool IsTDoor;
|
||||||
public bool IsPortal;
|
/// <summary> Whether this block is considered a message block. </summary>
|
||||||
|
public bool IsMessageBlock;
|
||||||
/// <summary> Whether walkinhg through this block causes the death of that player. </summary>
|
/// <summary> Whether this block is considered a portal. </summary>
|
||||||
public bool CausesDeath;
|
public bool IsPortal;
|
||||||
|
|
||||||
/// <summary> Whether light passes through this block. </summary>
|
/// <summary> Whether walkinhg through this block causes the death of that player. </summary>
|
||||||
public bool LightPasses;
|
public bool CausesDeath;
|
||||||
|
|
||||||
/// <summary> Whether this block is an OP block (cannot be replaced by physics changes). </summary>
|
/// <summary> Whether light passes through this block. </summary>
|
||||||
public bool OPBlock;
|
public bool LightPasses;
|
||||||
|
|
||||||
public BlockProps(byte type) {
|
/// <summary> Whether this block is an OP block (cannot be replaced by physics changes). </summary>
|
||||||
this = default(BlockProps);
|
public bool OPBlock;
|
||||||
ConvertId = type;
|
|
||||||
SaveConvertId = type;
|
public BlockProps(byte type) {
|
||||||
Name = "unknown";
|
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\PlaceBehaviour.cs" />
|
||||||
<Compile Include="Blocks\Behaviour\WalkthroughBehaviour.cs" />
|
<Compile Include="Blocks\Behaviour\WalkthroughBehaviour.cs" />
|
||||||
<Compile Include="Blocks\Block.Convert.cs" />
|
<Compile Include="Blocks\Block.Convert.cs" />
|
||||||
|
<Compile Include="Blocks\Block.CoreProps.cs" />
|
||||||
<Compile Include="Blocks\Block.cs" />
|
<Compile Include="Blocks\Block.cs" />
|
||||||
<Compile Include="Blocks\Block.ID.cs" />
|
<Compile Include="Blocks\Block.ID.cs" />
|
||||||
<Compile Include="Blocks\Block.Permissions.cs" />
|
<Compile Include="Blocks\Block.Permissions.cs" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user