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 owner = args.Data.ReadInt8();
//var position = args.Data.ReadVector2();
if (id is < 0 or > 400)
if (id is < 0 or > Main.maxItems)
return true;
if (id == 400 && owner == 255)
@ -4364,9 +4365,9 @@ namespace TShockAPI
}
// 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 shouldKick = mediumcore ? TShock.Config.Settings.KickOnMediumcoreDeath : TShock.Config.Settings.KickOnHardcoreDeath;
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))
{
@ -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
// swap around the PlayerData items ourself.
Tuple<int, int> GetArmorSlotsForLoadoutIndex(int index)
(int, int) GetArmorSlotsForLoadoutIndex(int index)
{
return index switch
{
@ -4588,7 +4589,7 @@ namespace TShockAPI
};
}
Tuple<int, int> GetDyeSlotsForLoadoutIndex(int index)
(int, int) GetDyeSlotsForLoadoutIndex(int index)
{
return index switch
{

View file

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