Jump to content

[URGENT]Help with ITextureProvider


blaytz

Recommended Posts

Hello everybody,

 

I've got a problem: i've been modding with forge and i just tried adding an armor set so i put this code in:

 

 

package MiscBlocksAndItems.common;

 

import net.minecraft.item.EnumArmorMaterial;

import net.minecraft.item.ItemArmor;

import net.minecraft.item.ItemStack;

import net.minecraftforge.common.IArmorTextureProvider;

 

public class ObsidianArmor extends ItemArmor implements ITextureProvider, IArmorTextureProvider {

 

public ObsidianArmor(int par1, EnumArmorMaterial par2EnumArmorMaterial,

int par3, int par4) {

super(par1, par2EnumArmorMaterial, par3, par4);

}

 

public String getTextureFile(){

return "/MiscBlocksAndItems/Textures.png";

}

public String getArmorTextureFile(ItemStack itemstack) {

if (itemstack.itemID == MiscBlocksAndItems.shiftedIndex || itemstack.itemID == MiscBlocksAndItems.ObsidianChestplate.shiftedIndex || itemstack.itemID == MiscBlocksAndItems.ObsidianBoots.shiftedIndex)

{

    return "/MiscBlocksAndItems/Obsidian_1.png";

}

else if (itemstack.itemID == MiscBlocksAndItems.ObsidianLeggings.shiftedIndex)

{

    return "/MiscBlcoksAndItems/Obsidian_2.png";

}

 

return null;

}

}

 

 

 

but it says "ITextureProvider cannot be resolved as a type."

So i would need some help because without ITextureProvider i cannot create an armor set wich would be stupid since that is the goal of my mod.

 

Thanks for your help,

Mr Blaytz

Link to comment
Share on other sites

Thanks for the prompt response but that is not the problem because when I hover with my mouse over the error it doesn't propose to import ITextureProvider and I know thats not the problem caus' it already gave me that error even before i wrote anything...

 

ITextureProviderError.png

Link to comment
Share on other sites

Solving 1 error didn't make the other, it made the other become clear :)

usually when you remove some bad code, you find more ;)

 

So now we solve for the new problem, what error is it giving?

Post the exact error it is giving and if possible a www.pastebin.com(Set Syntax Highlighting to Java) of the class with the error.

And I'm sure you will get it resolved :)

 

If you guys dont get it.. then well ya.. try harder...

Link to comment
Share on other sites

Well what it says inn it's way is that

What is this "shiftedIndex" you speak of?

 

I'm not sure but I think there is a different name for it now, opening the soruce class for the item's should let you know what the name is now.

 

Edit: endershadow wrote as I made my post, there ya have it^^

If you guys dont get it.. then well ya.. try harder...

Link to comment
Share on other sites

Well if you look at the error it is giving you, what is it telling you?

It's saying that something is undefined... meaning that it's not there!

What is it? Well it can't find a constructor at the class with those parameters, meaning you either have to change the paramterts to match the constructor you have or create a constructor which accepts the parameters you are passing into it :)

 

Without looking into the ObsidianArmor.java file, I can't be sure but I belive you have an constructor method like this:

public ObsidianArmor(int itemID, int TextureID, Material material){

 

so adding the textureID into the lines where you are calling the constructor inn your MiscBlocksAndItems file, should resolve the issue.

 

How much experience with modding and java in general do you have? if you have troubles understanding the error messages like that I assume you are quite new to java and programming? Don't take this as an insult, but if you are let me know and I can find some resources for you to learn some more which in turn will help you solve these kinds of errors on your own :D

 

 

If you guys dont get it.. then well ya.. try harder...

Link to comment
Share on other sites

Thank you Mazetar. I do not consider what you said as an insult, I consider it like a very nice act. Anyways, I do not have any constructor method like that, but I do not quite understand what you mean by saying "adding the textureID  into the lines where you are calling the constructor".

 

EDIT: This is my first minecraft/forge mod and I am currently learning java so I am not very good at it :D

Link to comment
Share on other sites

For the problem:

Paste the ObsidianArmor.java file on pastebin and let us see, you are either missing the constructor or it's parameters are different, in anycase it should be easy to fix :)

 

 

 

For Learning:

Here is a great source for learning the basics of Java, I recommend that you do watch the videos up until he starts with drawing GUI's using JFrame and such. Theres a lot of them but they are all really simple to follow and short!(Like 4-7 mins usually).

http://thenewboston.org/list.php?cat=31

 

Futher following some tutorial series on basics of forge modding will give you a good understanding not only of the specific things which you are creating but also the forge/minecraft code inn general :)

 

Wuppy here has created some nice tutorials both in tekst form AND as videos which could be a nice place to start if you aren't already following a tutorial series :)

http://wuppy29.blogspot.nl/2012/10/forge-modding-142.html

 

 

 

If you guys dont get it.. then well ya.. try harder...

Link to comment
Share on other sites

Video 17 will be dealing with constructors ^^

thenewboston is awesome! :D

 

Now to your code again:

public ObsidianArmor(int par1, EnumArmorMaterial par2EnumArmorMaterial,
                        int par3, int par4) {
                super(par1, par2EnumArmorMaterial, par3, par4);
        }

 

is the ObsidianArmor Constructor, whenever you call for new ObsidianArmor();

This is what's getting called. as you see it takes inn 4 parameters (Parameters are the name for variables that a function needs as an input). Namely Integers par1, par3 and par4, and the EnumArmorMaterial par2.

 

When you inn your mod file "MiscBlocksAndItems" call the line for a new Obsidan Armor, you are not giving it all the variables it needs! You are just giving it the first two variables it needs when you say

ObsidianHelemet = new ObsidianArmor(IbsidianHelmetID, OBSIDIAN)

You need to give it two more ints, to satisfy the 3rd and 4th parameters.

I'm not sure what they are but it should be easy to find out by looking at what the super() call inside the constructor is doing to them.

 

When you click on the line which says super("SOME PARAMETERS HERE"); and press F3 inn eclipse you should be taken to the deffinition of that method which will show you this code:

 

  public ItemArmor(int par1, EnumArmorMaterial par2EnumArmorMaterial, int par3, int par4)
    {
        super(par1);
        this.material = par2EnumArmorMaterial;
        this.armorType = par4;
        this.renderIndex = par3;
//etc.

 

From this you can see that the 3rd paramter is the renderIndex for the ObsidianHelmet and the 4th is for the armor type of the helment :)

Fill inn these numbers when you instansiate the ObsidianHelm like this:

ObsidianHelemet = new ObsidianArmor(IbsidianHelmetID, OBSIDIAN, armorTypeHere, renderIndexNumberHere)

 

If you guys dont get it.. then well ya.. try harder...

Link to comment
Share on other sites

Thank you SO much for your help!! It doesn't give me any errors anymore and I will try it and tell you if it works and... I LOVE YOU Mazetar!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!  :D

 

No seriously you have solved my probleem and I will never thank you enough!

Link to comment
Share on other sites

Yeah... It show the boots but not the rest in my inventory and when I wear those boots they are like white pants...  :'(

I guess you are testing within Eclipse, this just means that it didn't find the file. It should work if you compile it and out the textures in the right place. As for the Eclipse texture you need to put them in a special place in the folder, though I don't remember witch folder it was.

If you found this post helpful, please take your time to give me a "Thank You". :)

Link to comment
Share on other sites

If you place the image files into eclipse into the package structure which you reffer to it as being inn, it should find it.

Also it should find it inside the mcp/src/"The string for the file location you specified inn the code".

If you guys dont get it.. then well ya.. try harder...

Link to comment
Share on other sites

Okay so the boots are fixed, you can now wear them and you see them on you but the icon inn the inventory is not working as you wanted it too? It's just some weird or random icon, right?

 

Maybe you havent told it to read the item texture from a new texture file so it is reading the texture from the /items.png file as is default for all items? :)

If you guys dont get it.. then well ya.. try harder...

Link to comment
Share on other sites

Hello there, the ItemArmor class is a little trickier to work with than other things, mainly due to how it handles rendering its armor. I'm personally awed that you're trying this as a first project, so kudos on your progress. 8)

 

I decided to take the time today to learn about custom armor rendering thanks to this topic, and I'm glad I managed to solve it before the night was over.

 

You can find my source code on an example of how to do so here: https://github.com/Seigyoku/customarmortest

 

This is my first time working with GitHub, and it sadly doesn't make use of IArmorTextureProvider, but I hope it's of help all the same!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • They were already updated, and just to double check I even did a cleanup and fresh update from that same page. I'm quite sure drivers are not the problem here. 
    • i tried downloading the drivers but it says no AMD graphics hardware has been detected    
    • Update your AMD/ATI drivers - get the drivers from their website - do not update via system  
    • As the title says i keep on crashing on forge 1.20.1 even without any mods downloaded, i have the latest drivers (nvidia) and vanilla minecraft works perfectly fine for me logs: https://pastebin.com/5UR01yG9
    • Hello everyone, I'm making this post to seek help for my modded block, It's a special block called FrozenBlock supposed to take the place of an old block, then after a set amount of ticks, it's supposed to revert its Block State, Entity, data... to the old block like this :  The problem I have is that the system breaks when handling multi blocks (I tried some fix but none of them worked) :  The bug I have identified is that the function "setOldBlockFields" in the item's "setFrozenBlock" function gets called once for the 1st block of multiblock getting frozen (as it should), but gets called a second time BEFORE creating the first FrozenBlock with the data of the 1st block, hence giving the same data to the two FrozenBlock :   Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=head] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@73681674 BlockEntityData : id:"minecraft:bed",x:3,y:-60,z:-6} Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=3, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=2, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} here is the code inside my custom "freeze" item :    @Override     public @NotNull InteractionResult useOn(@NotNull UseOnContext pContext) {         if (!pContext.getLevel().isClientSide() && pContext.getHand() == InteractionHand.MAIN_HAND) {             BlockPos blockPos = pContext.getClickedPos();             BlockPos secondBlockPos = getMultiblockPos(blockPos, pContext.getLevel().getBlockState(blockPos));             if (secondBlockPos != null) {                 createFrozenBlock(pContext, secondBlockPos);             }             createFrozenBlock(pContext, blockPos);             return InteractionResult.SUCCESS;         }         return super.useOn(pContext);     }     public static void createFrozenBlock(UseOnContext pContext, BlockPos blockPos) {         BlockState oldState = pContext.getLevel().getBlockState(blockPos);         BlockEntity oldBlockEntity = oldState.hasBlockEntity() ? pContext.getLevel().getBlockEntity(blockPos) : null;         CompoundTag oldBlockEntityData = oldState.hasBlockEntity() ? oldBlockEntity.serializeNBT() : null;         if (oldBlockEntity != null) {             pContext.getLevel().removeBlockEntity(blockPos);         }         BlockState FrozenBlock = setFrozenBlock(oldState, oldBlockEntity, oldBlockEntityData);         pContext.getLevel().setBlockAndUpdate(blockPos, FrozenBlock);     }     public static BlockState setFrozenBlock(BlockState blockState, @Nullable BlockEntity blockEntity, @Nullable CompoundTag blockEntityData) {         BlockState FrozenBlock = BlockRegister.FROZEN_BLOCK.get().defaultBlockState();         ((FrozenBlock) FrozenBlock.getBlock()).setOldBlockFields(blockState, blockEntity, blockEntityData);         return FrozenBlock;     }  
  • Topics

×
×
  • Create New...

Important Information

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