示例#1
0
        public void Handle(NetworkManager nm, Bot core)
        {
            if (!core.EnableCpe)
                core.RaiseErrorMessage("Protocol error: Received ChangeModel while CPE Disabled.");

            if (!core.ClientSupportedExtensions.Contains(CPEExtensions.ChangeModel))
                core.RaiseErrorMessage("Protocol error: Received ChangeModel packet, which client does not support.");
        }
示例#2
0
 /// <summary>
 /// Performs a sanity check against the map file to ensure that there are no out of range values.
 /// </summary>
 /// <param name="clientBot"></param>
 public void WorldCheck(Bot clientBot)
 {
     for (var x = 0; x < MapSize.X - 1; x++) {
         for (var y = 0; y < MapSize.Y - 1; y++) {
             for (var z = 0; z < MapSize.Z - 1; z++) {
                 var myId = GetBlockId((short)x, (short)y, (short)z);
                 if (myId > 49 && !clientBot.ClientSupportedExtensions.Contains(CPEExtensions.CustomBlocks)) {
                     clientBot.RaiseErrorMessage("Block ID out of bounds: " + myId + " :" + x + " " + y + " " + z);
                 } else if (myId > 65) {
                     clientBot.RaiseErrorMessage("Block ID out of bounds: " + myId + " :" + x + " " + y + " " + z);
                 }
             }
         }
     }
 }
示例#3
0
        public void Handle(NetworkManager nm, Bot core)
        {
            if (!core.EnableCpe)
                core.RaiseErrorMessage("Protocol error: Received Extinfo while CPE Disabled.");

            core.SupportsCpe = true;
            core.ServerAppName = AppName;
            core.Extensions = ExtensionCount;
            core.ServerExtensions = new Dictionary<string, int>();
            core.raiseDebugMessage("Connecting to " + AppName + " with " + ExtensionCount + " extensions.");
        }
示例#4
0
        public void Handle(NetworkManager nm, Bot core)
        {
            if (!core.EnableCpe)
                core.RaiseErrorMessage("Protocol error: Received Extentry while CPE Disabled.");

            if (core.SentCpe)
                core.RaiseErrorMessage("Protocol error: Received ExtEntry after sending client extensions!");

            core.ReceivedExtensions += 1;

            if (core.ReceivedExtensions > core.Extensions)
                core.RaiseInfoMessage("Warning: Server sent more extensions than ExtInfo reported.");

            if (!core.ServerExtensions.ContainsKey(ExtName))
                core.ServerExtensions.Add(ExtName, Version);
            else
                core.RaiseErrorMessage("Protocol warning: Server sent ExtEntry of same name multiple times (" + ExtName + ")");

            core.raiseDebugMessage("Received ExtEntry: " + ExtName + " -- " + Version);

            if (core.ReceivedExtensions == core.Extensions)
                nm.SendCPE();
        }
示例#5
0
        public void Handle(NetworkManager nm, Bot core)
        {
            if (!core.EnableCpe)
                core.RaiseErrorMessage("Protocol error: Received ExtAddPlayerName while CPE Disabled.");

            if (!core.ClientSupportedExtensions.Contains(CPEExtensions.ExtPlayerList))
                core.RaiseErrorMessage("Protocol error: Received ExtPlayerList packet, which client does not support.");

            var newEntry = new ExtPlayerListEntry {
                NameId = NameId,
                PlayerName = PlayerName,
                ListName = ListName,
                GroupName = GroupName,
                GroupRank = GroupRank
            };

            if (!core.NumberPlayerList.ContainsKey(NameId)) {
                core.ExtPlayerList.Add(PlayerName, newEntry);
                core.NumberPlayerList.Add(NameId, newEntry);
            }
            else {
                core.ExtPlayerList.Remove(core.NumberPlayerList[NameId].PlayerName);
                core.ExtPlayerList.Add(PlayerName, newEntry);
                core.NumberPlayerList[NameId] = newEntry;
            }

            core.RaiseExtPlayerListUpdate();
        }
示例#6
0
        public void Handle(NetworkManager nm, Bot core)
        {
            if (!core.EnableCpe)
                core.RaiseErrorMessage("Protocol error: Received EnvSetMapAppearance while CPE Disabled.");

            if (!core.ClientSupportedExtensions.Contains(CPEExtensions.EnvMapAppearance))
                core.RaiseErrorMessage("Protocol error: Received EnvMapAppearances packet, which client does not support.");
        }
示例#7
0
        public void Handle(NetworkManager nm, Bot core)
        {
            if (!core.EnableCpe)
                core.RaiseErrorMessage("Protocol error: Received SetTextHotKey while CPE Disabled.");

            if (!core.ClientSupportedExtensions.Contains(CPEExtensions.CustomBlocks))
                core.RaiseErrorMessage("Protocol error: Received SetTextHotKey, which client does not support.");

            var myHotkey = new TextHotKeyEntry {
                Label = Label,
                Action = Action,
                Keycode = KeyCode,
                Modifier = (HotkeyModifier) KeyMods
            };

            if (core.Hotkeys == null)
                core.Hotkeys = new List<TextHotKeyEntry>();

            core.Hotkeys.Add(myHotkey);
            core.RaiseHotkeyAdded();
        }
示例#8
0
        public void Handle(NetworkManager nm, Bot core)
        {
            if (!core.EnableCpe)
                core.RaiseErrorMessage("Protocol error: Received CBSL while CPE Disabled.");

            if (!core.ClientSupportedExtensions.Contains(CPEExtensions.CustomBlocks))
                core.RaiseErrorMessage("Protocol error: Received CBSL, which client does not support.");

            core.ServerCbLevel = SupportLevel;

            var myCb = new CustomBlockSupportLevel {SupportLevel = Bot.CustomBlockSuportlevel};
            myCb.Write(nm);

            core.raiseDebugMessage("Received CustomBlockSupportLevel.");
        }
示例#9
0
        public void Handle(NetworkManager nm, Bot core)
        {
            if (!core.EnableCpe)
                core.RaiseErrorMessage("Protocol error: Received SetBlockPermissions while CPE Disabled.");

            if (!core.ClientSupportedExtensions.Contains(CPEExtensions.BlockPermissions))
                core.RaiseErrorMessage("Protocol error: Received BlockPermissions packet, which client does not support.");

            if (BlockType > 49 && !core.ClientSupportedExtensions.Contains(CPEExtensions.CustomBlocks))
                core.RaiseErrorMessage("Protocol error: SetBlockPermissions on block > 49 while custom blocks not supported.");
        }
示例#10
0
        public void Handle(NetworkManager nm, Bot core)
        {
            if (!core.EnableCpe)
                core.RaiseErrorMessage("Protocol error: Received RemoveSelection while CPE Disabled.");

            if (!core.ClientSupportedExtensions.Contains(CPEExtensions.SelectionCuboid))
                core.RaiseErrorMessage("Protocol error: Received SelectionCuboid packet, which client does not support.");
        }
示例#11
0
        public void Handle(NetworkManager nm, Bot core)
        {
            if (!core.Entities.ContainsKey(PlayerId)) {
                core.RaiseErrorMessage("Protocol Warning: Updated position of non-existant player");
                return;
            }

            var myEntity = core.Entities[PlayerId];

            if (PlayerId != -1) {
                myEntity.UpdateLocation((short)(myEntity.Location.X + ChangeX), (short)(myEntity.Location.Y + ChangeY), (short)(myEntity.Location.Z + ChangeZ));
                core.RaisePlayerMoved(myEntity);
            }

            core.Location.X += ChangeX;
            core.Location.Y += ChangeY;
            core.Location.Z += ChangeZ;
            core.RaiseYouMoved();
        }
示例#12
0
        public void Handle(NetworkManager nm, Bot core)
        {
            if (!core.Entities.ContainsKey(PlayerId)) {
                core.RaiseErrorMessage("Protocol Warning: Despawned non-existant entity.");
                return;

            }
            var myEntity = core.Entities[PlayerId];

            core.Entities.Remove(PlayerId);
            core.RaisePlayerLeft(myEntity);
        }
示例#13
0
        public void Handle(NetworkManager nm, Bot core)
        {
            if (!core.Entities.ContainsKey(PlayerId) && PlayerId != -1) {
                core.RaiseErrorMessage("Protocol Warning: Teleported non-existant player");
                return;
            }

            if (PlayerId != -1) {
                core.Entities[PlayerId].UpdateLocation(X, Y, Z);
                core.Entities[PlayerId].UpdateLook(Yaw, Pitch);
                core.RaisePlayerMoved(core.Entities[PlayerId]);
                return;
            }

            core.Location.X = X;
            core.Location.Y = Y;
            core.Location.Z = Z;
            core.Position[0] = Yaw;
            core.Position[1] = Pitch;
            core.RaiseYouMoved();
            core.raiseDebugMessage("Set location via Teleport.");
        }
示例#14
0
        public void Handle(NetworkManager nm, Bot core)
        {
            if (!core.Entities.ContainsKey(PlayerId)) {
                core.RaiseErrorMessage("Protocol Warning: Updated orientation of non-existant player");
                return;
            }

            var myEntity = core.Entities[PlayerId];

            if (PlayerId != -1) {
                myEntity.UpdateLook(Yaw, Pitch);
                core.RaisePlayerMoved(myEntity);
                return;

            }

            core.Position[0] = Yaw;
            core.Position[1] = Pitch;
            core.RaiseYouMoved();
        }
示例#15
0
        public void Handle(NetworkManager nm, Bot core)
        {
            File.WriteAllBytes("map.gz", core.ClientWorld.BlockArray);

            core.ClientWorld.BlockArray = GZip.UnGZip(core.ClientWorld.BlockArray) ??
                                          new byte[(SizeX * SizeY * SizeZ) + 4];

            var blockArraySize = BitConverter.ToInt32(new[] { core.ClientWorld.BlockArray[3], core.ClientWorld.BlockArray[2], core.ClientWorld.BlockArray[1], core.ClientWorld.BlockArray[0] }, 0);
            core.ClientWorld.RemoveSize();

            core.ClientWorld.MapSize = new Vector3S {X = SizeX, Y = SizeZ, Z = SizeY};

            core.RaiseInfoMessage("Map complete.");

            if ((SizeX * SizeY * SizeZ) != blockArraySize)
                core.RaiseErrorMessage(
                    $"Protocol Error: Map data length != Finalize length ({blockArraySize} - {(SizeX*SizeY*SizeZ)})");

            core.RaiseLevelComplete(SizeX, SizeY, SizeZ);

            //core.ClientWorld.WorldCheck(core);
        }
示例#16
0
        public void Handle(NetworkManager nm, Bot core)
        {
            if (!core.EnableCpe)
                core.RaiseErrorMessage("Protocol error: Received ExtRemovePlayerName while CPE Disabled.");

            if (!core.ClientSupportedExtensions.Contains(CPEExtensions.ExtPlayerList))
                core.RaiseErrorMessage("Protocol error: Received ExtPlayerList packet, which client does not support.");

            if (!core.NumberPlayerList.ContainsKey(NameId)) {
                core.RaiseErrorMessage("Protocol error: Received ExtRemovePlayerName for non-existant Name ID.");
            }
            else {
                core.ExtPlayerList.Remove(core.NumberPlayerList[NameId].PlayerName);
                core.NumberPlayerList.Remove(NameId);
                core.RaiseExtPlayerListUpdate();
            }
        }
示例#17
0
        public void Handle(NetworkManager nm, Bot core)
        {
            if (!core.EnableCpe)
                core.RaiseErrorMessage("Protocol error: Received Holdthis while CPE Disabled.");

            if (!core.ClientSupportedExtensions.Contains(CPEExtensions.HeldBlock))
                core.RaiseErrorMessage("Protocol error: Received HoldThis, which client does not support.");

            core.HeldBlock = BlockToHold;
            core.CanChangeBlock = (PreventChange > 0);
            core.RaiseHeldBlockChange(BlockToHold, PreventChange);
        }
示例#18
0
        public void Handle(NetworkManager nm, Bot core)
        {
            if (!core.EnableCpe)
                core.RaiseErrorMessage("Protocol error: Received SetClickDistance while CPE Disabled.");

            if (!core.ClientSupportedExtensions.Contains(CPEExtensions.ClickDistance))
                core.RaiseErrorMessage("Protocol error: Received SetClickDistance, which client does not support.");

            core.ClickDistance = Distance;
            core.RaiseClickDistanceSet(Distance);
        }