C
C#5mo ago
exile

new to c#: terraria struggles

can't seem to get a folder into a namespace, can someone help?
9 Replies
exile
exile5mo ago
using astrallogarium.Content;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;

namespace astrallogarium.Content.Items
{
public class KaiserRaiser : ModItem
{


public override void SetDefaults()
{
Item.useStyle = ItemUseStyleID.Swing;
Item.useAnimation = 10;
Item.useTime = 10;
Item.damage = 350;
Item.knockBack = 4.5f;
Item.width = 78;
Item.height = 122;
Item.scale = 1f;
Item.UseSound = SoundID.Item1;
Item.rare = ItemRarityID.Pink;
Item.value = Item.buyPrice(gold: 23);
Item.DamageType = DamageClass.Melee;
// Item.shoot = ModContent.ProjectileType<>();
Item.noMelee = true;
Item.shootsEveryUse = true;
Item.autoReuse = true;
}

public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
{
float adjustedItemScale = player.GetAdjustedItemScale(Item);
Projectile.NewProjectile(source, player.MountedCenter, new Vector2(player.direction, 0f), type, damage, knockback, player.whoAmI, player.direction * player.gravDir, player.itemAnimationMax, adjustedItemScale);
NetMessage.SendData(MessageID.PlayerControls, -1, -1, null, player.whoAmI);

return base.Shoot(player, source, position, velocity, type, damage, knockback);

}

public override void AddRecipes()
{
Recipe recipe = CreateRecipe();
recipe.AddIngredient(ItemID.FragmentSolar, 50);
recipe.AddIngredient(ItemID.Katana, 1);
recipe.AddTile(TileID.LunarCraftingStation);
recipe.Register();
}
}
}
using astrallogarium.Content;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;

namespace astrallogarium.Content.Items
{
public class KaiserRaiser : ModItem
{


public override void SetDefaults()
{
Item.useStyle = ItemUseStyleID.Swing;
Item.useAnimation = 10;
Item.useTime = 10;
Item.damage = 350;
Item.knockBack = 4.5f;
Item.width = 78;
Item.height = 122;
Item.scale = 1f;
Item.UseSound = SoundID.Item1;
Item.rare = ItemRarityID.Pink;
Item.value = Item.buyPrice(gold: 23);
Item.DamageType = DamageClass.Melee;
// Item.shoot = ModContent.ProjectileType<>();
Item.noMelee = true;
Item.shootsEveryUse = true;
Item.autoReuse = true;
}

public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
{
float adjustedItemScale = player.GetAdjustedItemScale(Item);
Projectile.NewProjectile(source, player.MountedCenter, new Vector2(player.direction, 0f), type, damage, knockback, player.whoAmI, player.direction * player.gravDir, player.itemAnimationMax, adjustedItemScale);
NetMessage.SendData(MessageID.PlayerControls, -1, -1, null, player.whoAmI);

return base.Shoot(player, source, position, velocity, type, damage, knockback);

}

public override void AddRecipes()
{
Recipe recipe = CreateRecipe();
recipe.AddIngredient(ItemID.FragmentSolar, 50);
recipe.AddIngredient(ItemID.Katana, 1);
recipe.AddTile(TileID.LunarCraftingStation);
recipe.Register();
}
}
}
exile
exile5mo ago
No description
mg
mg5mo ago
what do you mean by get a folder into a namespace they're different concepts
exile
exile5mo ago
specifically when i add projectiles i get the error saying this projectiles is the folder i am refrencing
No description
mg
mg5mo ago
largely unrelated
exile
exile5mo ago
this is what i get
No description
exile
exile5mo ago
but it's right here
mg
mg5mo ago
Again, namespaces and folders are not equivalent Just because the .cs file is in that folder doesn't mean it's in the namespace You could have 100 different folders on 10 different levels in your project and everything could still be in the same namespace You need to look in the KaiserRaiserSword.cs file and make sure that the classes defined within it are in the astrallogarium.Content.Projectiles namespace Just like the KaiserRaiser class is in the astrallogarium.Content.Items namespace
exile
exile5mo ago
oh i forgot to define it in the other thing wowe i feel really really dumb rn