-
-
Notifications
You must be signed in to change notification settings - Fork 386
Fixed Super Sponge unable to absorb shimmer #2833
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| } | ||
|
|
||
| if (!wasThereABombNearby && type == LiquidType.Shimmer && !(bucket == 8 || bucket == 9)) | ||
| if (TShock.ItemBans.DataModel.ItemIsBanned(EnglishLanguage.GetItemNameById(selectedItemType), args.Player)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if the banned item check should be here, I keep it because it used to be here and the IsBeingDisabled check does not check item-ban disabled
Line 1656 in 5d84192
| if (args.Player.IsBeingDisabled()) |
|
There is also a behaviour change here: |
Why? This PR is genuinely daunting to review because the implication is that the intent is to "Fixed Super Sponge unable to absorb shimmer" but it also "Now ban lava bucket just means lava bucket." and in-so-doing reorders all of the code related to this and makes it hard to review. At minimum can you separate changes like this into multiple commits? For example: Commit A (contents) could be the diff just for absorbing shimmer I've looked at this PR and other PRs in TShock multiple times but it's not easy to parse or understand the change deltas with very small descriptions of changes. |
|
Now this adds back to the original behavior, banning the lava bucket will disable all lava-related actions, and so do water/honey/shimmer (via bottomless shimmer bucket). |
|
The commit 49921cb seems to be confusing - view it with diff --git a/TShockAPI/Bouncer.cs b/TShockAPI/Bouncer.cs
index cfa10b50..4b1ff297 100644
--- a/TShockAPI/Bouncer.cs
+++ b/TShockAPI/Bouncer.cs
@@ -1729,54 +1729,70 @@ namespace TShockAPI
args.Handled = true;
}
+ if (TShock.ItemBans.DataModel.ItemIsBanned(EnglishLanguage.GetItemNameById(selectedItemType), args.Player))
+ {
+ Reject(GetString("Using banned {0} to manipulate liquid", Lang.GetItemNameValue(selectedItemType)));
+ return;
+ }
+
+ switch (type)
+ {
+ case LiquidType.Water:
+ if (TShock.ItemBans.DataModel.ItemIsBanned(EnglishLanguage.GetItemNameById(ItemID.WaterBucket), args.Player))
+ {
+ Reject(GetString("Using banned water bucket without permissions"));
+ return;
+ }
+ break;
+ case LiquidType.Lava:
+ if (TShock.ItemBans.DataModel.ItemIsBanned(EnglishLanguage.GetItemNameById(ItemID.LavaBucket), args.Player))
+ {
+ Reject(GetString("Using banned lava bucket without permissions"));
+ return;
+ }
+ break;
+ case LiquidType.Honey:
+ if (TShock.ItemBans.DataModel.ItemIsBanned(EnglishLanguage.GetItemNameById(ItemID.HoneyBucket), args.Player))
+ {
+ Reject(GetString("Using banned honey bucket without permissions"));
+ return;
+ }
+ break;
+ case LiquidType.Shimmer:
+ if (TShock.ItemBans.DataModel.ItemIsBanned(EnglishLanguage.GetItemNameById(ItemID.BottomlessShimmerBucket), args.Player))
+ {
+ Reject(GetString("Using banned shimmering water bucket without permissions"));
+ return;
+ }
+ break;
+ default:
+ Reject(GetString("Manipulating unknown liquid type"));
+ return;
+ }
+
if (type == LiquidType.Lava && !(selectedItemType == ItemID.LavaBucket || selectedItemType == ItemID.EmptyBucket || selectedItemType == ItemID.LavaAbsorbantSponge || selectedItemType == ItemID.BottomlessLavaBucket || selectedItemType == ItemID.UltraAbsorbantSponge))
{
Reject(GetString("Spreading lava without holding a lava bucket"));
return;
}
- if (type == LiquidType.Lava && TShock.ItemBans.DataModel.ItemIsBanned("Lava Bucket", args.Player))
- {
- Reject(GetString("Using banned lava bucket without permissions"));
- return;
- }
-
if (type == LiquidType.Water && !(selectedItemType == ItemID.WaterBucket || selectedItemType == ItemID.EmptyBucket || selectedItemType == ItemID.BottomlessBucket || selectedItemType == ItemID.UltraAbsorbantSponge || selectedItemType == ItemID.SuperAbsorbantSponge))
{
Reject(GetString("Spreading water without holding a water bucket"));
return;
}
- if (type == LiquidType.Water && TShock.ItemBans.DataModel.ItemIsBanned("Water Bucket", args.Player))
- {
- Reject(GetString("Using banned water bucket without permissions"));
- return;
- }
-
if (type == LiquidType.Honey && !(selectedItemType == ItemID.HoneyBucket || selectedItemType == ItemID.EmptyBucket || selectedItemType == ItemID.BottomlessHoneyBucket || selectedItemType == ItemID.HoneyAbsorbantSponge || selectedItemType == ItemID.UltraAbsorbantSponge))
{
Reject(GetString("Spreading honey without holding a honey bucket"));
return;
}
- if (type == LiquidType.Honey && TShock.ItemBans.DataModel.ItemIsBanned("Honey Bucket", args.Player))
- {
- Reject(GetString("Using banned honey bucket without permissions"));
- return;
- }
-
if (type == LiquidType.Shimmer && !(selectedItemType == ItemID.BottomlessShimmerBucket || selectedItemType == ItemID.UltraAbsorbantSponge || selectedItemType == ItemID.SuperAbsorbantSponge))
{
Reject(GetString("Spreading shimmer without holding a shimmer bucket"));
return;
}
-
- if (type == LiquidType.Shimmer &&
- TShock.ItemBans.DataModel.ItemIsBanned("Bottomless Shimmer Bucket", args.Player))
- {
- Reject(GetString("Using banned bottomless shimmer bucket without permissions"));
- return;
- }
}
if (!args.Player.HasBuildPermission(tileX, tileY)) |
drunderscore
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if this is what @hakusaro was exactly looking for when mentioning "separate commits", but I find these commits to be super weird:
- The first commit changes the magic numbers to include allow the Super Sponge
- ...but then the second commit removes those magic numbers completely
- ...but then the sixth commit totally removes all of that and replaces it with a
switchstatement on the items?
I do not recall how this PR previously looked, and that's certainly my own fault, but it's hard to imagine this is better?
| } | ||
|
|
||
| if (type == LiquidType.Lava && !(selectedItemType == ItemID.LavaBucket || selectedItemType == ItemID.EmptyBucket || selectedItemType == ItemID.LavaAbsorbantSponge || selectedItemType == ItemID.BottomlessLavaBucket || selectedItemType == ItemID.UltraAbsorbantSponge)) | ||
| switch (selectedItemType) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find this entire commit to be weird... why group the check of liquids based on item instead? It just feels so backwards when looking at the code.
| if (amount != 0) | ||
| { | ||
| int bucket = -1; | ||
| int selectedItemType = args.Player.TPlayer.inventory[args.Player.TPlayer.selectedItem].type; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And what's the point of this commit, if not to make all of this code a switch case later?
|
The first commit resolves the issue, However, it turns out that the After the second commit, the lines are long and there are still many duplications, e.g. we have four Lines 1815 to 1817 in 536c4d2
The original commit 3e61e68 is exactly the same but in one commit and without this, (restrict all lava actions if lava bucket banned, etc. to keep the same behaviour as old implementation) Lines 1738 to 1771 in 536c4d2
|
drunderscore
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tested that these changes fix the titled issue.
In the end, the commits will be squashed and merged into general-devel, so I'm alright with them staying how they are, as I was able to review the final code alright.
The switching on the selected item to check against the liquid type actually seems fine. I was a bit over-the-top with my previous dismissal of it, but the code is clean with it.
| { | ||
| Reject(GetString("Using banned lava bucket without permissions")); | ||
| return; | ||
| case LiquidType.Water: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a bit weird the basic bucket type being banned means the liquid is entirely banned, but that is what the original code did, so that's alright I think.
Fixes super sponge unable to handle shimmer, reported by Asanay.