From 079541d4c949387fff36f7a9fe8ca282478949ce Mon Sep 17 00:00:00 2001 From: Olink Date: Wed, 27 May 2020 23:05:45 -0400 Subject: [PATCH 1/4] Initial working commit. --- TShockAPI/Bouncer.cs | 13 +++++++++++++ TShockAPI/PlayerData.cs | 2 +- TShockAPI/TShock.cs | 3 ++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/TShockAPI/Bouncer.cs b/TShockAPI/Bouncer.cs index ad6e516a..0ea594e7 100644 --- a/TShockAPI/Bouncer.cs +++ b/TShockAPI/Bouncer.cs @@ -295,6 +295,19 @@ namespace TShockAPI { args.Player.LastKilledProjectile = 0; } + else if (editData == TileID.MysticSnakeRope) + { + //projectile should be the same X coordinate as all tile places + if (!args.Player.RecentlyCreatedProjectiles.Any(p => Main.projectile[p.Index].type == ProjectileID.MysticSnakeCoil && + Math.Abs((int)(Main.projectile[p.Index].position.X / 16f) - tileX) <= Math.Abs(Main.projectile[p.Index].velocity.X))) + { + TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from (inconceivable mystic snake rope) {0} {1} {2}", args.Player.Name, action, editData); + Console.WriteLine("Bouncer / OnTileEdit rejected from (inconceivable mystic snake rope) {0} {1} {2}", args.Player.Name, action, editData); + args.Player.SendTileSquare(tileX, tileY, 1); + args.Handled = true; + return; + } + } else if (action == EditAction.PlaceTile || action == EditAction.PlaceWall) { if ((action == EditAction.PlaceTile && TShock.Config.PreventInvalidPlaceStyle) && diff --git a/TShockAPI/PlayerData.cs b/TShockAPI/PlayerData.cs index 562dea80..d6540e34 100644 --- a/TShockAPI/PlayerData.cs +++ b/TShockAPI/PlayerData.cs @@ -496,7 +496,7 @@ namespace TShockAPI } var response = NetCreativeUnlocksModule.SerializeItemSacrifice(i, amount); - NetManager.Instance.SendToClient(response, player.TPlayer.whoAmI); + NetManager.Instance.SendToClient(response, player.Index); } } } diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 0d19a6fb..84c12dab 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -1640,7 +1640,8 @@ namespace TShockAPI if (e.number >= 0 && e.number < Main.projectile.Length) { var projectile = Main.projectile[e.number]; - if (projectile.active && projectile.owner >= 0 && GetDataHandlers.projectileCreatesLiquid.ContainsKey(projectile.type)) + if (projectile.active && projectile.owner >= 0 && + (GetDataHandlers.projectileCreatesLiquid.ContainsKey(projectile.type) || GetDataHandlers.projectileCreatesTile.ContainsKey(projectile.type))) { var player = Players[projectile.owner]; if (player != null) From 50337a1d2f1ce1b15ea5df5920b77bd540282fc2 Mon Sep 17 00:00:00 2001 From: Olink Date: Fri, 29 May 2020 17:03:48 -0400 Subject: [PATCH 2/4] Add support for all rope coil types. --- TShockAPI/Bouncer.cs | 11 ++++++----- TShockAPI/GetDataHandlers.cs | 15 ++++++++++++++- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/TShockAPI/Bouncer.cs b/TShockAPI/Bouncer.cs index 0ea594e7..cc8feef8 100644 --- a/TShockAPI/Bouncer.cs +++ b/TShockAPI/Bouncer.cs @@ -295,14 +295,15 @@ namespace TShockAPI { args.Player.LastKilledProjectile = 0; } - else if (editData == TileID.MysticSnakeRope) + else if (CoilTileIds.Contains(editData)) { //projectile should be the same X coordinate as all tile places - if (!args.Player.RecentlyCreatedProjectiles.Any(p => Main.projectile[p.Index].type == ProjectileID.MysticSnakeCoil && - Math.Abs((int)(Main.projectile[p.Index].position.X / 16f) - tileX) <= Math.Abs(Main.projectile[p.Index].velocity.X))) + if (!args.Player.RecentlyCreatedProjectiles.Any(p => GetDataHandlers.projectileCreatesTile.ContainsKey(Main.projectile[p.Index].type) && + Math.Abs((int)(Main.projectile[p.Index].position.X / 16f) - tileX) <= Math.Abs(Main.projectile[p.Index].velocity.X) && + GetDataHandlers.projectileCreatesTile[Main.projectile[p.Index].type] == editData)) { - TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from (inconceivable mystic snake rope) {0} {1} {2}", args.Player.Name, action, editData); - Console.WriteLine("Bouncer / OnTileEdit rejected from (inconceivable mystic snake rope) {0} {1} {2}", args.Player.Name, action, editData); + TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from (inconceivable rope coil) {0} {1} {2}", args.Player.Name, action, editData); + Console.WriteLine("Bouncer / OnTileEdit rejected from (inconceivable rope coil) {0} {1} {2}", args.Player.Name, action, editData); args.Player.SendTileSquare(tileX, tileY, 1); args.Handled = true; return; diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index 09667f33..3c94dedb 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -3630,7 +3630,20 @@ namespace TShockAPI { ProjectileID.EbonsandBallGun, TileID.Ebonsand }, { ProjectileID.PearlSandBallGun, TileID.Pearlsand }, { ProjectileID.CrimsandBallGun, TileID.Crimsand }, - { ProjectileID.MysticSnakeCoil, TileID.MysticSnakeRope } + { ProjectileID.MysticSnakeCoil, TileID.MysticSnakeRope }, + { ProjectileID.RopeCoil, TileID.Rope }, + { ProjectileID.SilkRopeCoil, TileID.SilkRope }, + { ProjectileID.VineRopeCoil, TileID.VineRope }, + { ProjectileID.WebRopeCoil, TileID.WebRope } + }; + + internal static List CoilTileIds = new List() + { + TileID.MysticSnakeRope, + TileID.Rope, + TileID.SilkRope, + TileID.VineRope, + TileID.WebRope }; internal static Dictionary projectileCreatesLiquid = new Dictionary From 4dd786129c67d9c5080918dfd2d97b9b829535eb Mon Sep 17 00:00:00 2001 From: Olink Date: Fri, 29 May 2020 17:04:38 -0400 Subject: [PATCH 3/4] Update changelog. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 02cdc3b2..611b74b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin * Attempted to fix the problem with the magic mirror spawn problems. You should be able to remove your spawn point in SSC by right clicking on a bed now. (@hakusaro, @AxeelAnder) * Added HandleFoodPlatterTryPlacing event, which is called whenever a player places a food in a plate. Add antihack to bouncer, to prevent removing food from plates if the region is protected; To prevent placement if they are not in range; To prevent placement if the item is not placed from player hand. (@Patrikkk) * Fixed an offset error in NetTile that impacted `SendTileSquare`. It was being read as a `byte` and not a `ushort`. (@QuiCM) +* Fix all rope coils. (@Olink) ## TShock 4.4.0 (Pre-release 8) * Update for OTAPI 2.0.0.36 and Terraria 1.4.0.4. (@hakusaro, @Patrikkk, @DeathCradle) From c999b4305ce17573cb9ed30155d6e8418c529550 Mon Sep 17 00:00:00 2001 From: Zack Date: Sat, 30 May 2020 11:58:59 -0400 Subject: [PATCH 4/4] Remove Console debug output. --- TShockAPI/Bouncer.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/TShockAPI/Bouncer.cs b/TShockAPI/Bouncer.cs index 4903f2e8..4e93f757 100644 --- a/TShockAPI/Bouncer.cs +++ b/TShockAPI/Bouncer.cs @@ -304,7 +304,6 @@ namespace TShockAPI GetDataHandlers.projectileCreatesTile[Main.projectile[p.Index].type] == editData)) { TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from (inconceivable rope coil) {0} {1} {2}", args.Player.Name, action, editData); - Console.WriteLine("Bouncer / OnTileEdit rejected from (inconceivable rope coil) {0} {1} {2}", args.Player.Name, action, editData); args.Player.SendTileSquare(tileX, tileY, 1); args.Handled = true; return;