Jump to content

Recommended Posts

Posted

I made a custom gun called a pulse rifle and the texture isnt loading. I know that I have the right texture path set. Here is my main class code:

 

 

        public static Item pulseRifle;

 

        pulseRifle = new mymod.items.pulseRifle(0, "pulseRifle").setCreativeTab(MyCreativeTab_1).setMaxStackSize(1).setTextureName("pulseRifle.png");

        GameRegistry.registerItem(pulseRifle, "pulseRifle");

        LanguageRegistry.addName(pulseRifle, "Pulse Rifle");

       

 

And here is the class code:

 

package mymod.items;

 

import mymod.entity.EntityRifleBolt.EntityRifleBolt;

import net.minecraft.client.Minecraft;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.init.Items;

import net.minecraft.item.Item;

import net.minecraft.item.ItemStack;

import net.minecraft.world.World;

import cpw.mods.fml.common.Mod.EventHandler;

import cpw.mods.fml.common.event.FMLPostInitializationEvent;

import cpw.mods.fml.relauncher.Side;

 

public class pulseRifle extends Item {

 

 

 

 

 

 

    private String texturePath = "mymod:";

   

    public pulseRifle(int ItemID, String textureName)

    {

        super();

        this.setUnlocalizedName(textureName);

        this.setCreativeTab(mymod.main.Main.MyCreativeTab_1);

        texturePath += textureName;

        }

 

  @Override

  public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World,EntityPlayer par3EntityPlayer) {

      if(par3EntityPlayer.capabilities.isCreativeMode||par3EntityPlayer.inventory.consumeInventoryItem(Items.redstone))

      {

          par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

          if (!par2World.isRemote)

          {

              par2World.spawnEntityInWorld(new EntityRifleBolt(par2World, par3EntityPlayer));

          }

      }

          return par1ItemStack;

      }

  }

 

Thanks for any help!

Posted

This is pretty basic stuff, there's tutorials everywhere...

 

setTextureName(MODID + ":pulseRifle");

 

Then put your graphic in the right folder...

 

Again, I don't feel like writing a tutorial that's been written 1000 times, but that's the jist. Google is your friend!

I'll need help, and I'll give help. Just ask, you know I will!

Posted

This is pretty basic stuff, there's tutorials everywhere...

 

setTextureName(MODID + ":pulseRifle");

 

Then put your graphic in the right folder...

 

Again, I don't feel like writing a tutorial that's been written 1000 times, but that's the jist. Google is your friend!

Except I did google it, I had been googling it for like an hour. Everything else worked without this code though.

 

Posted

This is pretty basic stuff, there's tutorials everywhere...

 

setTextureName(MODID + ":pulseRifle");

 

Then put your graphic in the right folder...

 

Again, I don't feel like writing a tutorial that's been written 1000 times, but that's the jist. Google is your friend!

Ok, I tried it. It still has no texture.

Posted

Post your updated code.

private String texturePath = "mymod:";

   

    public pulseRifle(int ItemID, String textureName)

    {

   

        super();

        this.setUnlocalizedName(textureName);

        this.setCreativeTab(mymod.main.Main.MyCreativeTab_1);

        this.setTextureName(mymod.main.Main.MODID + "mymod:");

        }

 

  @Override

  public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World,EntityPlayer par3EntityPlayer) {

      if(par3EntityPlayer.capabilities.isCreativeMode||par3EntityPlayer.inventory.consumeInventoryItem(Items.redstone))

      {

          par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

          if (!par2World.isRemote)

          {

              par2World.spawnEntityInWorld(new EntityRifleBolt(par2World, par3EntityPlayer));

          }

      }

          return par1ItemStack;

      }

  }

 

Posted

I hate to be that guy, but I would suggest reading the tutorial, not just copying the code. And I would suggest posting your code and maybe even telling us where you put your texture. However I would assume if you can't follow a tutorial then you can't follow a forum post. This forum is for helping point people to a solution, not for getting a mod written for you. I feel you have more than enough information to solve this issue.

I'll need help, and I'll give help. Just ask, you know I will!

Posted

I hate to be that guy, but I would suggest reading the tutorial, not just copying the code. And I would suggest posting your code and maybe even telling us where you put your texture. However I would assume if you can't follow a tutorial then you can't follow a forum post. This forum is for helping point people to a solution, not for getting a mod written for you. I feel you have more than enough information to solve this issue.

Why do you assume I am not doing what you are telling me to do? I am doing everything in the tutorial and everything you are telling me yet nothing is working!

Posted

Because when you say you have an issue you don't post the code, and then when you do post the code its not in a code tag, and because you still have an issue.  ;) Post your custom item, your registration in the main file, and a screenshot of your file structure, and then I can tell you if you have done what I, dies, and the tutorial have suggested...

I'll need help, and I'll give help. Just ask, you know I will!

Posted

I fixed it, all I needed to do was add  @Override 

@SideOnly(Side.CLIENT)

 

    public void registerIcons(IIconRegister iconRegister)

    {

        this.itemIcon = iconRegister.registerIcon(texturePath);

    } 

 

Posted

You don't need that. All you need to do is fix this line:

this.setTextureName(mymod.main.Main.MODID + "mymod:");

 

The error is pretty obvious.

I tried everything with that line that I could think of, nothing worked. But this did.

Posted

Only time I ever override registerIcons is when I have more than one texture for something (mainly items that have subtypes)

 

like diesieben and strum have been saying, just fix

this.setTextureName(mymod.main.Main.MODID + "mymod:");

 

I will give an example of how I set a texture:

 

weaponSwordSoul = new ItemSwordSoul(ToolMaterial.EMERALD)
			.setCreativeTab(Rot.tabRoT).setUnlocalizedName("weaponSwordSoul")
			.setTextureName(Rot.MODID + ":" + "weapons/soul_sword");

 

my folder path looks like "src\main\resources\assets\rot\textures\items" the bolded letters being my MODID

now when I'm setting this texture I have a folder called "weapons" in my "textures/items" path. Do you need to do that, No.

 

how you would do it:

pulseRifle = new mymod.items.pulseRifle(0, "pulseRifle").setCreativeTab(MyCreativeTab_1).setMaxStackSize(1).setTextureName(mymod.main.Main.MODID +":"+"pulseRifle.png");

 

I am quite sure every other modder on here is looking at me, and my post going Don't do it for him.

 

I have followed those tutorials and all my items work fine, and if doing the right way is not working for you, you have your resources in the "wrong" place

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.