Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ TryPlacingInChest()

static bool Terraria.UI.ChestUI.TryPlacingInChest ( Item I,
bool justCheck,
int itemSlotContext )
inlinestatic

Definition at line 1275 of file ChestUI.cs.

1276 {
1279 {
1280 return false;
1281 }
1282 Player player = Main.player[Main.myPlayer];
1283 bool flag = false;
1284 if (I.maxStack > 1)
1285 {
1286 for (int i = 0; i < 40; i++)
1287 {
1288 if (chestinv[i].stack >= chestinv[i].maxStack || !I.IsTheSameAs(chestinv[i]))
1289 {
1290 continue;
1291 }
1292 int num = I.stack;
1293 if (I.stack + chestinv[i].stack > chestinv[i].maxStack)
1294 {
1295 num = chestinv[i].maxStack - chestinv[i].stack;
1296 }
1297 if (justCheck)
1298 {
1299 flag = flag || num > 0;
1300 break;
1301 }
1302 I.stack -= num;
1303 chestinv[i].stack += num;
1305 if (I.stack <= 0)
1306 {
1307 I.SetDefaults();
1308 if (sync)
1309 {
1310 NetMessage.SendData(32, -1, -1, null, player.chest, i);
1311 }
1312 break;
1313 }
1314 if (chestinv[i].type == 0)
1315 {
1316 chestinv[i] = I.Clone();
1317 I.SetDefaults();
1318 }
1319 if (sync)
1320 {
1321 NetMessage.SendData(32, -1, -1, null, player.chest, i);
1322 }
1323 }
1324 }
1325 if (I.stack > 0)
1326 {
1327 for (int j = 0; j < 40; j++)
1328 {
1329 if (chestinv[j].stack != 0)
1330 {
1331 continue;
1332 }
1333 if (justCheck)
1334 {
1335 flag = true;
1336 break;
1337 }
1339 chestinv[j] = I.Clone();
1340 I.SetDefaults();
1341 ItemSlot.AnnounceTransfer(new ItemSlot.ItemTransferInfo(chestinv[j], 0, 3));
1342 if (sync)
1343 {
1344 NetMessage.SendData(32, -1, -1, null, player.chest, j);
1345 }
1346 break;
1347 }
1348 }
1349 return flag;
1350 }
static void PlaySound(int type, Vector2 position, int style=1)
static bool IsBlockedFromTransferIntoChest(Item item, Item[] container)
Definition ChestUI.cs:1380
static void GetContainerUsageInfo(out bool sync, out Item[] chestinv)
Definition ChestUI.cs:1352

References Terraria.UI.ItemSlot.AnnounceTransfer(), Terraria.Player.chest, Terraria.UI.ChestUI.GetContainerUsageInfo(), Terraria.UI.ChestUI.IsBlockedFromTransferIntoChest(), Terraria.Main.myPlayer, Terraria.Main.player, Terraria.Audio.SoundEngine.PlaySound(), and Terraria.NetMessage.SendData().

Referenced by Terraria.UI.ItemSlot.GetOverrideInstructions(), Terraria.UI.ItemSlot.OverrideHover(), and Terraria.UI.ItemSlot.OverrideLeftClick().