private Task DispatchPacket(UseEntity packet) { var player = _user; // player.UseEntity((uint)packet.Target, (EntityUsage)packet.Type, packet.TargetX.HasValue ? // new Vector3?(new Vector3(packet.TargetX.Value, packet.TargetY.Value, packet.TargetZ.Value)) : null, (EntityInteractHand?)packet.Hand).Ignore(); return(Task.CompletedTask); }
private Task DispatchPacket(UseEntity packet) { Logger.LogWarning("UseEntity is not implemented."); // player.UseEntity((uint)packet.Target, (EntityUsage)packet.Type, packet.TargetX.HasValue ? // new Vector3?(new Vector3(packet.TargetX.Value, packet.TargetY.Value, packet.TargetZ.Value)) : null, (EntityInteractHand?)packet.Hand).Ignore(); return(Task.CompletedTask); }
public IPacket ReadPacket(IMinecraftDataReader reader) { Target = reader.ReadVarInt(); Type = (UseEntity) reader.ReadVarInt(); if (Type == UseEntity.INTERACT_AT) { TargetX = reader.ReadFloat(); TargetY = reader.ReadFloat(); TargetZ = reader.ReadFloat(); } return this; }
/// <summary> /// return true to block packet /// </summary> bool UseEntityFromClient(UseEntity ue) { //Attack others if (ue.Type == UseEntity.Types.Attack) { //Admin instant kill using bedrock if (Player.Admin(Permissions.AnyAdmin) && this.ActiveItem != null && this.ActiveItem.ItemID == BlockID.Bedrock) { VanillaSession dust = World.Main.GetPlayer(ue.Target); if (dust == null) { Player.TellSystem(Chat.Purple, "Failed to find player"); return(true); } dust.SendToBackend(new ChatMessageClient("/kill")); Log.WritePlayer(this, "Admin kill: " + dust.Player.MinecraftUsername); return(true); } if (Player.Settings.Cloaked != null) { return(false); } Debug.WriteLine("Attacked: " + ue.Target); VanillaSession target = World.Main.GetPlayer(ue.Target); if (target == null && Player.Settings.Cloaked == null) { Entity e = World.Main.GetEntity(ue.Target); var m = e as Mob; var v = e as Vehicle; WorldRegion cr = CurrentRegion; //prevent killing mobs and villagers inside region if (cr != null && cr.Type == "protected" && (cr.IsResident(Player) == false)) { if (m != null && m.Type >= MobType.Pig) { Player.TellSystem(Chat.Pink, "No killing inside this region"); return(true); } if (v != null && v.Type == Vehicles.Frame) { //Protect frames Debug.WriteLine("Frame protected"); return(true); } } if (m != null && m.Owner != "") { //this could prevent killing of tamed animals } } if (target != null && target.Player.Settings.Cloaked == null) { if (this.ActiveItem != null) { switch (this.ActiveItem.ItemID) { case BlockID.Rose: case BlockID.Dandelion: PlayerInteraction.Prod(this.Player, target.Player); return(true); } } //Anywhere but war WorldRegion r = CurrentRegion; if (r != null && r.Type == "war") { //War Zone //r.Say (Chat.Yellow + Name + Chat.Gold + " attacked " + Chat.Yellow + target.Name + Chat.Gold + " using " + newAttack.Item); SendToBackend(ue); return(true); } //Anywhere but war if (Player.PvP == false) { Player.TellSystem(Chat.Purple, "PvP active"); Player.PvP = true; } Attacked newAttack = new Attacked(this.Player); if (target.Attacker == null || target.Attacker.Timestamp.AddSeconds(10) < DateTime.Now) { //Regular zone if (target.Player.PvP == false && ((r == null) || (r.IsResident(Player) == false))) { if (target.lastPvpMessage < DateTime.Now) { target.lastPvpMessage = DateTime.Now.AddSeconds(5); PlayerInteraction.Prod(target.Player); target.Player.TellSystem(Chat.Pink, Player.Name + " can't hurt you"); } Player.TellSystem(Chat.Pink, "You challenge " + target.Player.Name + " to a fight to the " + Chat.Red + "death"); return(true); } string msg = Player.Name + " attacked " + target.Player.Name + " using " + newAttack.Item; Chatting.Parser.SayFirehose(Chat.Gray, msg); target.TellSystem(Chat.Gray, msg); this.TellSystem(Chat.Gray, msg); Log.WriteAction(target.Player, newAttack, false); } target.Attacker = newAttack; } return(false); } else { //Right click Mob m = World.Main.GetEntity(ue.Target) as Mob; if (m == null) { return(false); } if (m.Owner == "") { return(false); } if (m.Type == MobType.Ocelot) { this.TellSystem(Chat.Pink, "Meow " + m.Owner); } else if (m.Type == MobType.Wolf) { this.TellSystem(Chat.Pink, "Woof " + m.Owner); } else { this.TellSystem(Chat.Pink, "Owner: " + m.Owner); } return(false); } }
private void InvokeUseEntity(UseEntity packet) { packetListener.OnUseEntity(packet); }
public virtual void OnUseEntity(UseEntity packet) { }