mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-18 12:05:14 -04:00
fix block ID 255 not showing in inventory
This commit is contained in:
parent
f5e508ceb1
commit
8bdecb71fc
@ -232,7 +232,7 @@ namespace ClassicalSharp.Gui.Widgets {
|
||||
}
|
||||
|
||||
bool Show(BlockID block) {
|
||||
if (block == Block.Invalid) return false;
|
||||
if (block == Block.Air) return false;
|
||||
|
||||
if (block < Block.CpeCount) {
|
||||
int count = game.UseCPEBlocks ? Block.CpeCount : Block.OriginalCount;
|
||||
|
@ -100,16 +100,16 @@ namespace ClassicalSharp {
|
||||
for (int i = 0; i < Map.Length; i++) Map[i] = (BlockID)i;
|
||||
for (int i = 0; i < Map.Length; i++) {
|
||||
BlockID mapping = DefaultMapping(i);
|
||||
if (game.PureClassic && IsHackBlock(mapping)) mapping = Block.Invalid;
|
||||
if (game.PureClassic && IsHackBlock(mapping)) mapping = Block.Air;
|
||||
if (mapping != i) Map[i] = mapping;
|
||||
}
|
||||
}
|
||||
|
||||
BlockID DefaultMapping(int i) {
|
||||
#if USE16_BIT
|
||||
if ((i >= Block.CpeCount && i < 256) || i == Block.Air) return Block.Invalid;
|
||||
if ((i >= Block.CpeCount && i < 256) || i == Block.Air) return Block.Air;
|
||||
#else
|
||||
if (i >= Block.CpeCount || i == Block.Air) return Block.Invalid;
|
||||
if (i >= Block.CpeCount || i == Block.Air) return Block.Air;
|
||||
#endif
|
||||
if (!game.ClassicMode) return (BlockID)i;
|
||||
|
||||
@ -178,14 +178,14 @@ namespace ClassicalSharp {
|
||||
|
||||
public void Remove(BlockID block) {
|
||||
for (int i = 0; i < Map.Length; i++) {
|
||||
if (Map[i] == block) Map[i] = Block.Invalid;
|
||||
if (Map[i] == block) Map[i] = Block.Air;
|
||||
}
|
||||
}
|
||||
|
||||
public void Insert(int i, BlockID block) {
|
||||
if (Map[i] == block) return;
|
||||
// Need to push the old block to a different slot if different block
|
||||
if (Map[i] != Block.Invalid) PushToFreeSlots(i);
|
||||
if (Map[i] != Block.Air) PushToFreeSlots(i);
|
||||
|
||||
Map[i] = block;
|
||||
}
|
||||
@ -199,10 +199,10 @@ namespace ClassicalSharp {
|
||||
}
|
||||
|
||||
for (int j = block; j < Map.Length; j++) {
|
||||
if (Map[j] == Block.Invalid) { Map[j] = block; return; }
|
||||
if (Map[j] == Block.Air) { Map[j] = block; return; }
|
||||
}
|
||||
for (int j = 1; j < block; j++) {
|
||||
if (Map[j] == Block.Invalid) { Map[j] = block; return; }
|
||||
if (Map[j] == Block.Air) { Map[j] = block; return; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -47,9 +47,9 @@ bool Inventory_IsHackBlock(BlockID b) {
|
||||
|
||||
BlockID Inventory_DefaultMapping(Int32 i) {
|
||||
#if USE16_BIT
|
||||
if ((i >= Block_CpeCount && i < 256) || i == BLOCK_AIR) return BLOCK_INVALID;
|
||||
if ((i >= Block_CpeCount && i < 256) || i == BLOCK_AIR) return BLOCK_AIR;
|
||||
#else
|
||||
if (i >= BLOCK_CPE_COUNT || i == BLOCK_AIR) return BLOCK_INVALID;
|
||||
if (i >= BLOCK_CPE_COUNT || i == BLOCK_AIR) return BLOCK_AIR;
|
||||
#endif
|
||||
if (!Game_ClassicMode) return (BlockID)i;
|
||||
|
||||
@ -101,7 +101,7 @@ void Inventory_SetDefaultMapping(void) {
|
||||
for (i = 0; i < Array_NumElements(Inventory_Map); i++) {
|
||||
BlockID mapping = Inventory_DefaultMapping(i);
|
||||
if (Game_PureClassic && Inventory_IsHackBlock(mapping)) {
|
||||
mapping = BLOCK_INVALID;
|
||||
mapping = BLOCK_AIR;
|
||||
}
|
||||
if (mapping != i) Inventory_Map[i] = mapping;
|
||||
}
|
||||
@ -133,7 +133,7 @@ void Inventory_Remove(BlockID block) {
|
||||
Int32 i;
|
||||
for (i = 0; i < Array_NumElements(Inventory_Map); i++) {
|
||||
if (Inventory_Map[i] != block) continue;
|
||||
Inventory_Map[i] = BLOCK_INVALID;
|
||||
Inventory_Map[i] = BLOCK_AIR;
|
||||
}
|
||||
}
|
||||
|
||||
@ -147,12 +147,12 @@ void Inventory_PushToFreeSlots(Int32 i) {
|
||||
}
|
||||
|
||||
for (j = block; j < Array_NumElements(Inventory_Map); j++) {
|
||||
if (Inventory_Map[j] == BLOCK_INVALID) {
|
||||
if (Inventory_Map[j] == BLOCK_AIR) {
|
||||
Inventory_Map[j] = block; return;
|
||||
}
|
||||
}
|
||||
for (j = 1; j < block; j++) {
|
||||
if (Inventory_Map[j] == BLOCK_INVALID) {
|
||||
if (Inventory_Map[j] == BLOCK_AIR) {
|
||||
Inventory_Map[j] = block; return;
|
||||
}
|
||||
}
|
||||
@ -161,7 +161,7 @@ void Inventory_PushToFreeSlots(Int32 i) {
|
||||
void Inventory_Insert(Int32 i, BlockID block) {
|
||||
if (Inventory_Map[i] == block) return;
|
||||
/* Need to push the old block to a different slot if different block. */
|
||||
if (Inventory_Map[i] != BLOCK_INVALID) Inventory_PushToFreeSlots(i);
|
||||
if (Inventory_Map[i] != BLOCK_AIR) Inventory_PushToFreeSlots(i);
|
||||
Inventory_Map[i] = block;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user