Mark/Place should default to held block instead of stone. (Thanks canadacanucks01), also use the fact that clients with HeldBlock CPE ext update the held block in every position movement packet.

This commit is contained in:
UnknownShadow200 2016-08-03 23:57:26 +10:00
parent e89d776e3e
commit b923824dd4
5 changed files with 16 additions and 15 deletions

View File

@ -37,7 +37,10 @@ namespace MCGalaxy.Commands.Building {
if (!p.HasBlockchange) {
Player.Message(p, "Cannot mark, no selection or cuboid in progress."); return;
}
p.ManualChange(P.X, P.Y, P.Z, 0, Block.rock, 0, false);
byte heldExt = 0;
byte heldBlock = p.GetActualHeldBlock(out heldExt);
p.ManualChange(P.X, P.Y, P.Z, 0, heldBlock, heldExt, false);
Player.Message(p, "Mark placed at &b({0}, {1}, {2})", P.X, P.Y, P.Z);
}

View File

@ -27,17 +27,16 @@ namespace MCGalaxy.Commands.Building {
public CmdPlace() { }
public override void Use(Player p, string message) {
int block = -1;
byte extBlock = 0;
int block = p.GetActualHeldBlock(out extBlock);
ushort x = p.pos[0], y = (ushort)(p.pos[1] - 32), z = p.pos[2];
try {
string[] parts = message.Split(' ');
switch (parts.Length) {
case 1: block = message == "" ? Block.rock :
case 1: block = message == "" ? block :
DrawCmd.GetBlock(p, parts[0], out extBlock); break;
case 3:
block = Block.rock;
x = (ushort)(Convert.ToUInt16(parts[0]) * 32);
y = (ushort)(Convert.ToUInt16(parts[1]) * 32);
z = (ushort)(Convert.ToUInt16(parts[2]) * 32);
@ -60,7 +59,7 @@ namespace MCGalaxy.Commands.Building {
P.X /= 32; P.Y /= 32; P.Z /= 32;
p.level.UpdateBlock(p, P.X, P.Y, P.Z, (byte)block, extBlock);
Player.Message(p, "A block was placed at ({0}, {1}, {2}).", P.X, P.Y, P.Z);
Player.Message(p, "{3} block was placed at ({0}, {1}, {2}).", P.X, P.Y, P.Z, Block.Name((byte)block));
}
public override void Help(Player p) {

View File

@ -18,10 +18,8 @@
using System;
using System.Drawing;
namespace MCGalaxy
{
public partial class Player
{
namespace MCGalaxy {
public partial class Player {
public int ClickDistance = 0;
public int CustomBlocks = 0;
public int HeldBlock = 0;
@ -47,10 +45,8 @@ namespace MCGalaxy
public bool hasCustomBlocks, hasBlockDefs,
hasTextColors, hasChangeModel, hasExtList;
public void AddExtension(string Extension, int version)
{
switch (Extension.Trim())
{
public void AddExtension(string ext, int version) {
switch (ext.Trim()) {
case CpeExt.ClickDistance:
ClickDistance = version; break;
case CpeExt.CustomBlocks:

View File

@ -232,7 +232,7 @@ namespace MCGalaxy {
//Games
public DateTime lastDeath = DateTime.UtcNow;
public byte modeType, RawHeldBlock = Block.stone;
public byte modeType, RawHeldBlock = Block.rock;
public byte[] bindings = new byte[Block.CpeCount];
public string[] cmdBind = new string[10];
public string[] messageBind = new string[10];

View File

@ -281,7 +281,10 @@ namespace MCGalaxy {
this.SendPos(0xFF, (ushort)(clippos[0] - 18), (ushort)(clippos[1] - 18), (ushort)(clippos[2] - 18), cliprot[0], cliprot[1]);
return;
}*/
byte thisid = packet[1];
byte heldBlock = packet[1];
if (HasCpeExt(CpeExt.HeldBlock))
RawHeldBlock = heldBlock;
ushort x = NetUtils.ReadU16(packet, 2);
ushort y = NetUtils.ReadU16(packet, 4);
ushort z = NetUtils.ReadU16(packet, 6);