Now hold air instead of 255 in survival, fixes invalid block type 255

This commit is contained in:
UnknownShadow200 2017-02-10 23:54:08 +11:00
parent 8f8e880d94
commit 132967bf9d
4 changed files with 10 additions and 8 deletions

View File

@ -32,9 +32,8 @@ namespace ClassicalSharp {
input.ButtonStateChanged(MouseButton.Middle, middle);
}
int buttonsDown = (left ? 1 : 0) + (right ? 1 : 0) + (middle ? 1 : 0);
if (buttonsDown > 1 || game.Gui.ActiveScreen.HandlesAllInput ||
inv.HeldBlock == Block.Air) return;
int btns = (left ? 1 : 0) + (right ? 1 : 0) + (middle ? 1 : 0);
if (btns > 1 || game.Gui.ActiveScreen.HandlesAllInput || inv.HeldBlock == Block.Invalid) return;
// always play delete animations, even if we aren't picking a block.
if (left) {

View File

@ -58,6 +58,7 @@ namespace ClassicalSharp.GraphicsAPI {
if (!Utils.IsPowerOf2(bmp.Width) || !Utils.IsPowerOf2(bmp.Height)) {
throw new ArgumentOutOfRangeException("Bitmap must have power of two dimensions");
}
if (LostContext) throw new InvalidOperationException("Cannot create texture when context lost");
if (!bmp.IsLocked) bmp.LockBits();
int texId = CreateTexture(bmp.Width, bmp.Height, bmp.Scan0, managedPool);

View File

@ -39,7 +39,7 @@ namespace ClassicalSharp.Mode {
if (invCount[index] != 0) return;
// bypass HeldBlock's normal behaviour
game.Inventory.Hotbar[index] = Block.Invalid;
game.Inventory.Hotbar[index] = Block.Air;
game.Events.RaiseHeldBlockChanged();
}
@ -83,7 +83,7 @@ namespace ClassicalSharp.Mode {
}
if (index == -1) {
for (int i = hotbar.Length - 1; i >= 0; i--) {
if (hotbar[i] == Block.Invalid) index = i;
if (hotbar[i] == Block.Air) index = i;
}
}
if (index == -1) return; // no free slots
@ -116,7 +116,7 @@ namespace ClassicalSharp.Mode {
this.game = game;
byte[] hotbar = game.Inventory.Hotbar;
for (int i = 0; i < hotbar.Length; i++)
hotbar[i] = Block.Invalid;
hotbar[i] = Block.Air;
hotbar[hotbar.Length - 1] = Block.TNT;
}

View File

@ -83,10 +83,12 @@ namespace ClassicalSharp.Network.Protocols {
}
void HandleHoldThis() {
byte blockType = reader.ReadUInt8();
byte block = reader.ReadUInt8();
if (block == Block.Air) block = Block.Invalid;
bool canChange = reader.ReadUInt8() == 0;
game.Inventory.CanChangeHeldBlock = true;
game.Inventory.HeldBlock = blockType;
game.Inventory.HeldBlock = block;
game.Inventory.CanChangeHeldBlock = canChange;
}