using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using SubworldLibrary;
using kurti256testmod.Common;
using Microsoft.Xna.Framework;
namespace kurti256testmod.Content.Items
{
public class MirrorOfCorruption : ModItem
{
public static string evil = "none";
// The Display Name and Tooltip of this item can be edited in the Localization/en-US_Mods.testmod.hjson file.
public override void SetDefaults()
{
Item.useStyle = ItemUseStyleID.HoldUp;
Item.width = 40;
Item.height = 40;
Item.useTime = 20;
Item.useAnimation = 20;
}
public override bool? UseItem(Player player)
{
return true;
}
// UseStyle is called each frame that the item is being actively used.
public override void UseStyle(Player player, Rectangle heldItemFrame)
{
// Each frame, make some dust
if (Main.rand.NextBool())
{
Dust.NewDust(player.position, player.width, player.height, DustID.MagicMirror, 0f, 0f, 150, Color.White, 1.1f); // Makes dust from the player's position and copies the hitbox of which the dust may spawn. Change these arguments if needed.
}
// This sets up the itemTime correctly.
if (player.itemTime == 0)
{
player.ApplyItemTime(Item);
}
else if (player.itemTime == player.itemTimeMax / 2)
{
if (player.whoAmI == Main.myPlayer) //makes entering the world player dependant (hopefully)
{
// This code runs once halfway through the useTime of the Item. You'll notice with magic mirrors you are still holding the item for a little bit after you've teleported.
if (SubworldSystem.IsActive<ExampleSubworld>() == false)
{
if (Main.ActiveWorldFileData.HasCrimson == true)
{
evil = "crimson";
MirrorOfCrimson.evil = "crimson";
}
if (Main.ActiveWorldFileData.HasCorruption == true)
{
evil = "corruption";
MirrorOfCrimson.evil = "crorruption";
}
SubworldSystem.Enter<ExampleSubworld>();
}
else
{
SubworldSystem.Exit();
}
}
// Make dust 80 times for a cool effect.
for (int d = 0; d < 80; d++)
{
Dust.NewDust(player.position, player.width, player.height, DustID.MagicMirror, player.velocity.X * 0.5f, player.velocity.Y * 0.5f, 150, new Color(66, 6, 144), 1.5f);
}
// Make dust 80 times for a cool effect. This dust is the dust at the destination.
for (int d = 0; d < 80; d++)
{
Dust.NewDust(player.position, player.width, player.height, DustID.MagicMirror, 0f, 0f, 150, new Color(66, 6, 144), 1.5f);
}
}
}
public override void AddRecipes()
{
CreateRecipe()
.AddCondition(Condition.CrimsonWorld)
.AddIngredient(ItemID.TissueSample,5)
.AddTile(TileID.DemonAltar)
.Register();
/*if (ModLoader.TryGetMod("Kurti256TestMod", out Mod calamityMod) && calamityMod.TryFind<ModItem>("SoapBar", out ModItem theModItemYouWant))
{
CreateRecipe()
.AddCondition(kurti256customconditions.WorldIsCrimson)
.AddIngredient(ItemID.DirtBlock, 1)
.AddIngredient(theModItemYouWant)
.AddTile(TileID.WorkBenches)
.Register();
}*/
}
}
}
pretty much this
code i join the subworld with below
although to note this issue is reproducible with
SubworldSystem.Enter();