From 6cec7e71cd3b881d78157c4f8d397c730bf4e2b7 Mon Sep 17 00:00:00 2001
From: AkjaHAsLk1IALk0MasH <46046453+AgaSpace@users.noreply.github.com>
Date: Sun, 28 Nov 2021 15:35:50 +0700
Subject: [PATCH 1/4] Fixed the ability to spawn Zenith projectile with
non-original items.
---
CHANGELOG.md | 1 +
TShockAPI/Bouncer.cs | 8 +++++++-
TShockAPI/Configuration/TShockConfig.cs | 4 ++++
3 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index cc632514..ad559311 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
* Changed hook `GetDataHandlers.OnNewProjectile` so that it passes the projectile's AI (by updating `NewProjectileEventArgs` and parsing this during the TShock hook) to support processing projectile AI in bouncer. (@AgaSpace)
* Fixed an issue where certain projectiles could be sent to the server with uncapped size parameters, which resulted in large disruptive client artifacts that could be used to grief players. (@AgaSpace, @Arthri)
* Added the currently running value of `Main.GameMode` to `/worldmode` as "Mode". (@hakusaro)
+* Fixed the ability to spawn Zenith projectile with non-original items. (@AgaSpace)
## TShock 4.5.10
* Changed the server behavior when `SIGINT` is received. When `SIGINT` is trapped, the server will attempt to shut down safely. When it is trapped a second time in a session, it will immediately exit. (`SIGINT` is typically triggered via CTRL + C.) This means that it is possible to corrupt your world if you force shutdown at the wrong time (e.g., while the world is saving), but hopefully you expect this to happen if you hit CTRL + C twice in a session and you read the warning. (@hakusaro, @Onusai)
diff --git a/TShockAPI/Bouncer.cs b/TShockAPI/Bouncer.cs
index 7795ed64..bf7881e2 100644
--- a/TShockAPI/Bouncer.cs
+++ b/TShockAPI/Bouncer.cs
@@ -1096,7 +1096,13 @@ namespace TShockAPI
return;
}
-
+ if (TShock.Config.Settings.DisableAnyZenith && type == ProjectileID.FinalFractal && !Terraria.Graphics.FinalFractalHelper._fractalProfiles.ContainsKey((int)ai[1]))
+ {
+ TShock.Log.ConsoleDebug("Bouncer / OnNewProjectile rejected from bouncer modified Zenith projectile from {0}.", args.Player.Name);
+ args.Player.RemoveProjectile(ident, owner);
+ args.Handled = true;
+ return;
+ }
if (!args.Player.HasPermission(Permissions.ignoreprojectiledetection))
{
diff --git a/TShockAPI/Configuration/TShockConfig.cs b/TShockAPI/Configuration/TShockConfig.cs
index eeb658c1..8b1a31ea 100644
--- a/TShockAPI/Configuration/TShockConfig.cs
+++ b/TShockAPI/Configuration/TShockConfig.cs
@@ -456,6 +456,10 @@ namespace TShockAPI.Configuration
/// Whether or not the server should suppress build permission failure warnings from regions, spawn point, or server edit failure.
[Description("Whether or not the server should suppress build permission failure warnings from regions, spawn point, or server edit failure.")]
public bool SuppressPermissionFailureNotices = false;
+
+ /// Prohibit the use of Zenith projectile with different objects instead of weapons.
+ [Description("Prohibit the use of Zenith projectile with different objects instead of weapons.")]
+ public bool DisableAnyZenith = true;
#endregion
From 1a62d1dfedbc92e54fdf5b513ac5715e52c14818 Mon Sep 17 00:00:00 2001
From: AkjaHAsLk1IALk0MasH <46046453+AgaSpace@users.noreply.github.com>
Date: Tue, 30 Nov 2021 14:22:41 +0700
Subject: [PATCH 2/4] Added ai[0] check
---
TShockAPI/Bouncer.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/TShockAPI/Bouncer.cs b/TShockAPI/Bouncer.cs
index bf7881e2..1ff46921 100644
--- a/TShockAPI/Bouncer.cs
+++ b/TShockAPI/Bouncer.cs
@@ -1096,7 +1096,7 @@ namespace TShockAPI
return;
}
- if (TShock.Config.Settings.DisableAnyZenith && type == ProjectileID.FinalFractal && !Terraria.Graphics.FinalFractalHelper._fractalProfiles.ContainsKey((int)ai[1]))
+ if (TShock.Config.Settings.DisableAnyZenith && type == ProjectileID.FinalFractal && (ai[0] < -100 || ai[0] > 101 ) && !Terraria.Graphics.FinalFractalHelper._fractalProfiles.ContainsKey((int)ai[1]))
{
TShock.Log.ConsoleDebug("Bouncer / OnNewProjectile rejected from bouncer modified Zenith projectile from {0}.", args.Player.Name);
args.Player.RemoveProjectile(ident, owner);
From 77032ccbea9c59e36cb817d96eee86caef88e197 Mon Sep 17 00:00:00 2001
From: AkjaHAsLk1IALk0MasH <46046453+AgaSpace@users.noreply.github.com>
Date: Tue, 30 Nov 2021 14:23:49 +0700
Subject: [PATCH 3/4] Renamed value in config
---
TShockAPI/Bouncer.cs | 2 +-
TShockAPI/Configuration/TShockConfig.cs | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/TShockAPI/Bouncer.cs b/TShockAPI/Bouncer.cs
index 1ff46921..b8188539 100644
--- a/TShockAPI/Bouncer.cs
+++ b/TShockAPI/Bouncer.cs
@@ -1096,7 +1096,7 @@ namespace TShockAPI
return;
}
- if (TShock.Config.Settings.DisableAnyZenith && type == ProjectileID.FinalFractal && (ai[0] < -100 || ai[0] > 101 ) && !Terraria.Graphics.FinalFractalHelper._fractalProfiles.ContainsKey((int)ai[1]))
+ if (TShock.Config.Settings.DisableModifiedZenith && type == ProjectileID.FinalFractal && (ai[0] < -100 || ai[0] > 101 ) && !Terraria.Graphics.FinalFractalHelper._fractalProfiles.ContainsKey((int)ai[1]))
{
TShock.Log.ConsoleDebug("Bouncer / OnNewProjectile rejected from bouncer modified Zenith projectile from {0}.", args.Player.Name);
args.Player.RemoveProjectile(ident, owner);
diff --git a/TShockAPI/Configuration/TShockConfig.cs b/TShockAPI/Configuration/TShockConfig.cs
index 8b1a31ea..2c643fab 100644
--- a/TShockAPI/Configuration/TShockConfig.cs
+++ b/TShockAPI/Configuration/TShockConfig.cs
@@ -459,7 +459,7 @@ namespace TShockAPI.Configuration
/// Prohibit the use of Zenith projectile with different objects instead of weapons.
[Description("Prohibit the use of Zenith projectile with different objects instead of weapons.")]
- public bool DisableAnyZenith = true;
+ public bool DisableModifiedZenith = false;
#endregion
From df5c1180559fa07822a75afb57f2af341567e619 Mon Sep 17 00:00:00 2001
From: AkjaHAsLk1IALk0MasH <46046453+AgaSpace@users.noreply.github.com>
Date: Tue, 30 Nov 2021 14:36:19 +0700
Subject: [PATCH 4/4] Added comments to help other developers understand what I
used and why
---
TShockAPI/Bouncer.cs | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/TShockAPI/Bouncer.cs b/TShockAPI/Bouncer.cs
index b8188539..2145b373 100644
--- a/TShockAPI/Bouncer.cs
+++ b/TShockAPI/Bouncer.cs
@@ -1096,7 +1096,15 @@ namespace TShockAPI
return;
}
- if (TShock.Config.Settings.DisableModifiedZenith && type == ProjectileID.FinalFractal && (ai[0] < -100 || ai[0] > 101 ) && !Terraria.Graphics.FinalFractalHelper._fractalProfiles.ContainsKey((int)ai[1]))
+ /*
+ * ai - Arguments that Projectile.AI uses for easier projectile control.
+ * ai[0] - Distance from player (Doesn't affect the result very much)
+ * ai[1] - The identifier of the object that will fly.
+ *
+ * FinalFractalHelper._fractalProfiles - A list of items that must be used in Zenith. (And also their colors)
+ * If you add an item to this collection, it will also fly in the Zenith. (not active from server)
+ */
+ if (TShock.Config.Settings.DisableModifiedZenith && type == ProjectileID.FinalFractal && (ai[0] < -100 || ai[0] > 101) && !Terraria.Graphics.FinalFractalHelper._fractalProfiles.ContainsKey((int)ai[1]))
{
TShock.Log.ConsoleDebug("Bouncer / OnNewProjectile rejected from bouncer modified Zenith projectile from {0}.", args.Player.Name);
args.Player.RemoveProjectile(ident, owner);