public override void HitWire(int i, int j) { //Top left tile int x = i - Main.tile[i, j].frameX / 18; int y = j - Main.tile[i, j].frameY % animationFrameHeight / 18; Wiring.SkipWire(x, y); Wiring.SkipWire(x, y + 1); Wiring.SkipWire(x, y + 2); Wiring.SkipWire(x + 1, y); Wiring.SkipWire(x + 1, y + 1); Wiring.SkipWire(x + 1, y + 2); Wiring.SkipWire(x + 2, y); Wiring.SkipWire(x + 2, y + 1); Wiring.SkipWire(x + 2, y + 2); try { var tileEntity = (RedChimneyTE)TileEntity.ByPosition[new Point16(x, y)]; tileEntity.CurrentState = tileEntity.CurrentState.NextEnum(); NetMessage.SendData(MessageID.TileEntitySharing, -1, -1, null, tileEntity.ID, x, y); } catch (Exception e) { GoldensMisc.Log("Chimney TileEntity not found! Error! " + e); } }
public override bool NewRightClick(int i, int j) { //Top left tile int x = i - Main.tile[i, j].frameX % 54 / 18; int y = j - Main.tile[i, j].frameY % 38 / 18; try { var te = (AutofisherTE)TileEntity.ByPosition[new Point16(x, y)]; if (Main.netMode == NetmodeID.MultiplayerClient) { var message = mod.GetPacket(); message.Write((byte)MiscMessageType.PrintAutofisherInfo); message.Write(te.ID); message.Send(); } else { if (te.DisplayedFishingInfo != null) { Main.NewText(te.DisplayedFishingInfo); } } } catch (Exception e) { GoldensMisc.Log(e); Main.NewText("Error! Report this error and send the Terraria/Logs/Logs.txt file!"); } return(true); }
public override void Update() { base.Update(); if (Main.netMode != NetmodeID.MultiplayerClient) { bool facingRight = Main.tile[Position.X, Position.Y].frameX == 0; var baitItem = GetCurrentBait(); if (baitItem == null) { DisplayedFishingInfo = Language.GetTextValue("Mods.GoldensMisc.Autofisher.NoBait"); } else if (bobberProj == -1 || !Main.projectile[bobberProj].active || Main.projectile[bobberProj].type != ModContent.ProjectileType <AutofisherBobber>()) { var bobberPos = new Point(Position.X + (facingRight ? 2 : 0), Position.Y).ToWorldCoordinates(); bobberProj = Projectile.NewProjectile(bobberPos, new Vector2(facingRight ? 3f : -3f, 0f), ModContent.ProjectileType <AutofisherBobber>(), 0, 0, ai1: this.ID); Main.projectile[bobberProj].ai[1] = this.ID; Main.projectile[bobberProj].netUpdate = true; _fishingInfo = null; } if (FishingCooldown > 0) { FishingCooldown--; } else { if (Main.rand.Next(150) == 1) { FishingCooldown = 500; int itemType = 0; try { if (baitItem == null) { return; } var projectile = Main.projectile[bobberProj]; itemType = ((AutofisherBobber)projectile.modProjectile).FishingCheck(true); if (itemType > 0) { TryConsumeBait(); } } catch (Exception e) { GoldensMisc.Log(e); Main.NewText("autofisher error! look at Logs.txt"); } } } } }
//Don't animate if deactivated public override void AnimateIndividualTile(int type, int i, int j, ref int frameXOffset, ref int frameYOffset) { //Top left tile int x = i - Main.tile[i, j].frameX / 18; int y = j - Main.tile[i, j].frameY % animationFrameHeight / 18; try { var tileEntity = (RedChimneyTE)TileEntity.ByPosition[new Point16(x, y)]; if (tileEntity.CurrentState == RedChimneyTE.State.Deactivated) { frameYOffset = animationFrameHeight * 6; } } catch (KeyNotFoundException e) { GoldensMisc.Log(e); Main.NewText("Error! Report this error and send the Terraria/Logs/Logs.txt file!"); } }
public override void Update() { try { base.Update(); if ((int)(Main.GlobalTime * 60f) % 100 == GetPickupTime()) { var chest = Main.chest[Chest.FindChest(Position.X, Position.Y + 1)]; var myPos = Position.ToWorldCoordinates(16f, 8f); for (int i = 0; i < Main.maxItems; i++) { var item = Main.item[i]; if (item.active && item.stack > 0 && item.DistanceSQ(myPos) < PickupRadiusSq) { var itemPos = item.position; int itemWidth = item.width; int itemHeight = item.height; //string itemName = item.Name; int oldStack = item.stack; MiscUtils.PutItem(chest, item, SmartStack); if (item.type == 0 || oldStack - item.stack > 0) { if (item.stack == 0 || item.type == 0) { item.active = false; } Main.PlaySound(SoundID.Item8, itemPos); Main.PlaySound(SoundID.Grab, myPos); for (int j = 0; j < 10; j++) { Dust.NewDust(itemPos, itemWidth, itemHeight, 159); Dust.NewDust(Position.ToWorldCoordinates(0, 0), 32, 16, 159); } //if(oldStack - item.stack > 1) // itemName += "(" + (oldStack - item.stack) + ")"; //if(Main.netMode == NetmodeID.Server) //{ // NetMessage.SendData(MessageID.CombatTextString, // text: NetworkText.FromLiteral(itemName), // number: (int)Color.White.PackedValue, // number2: myPos.X, // number3: myPos.Y); //} //else //{ // CombatText.NewText(new Rectangle(Position.X * 16, Position.Y * 16, 32, 16), Color.White, itemName); //} } } } } } catch (Exception e) { Main.NewText("chest vacuum error. look at Logs.txt"); GoldensMisc.Log(e); } }