This commit is contained in:
xuyuwtu 2026-01-28 22:08:48 +08:00
parent 004a459bba
commit 54025a9b93
2 changed files with 38 additions and 37 deletions

View file

@ -2972,8 +2972,9 @@ namespace TShockAPI
{ {
var id = args.Data.ReadInt16(); var id = args.Data.ReadInt16();
var owner = args.Data.ReadInt8(); var owner = args.Data.ReadInt8();
//var position = args.Data.ReadVector2();
if (id is < 0 or > 400) if (id is < 0 or > Main.maxItems)
return true; return true;
if (id == 400 && owner == 255) if (id == 400 && owner == 255)
@ -4364,9 +4365,9 @@ namespace TShockAPI
} }
// Handle kicks/bans on mediumcore/hardcore deaths. // Handle kicks/bans on mediumcore/hardcore deaths.
if (args.TPlayer.difficulty == 1 || args.TPlayer.difficulty == 2) // Player is not softcore if (args.TPlayer.difficulty == PlayerDifficultyID.MediumCore || args.TPlayer.difficulty == PlayerDifficultyID.Hardcore) // Player is not softcore
{ {
bool mediumcore = args.TPlayer.difficulty == 1; bool mediumcore = args.TPlayer.difficulty == PlayerDifficultyID.MediumCore;
bool shouldBan = mediumcore ? TShock.Config.Settings.BanOnMediumcoreDeath : TShock.Config.Settings.BanOnHardcoreDeath; bool shouldBan = mediumcore ? TShock.Config.Settings.BanOnMediumcoreDeath : TShock.Config.Settings.BanOnHardcoreDeath;
bool shouldKick = mediumcore ? TShock.Config.Settings.KickOnMediumcoreDeath : TShock.Config.Settings.KickOnHardcoreDeath; bool shouldKick = mediumcore ? TShock.Config.Settings.KickOnMediumcoreDeath : TShock.Config.Settings.KickOnHardcoreDeath;
string banReason = mediumcore ? TShock.Config.Settings.MediumcoreBanReason : TShock.Config.Settings.HardcoreBanReason; string banReason = mediumcore ? TShock.Config.Settings.MediumcoreBanReason : TShock.Config.Settings.HardcoreBanReason;
@ -4387,7 +4388,7 @@ namespace TShockAPI
} }
} }
if (args.TPlayer.difficulty == 2 && Main.ServerSideCharacter && args.Player.IsLoggedIn) if (args.TPlayer.difficulty == PlayerDifficultyID.Hardcore && Main.ServerSideCharacter && args.Player.IsLoggedIn)
{ {
if (TShock.CharacterDB.RemovePlayer(args.Player.Account.ID)) if (TShock.CharacterDB.RemovePlayer(args.Player.Account.ID))
{ {
@ -4578,7 +4579,7 @@ namespace TShockAPI
// and the server will replicate the changes the client did. This means that PlayerData.StoreSlot is never called, so we need to // and the server will replicate the changes the client did. This means that PlayerData.StoreSlot is never called, so we need to
// swap around the PlayerData items ourself. // swap around the PlayerData items ourself.
Tuple<int, int> GetArmorSlotsForLoadoutIndex(int index) (int, int) GetArmorSlotsForLoadoutIndex(int index)
{ {
return index switch return index switch
{ {
@ -4588,7 +4589,7 @@ namespace TShockAPI
}; };
} }
Tuple<int, int> GetDyeSlotsForLoadoutIndex(int index) (int, int) GetDyeSlotsForLoadoutIndex(int index)
{ {
return index switch return index switch
{ {

View file

@ -100,52 +100,52 @@ namespace TShockAPI
(LoadoutArmorSlots * 3) + (LoadoutArmorSlots * 3) +
(LoadoutDyeSlots * 3); (LoadoutDyeSlots * 3);
public static readonly Tuple<int, int> InventoryIndex = new Tuple<int, int>(0, InventorySlots); public static readonly (int, int) InventoryIndex = (0, InventorySlots);
public static readonly Tuple<int, int> ArmorIndex = public static readonly (int, int) ArmorIndex =
new Tuple<int, int>(InventoryIndex.Item2, InventoryIndex.Item2 + ArmorSlots); (InventoryIndex.Item2, InventoryIndex.Item2 + ArmorSlots);
public static readonly Tuple<int, int> DyeIndex = public static readonly (int, int) DyeIndex =
new Tuple<int, int>(ArmorIndex.Item2, ArmorIndex.Item2 + DyeSlots); (ArmorIndex.Item2, ArmorIndex.Item2 + DyeSlots);
public static readonly Tuple<int, int> MiscEquipIndex = public static readonly (int, int) MiscEquipIndex =
new Tuple<int, int>(DyeIndex.Item2, DyeIndex.Item2 + MiscEquipSlots); (DyeIndex.Item2, DyeIndex.Item2 + MiscEquipSlots);
public static readonly Tuple<int, int> MiscDyeIndex = public static readonly (int, int) MiscDyeIndex =
new Tuple<int, int>(MiscEquipIndex.Item2, MiscEquipIndex.Item2 + MiscDyeSlots); (MiscEquipIndex.Item2, MiscEquipIndex.Item2 + MiscDyeSlots);
public static readonly Tuple<int, int> PiggyIndex = public static readonly (int, int) PiggyIndex =
new Tuple<int, int>(MiscDyeIndex.Item2, MiscDyeIndex.Item2 + PiggySlots); (MiscDyeIndex.Item2, MiscDyeIndex.Item2 + PiggySlots);
public static readonly Tuple<int, int> SafeIndex = public static readonly (int, int) SafeIndex =
new Tuple<int, int>(PiggyIndex.Item2, PiggyIndex.Item2 + SafeSlots); (PiggyIndex.Item2, PiggyIndex.Item2 + SafeSlots);
public static readonly Tuple<int, int> TrashIndex = public static readonly (int, int) TrashIndex =
new Tuple<int, int>(SafeIndex.Item2, SafeIndex.Item2 + TrashSlots); (SafeIndex.Item2, SafeIndex.Item2 + TrashSlots);
public static readonly Tuple<int, int> ForgeIndex = public static readonly (int, int) ForgeIndex =
new Tuple<int, int>(TrashIndex.Item2, TrashIndex.Item2 + ForgeSlots); (TrashIndex.Item2, TrashIndex.Item2 + ForgeSlots);
public static readonly Tuple<int, int> VoidIndex = public static readonly (int, int) VoidIndex =
new Tuple<int, int>(ForgeIndex.Item2, ForgeIndex.Item2 + VoidSlots); (ForgeIndex.Item2, ForgeIndex.Item2 + VoidSlots);
public static readonly Tuple<int, int> Loadout1Armor = public static readonly (int, int) Loadout1Armor =
new Tuple<int, int>(VoidIndex.Item2, VoidIndex.Item2 + LoadoutArmorSlots); (VoidIndex.Item2, VoidIndex.Item2 + LoadoutArmorSlots);
public static readonly Tuple<int, int> Loadout1Dye = public static readonly (int, int) Loadout1Dye =
new Tuple<int, int>(Loadout1Armor.Item2, Loadout1Armor.Item2 + LoadoutDyeSlots); (Loadout1Armor.Item2, Loadout1Armor.Item2 + LoadoutDyeSlots);
public static readonly Tuple<int, int> Loadout2Armor = public static readonly (int, int) Loadout2Armor =
new Tuple<int, int>(Loadout1Dye.Item2, Loadout1Dye.Item2 + LoadoutArmorSlots); (Loadout1Dye.Item2, Loadout1Dye.Item2 + LoadoutArmorSlots);
public static readonly Tuple<int, int> Loadout2Dye = public static readonly (int, int) Loadout2Dye =
new Tuple<int, int>(Loadout2Armor.Item2, Loadout2Armor.Item2 + LoadoutDyeSlots); (Loadout2Armor.Item2, Loadout2Armor.Item2 + LoadoutDyeSlots);
public static readonly Tuple<int, int> Loadout3Armor = public static readonly (int, int) Loadout3Armor =
new Tuple<int, int>(Loadout2Dye.Item2, Loadout2Dye.Item2 + LoadoutArmorSlots); (Loadout2Dye.Item2, Loadout2Dye.Item2 + LoadoutArmorSlots);
public static readonly Tuple<int, int> Loadout3Dye = public static readonly (int, int) Loadout3Dye =
new Tuple<int, int>(Loadout3Armor.Item2, Loadout3Armor.Item2 + LoadoutDyeSlots); (Loadout3Armor.Item2, Loadout3Armor.Item2 + LoadoutDyeSlots);
[JsonProperty("netID")] [JsonProperty("netID")]
private int _netId; private int _netId;