Add rope/lader collide type 7

This commit is contained in:
UnknownShadow200 2018-03-10 19:38:41 +11:00
parent c61f3cb326
commit 2376994210
7 changed files with 10 additions and 3 deletions

View File

@ -61,6 +61,8 @@ namespace ClassicalSharp {
/// <summary> Lava style 'swimming'/'bobbing' interaction when player collides. </summary>
public const byte LiquidLava = 6;
public const byte ClimbRope = 7;
}
/// <summary> Stores various properties about the blocks. </summary>

View File

@ -54,6 +54,8 @@ namespace ClassicalSharp.Blocks {
}
public static byte MapOldCollide(BlockID b, byte collide) {
if (b == Block.Rope && collide == CollideType.Gas)
return CollideType.ClimbRope;
if (b == Block.Ice && collide == CollideType.Solid)
return CollideType.Ice;
if ((b == Block.Water || b == Block.StillWater) && collide == CollideType.Liquid)

View File

@ -214,7 +214,7 @@ namespace ClassicalSharp.Entities {
return TouchesAny(bounds, touchesRope);
}
static Predicate<BlockID> touchesRope = IsRope;
static bool IsRope(BlockID b) { return b == Block.Rope; }
static bool IsRope(BlockID b) { return BlockInfo.ExtendedCollide[b] == CollideType.ClimbRope; }
static readonly Vector3 liqExpand = new Vector3(0.25f/16f, 0/16f, 0.25f/16f);

View File

@ -138,7 +138,7 @@ namespace ClassicalSharp.Singleplayer {
BlockID block = map.blocks[posIndex];
if (block == Block.Lava || block == Block.StillLava) {
game.UpdateBlock(x, y, z, Block.Stone);
} else if (BlockInfo.Collide[block] == CollideType.Gas && block != Block.Rope) {
} else if (BlockInfo.ExtendedCollide[block] == CollideType.Gas) {
// Sponge check
for (int yy = (y < 2 ? 0 : y - 2); yy <= (y > maxWaterY ? maxY : y + 2); yy++)
for (int zz = (z < 2 ? 0 : z - 2); zz <= (z > maxWaterZ ? maxZ : z + 2); zz++)

View File

@ -616,6 +616,8 @@ UInt8 DefaultSet_Collide(BlockID b) {
}
UInt8 DefaultSet_MapOldCollide(BlockID b, UInt8 collide) {
if (b == BLOCK_ROPE && collide == COLLIDE_GAS)
return COLLIDE_CLIMB_ROPE;
if (b == BLOCK_ICE && collide == COLLIDE_SOLID)
return COLLIDE_ICE;
if ((b == BLOCK_WATER || b == BLOCK_STILL_WATER) && collide == COLLIDE_LIQUID)

View File

@ -39,6 +39,7 @@
#define COLLIDE_SLIPPERY_ICE 4 /* Block is solid and fully slidable on. */
#define COLLIDE_LIQUID_WATER 5 /* Water style 'swimming'/'bobbing' interaction when player collides. */
#define COLLIDE_LIQUID_LAVA 6 /* Lava style 'swimming'/'bobbing' interaction when player collides. */
#define COLLIDE_CLIMB_ROPE 7 /* Rope/Ladder style climbing interaction when player collides */
UInt8 Block_NamesBuffer[String_BufferSize(STRING_SIZE) * BLOCK_COUNT];
#define Block_NamePtr(i) &Block_NamesBuffer[String_BufferSize(STRING_SIZE) * i]

View File

@ -190,7 +190,7 @@ bool Entity_TouchesAny(AABB* bounds, TouchesAny_Condition condition) {
return false;
}
bool Entity_IsRope(BlockID b) { return b == BLOCK_ROPE; }
bool Entity_IsRope(BlockID b) { return Block_ExtendedCollide[b] == COLLIDE_CLIMB_ROPE; }
bool Entity_TouchesAnyRope(Entity* entity) {
AABB bounds; Entity_GetBounds(entity, &bounds);
bounds.Max.Y += 0.5f / 16.0f;