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

◆ Create()

void Terraria.Recipe.Create ( )
inline

Definition at line 177 of file Recipe.cs.

178 {
179 Item[] array = null;
180 Item item = null;
181 Item item2 = null;
182 for (int i = 0; i < maxRequirements; i++)
183 {
185 if (item2.type == 0)
186 {
187 break;
188 }
189 int num = item2.stack;
190 if (alchemy && Main.player[Main.myPlayer].alchemyTable)
191 {
192 if (num > 1)
193 {
194 int num2 = 0;
195 for (int j = 0; j < num; j++)
196 {
197 if (Main.rand.Next(3) == 0)
198 {
199 num2++;
200 }
201 }
202 num -= num2;
203 }
204 else if (Main.rand.Next(3) == 0)
205 {
206 num = 0;
207 }
208 }
209 if (num <= 0)
210 {
211 continue;
212 }
213 array = Main.player[Main.myPlayer].inventory;
214 for (int k = 0; k < 58; k++)
215 {
216 item = array[k];
217 if (num <= 0)
218 {
219 break;
220 }
221 if (item.IsTheSameAs(item2) || useWood(item.type, item2.type) || useSand(item.type, item2.type) || useFragment(item.type, item2.type) || useIronBar(item.type, item2.type) || usePressurePlate(item.type, item2.type) || AcceptedByItemGroups(item.type, item2.type))
222 {
223 if (item.stack > num)
224 {
225 item.stack -= num;
226 num = 0;
227 }
228 else
229 {
230 num -= item.stack;
231 array[k] = new Item();
232 }
233 }
234 }
235 if (Main.player[Main.myPlayer].chest != -1)
236 {
237 if (Main.player[Main.myPlayer].chest > -1)
238 {
239 array = Main.chest[Main.player[Main.myPlayer].chest].item;
240 }
241 else if (Main.player[Main.myPlayer].chest == -2)
242 {
243 array = Main.player[Main.myPlayer].bank.item;
244 }
245 else if (Main.player[Main.myPlayer].chest == -3)
246 {
247 array = Main.player[Main.myPlayer].bank2.item;
248 }
249 else if (Main.player[Main.myPlayer].chest == -4)
250 {
251 array = Main.player[Main.myPlayer].bank3.item;
252 }
253 else if (Main.player[Main.myPlayer].chest == -5)
254 {
255 array = Main.player[Main.myPlayer].bank4.item;
256 }
257 for (int l = 0; l < 40; l++)
258 {
259 item = array[l];
260 if (num <= 0)
261 {
262 break;
263 }
264 if (!item.IsTheSameAs(item2) && !useWood(item.type, item2.type) && !useSand(item.type, item2.type) && !useIronBar(item.type, item2.type) && !usePressurePlate(item.type, item2.type) && !useFragment(item.type, item2.type) && !AcceptedByItemGroups(item.type, item2.type))
265 {
266 continue;
267 }
268 if (item.stack > num)
269 {
270 item.stack -= num;
271 if (Main.netMode == 1 && Main.player[Main.myPlayer].chest >= 0)
272 {
273 NetMessage.SendData(32, -1, -1, null, Main.player[Main.myPlayer].chest, l);
274 }
275 num = 0;
276 }
277 else
278 {
279 num -= item.stack;
280 array[l] = new Item();
281 if (Main.netMode == 1 && Main.player[Main.myPlayer].chest >= 0)
282 {
283 NetMessage.SendData(32, -1, -1, null, Main.player[Main.myPlayer].chest, l);
284 }
285 }
286 }
287 }
288 if (!Main.player[Main.myPlayer].useVoidBag() || Main.player[Main.myPlayer].chest == -5)
289 {
290 continue;
291 }
292 array = Main.player[Main.myPlayer].bank4.item;
293 for (int m = 0; m < 40; m++)
294 {
295 item = array[m];
296 if (num <= 0)
297 {
298 break;
299 }
300 if (!item.IsTheSameAs(item2) && !useWood(item.type, item2.type) && !useSand(item.type, item2.type) && !useIronBar(item.type, item2.type) && !usePressurePlate(item.type, item2.type) && !useFragment(item.type, item2.type) && !AcceptedByItemGroups(item.type, item2.type))
301 {
302 continue;
303 }
304 if (item.stack > num)
305 {
306 item.stack -= num;
307 if (Main.netMode == 1 && Main.player[Main.myPlayer].chest >= 0)
308 {
309 NetMessage.SendData(32, -1, -1, null, Main.player[Main.myPlayer].chest, m);
310 }
311 num = 0;
312 }
313 else
314 {
315 num -= item.stack;
316 array[m] = new Item();
317 if (Main.netMode == 1 && Main.player[Main.myPlayer].chest >= 0)
318 {
319 NetMessage.SendData(32, -1, -1, null, Main.player[Main.myPlayer].chest, m);
320 }
321 }
322 }
323 }
325 AchievementsHelper.NotifyItemPickup(Main.player[Main.myPlayer], createItem);
326 FindRecipes();
327 }
static void NotifyItemPickup(Player player, Item item)
bool AcceptedByItemGroups(int invType, int reqType)
Definition Recipe.cs:137
Item createItem
Definition Recipe.cs:27
bool useWood(int invType, int reqType)
Definition Recipe.cs:329
static int maxRequirements
Definition Recipe.cs:19
bool usePressurePlate(int invType, int reqType)
Definition Recipe.cs:409
bool useFragment(int invType, int reqType)
Definition Recipe.cs:396
static void FindRecipes(bool canDelayCheck=false)
Definition Recipe.cs:453
bool useSand(int invType, int reqType)
Definition Recipe.cs:383
Item[] requiredItem
Definition Recipe.cs:29
bool useIronBar(int invType, int reqType)
Definition Recipe.cs:366

References Terraria.Recipe.AcceptedByItemGroups(), Terraria.Recipe.alchemy, System.array, Terraria.Main.chest, Terraria.Recipe.createItem, Terraria.Recipe.FindRecipes(), System.item, Terraria.Recipe.maxRequirements, Terraria.Main.myPlayer, Terraria.Main.netMode, Terraria.GameContent.Achievements.AchievementsHelper.NotifyItemCraft(), Terraria.GameContent.Achievements.AchievementsHelper.NotifyItemPickup(), Terraria.Main.player, Terraria.Main.rand, Terraria.Recipe.requiredItem, Terraria.NetMessage.SendData(), Terraria.Recipe.useFragment(), Terraria.Recipe.useIronBar(), Terraria.Recipe.usePressurePlate(), Terraria.Recipe.useSand(), and Terraria.Recipe.useWood().