Posted January 1, 201510 yr As I follow tutorials on how to set mods up, there is this generic method people use to texture blocks. I'm sure all of you modders out there have heard of it, it is the .setBlockTextureName method that is supposed to be defined by the net.minecraft.block.Block package. My problem is this: Upon importing the net.minecraft.block.Block package everything seems to run smoothly until I want to texture the block. If I do type in .setBlockTextureName method I get an error. If I look for something to resolve this error via the left click is says "The method setBlockTextureName(String) from the type Block is not visible" I have tried many things to fix this error, but to no avail. I call to you, fellow modders, for I require a solution to this error as it is very stressing to see. -XenoMustache
January 1, 201510 yr have you tried this.setBlockTextureName? If you are trying that/have tried it, look at the "registerBlockIcons" and "getIcon" methods. They give you more control over texturing anyways. The proud(ish) developer of Ancients
January 1, 201510 yr Author Well, I would need help applying either of these methods as I have no Idea how to use them and the autodetect system doesn't give much information. -XenoMustache
January 1, 201510 yr Access Control in Java Stack Overflow Question with user responses Java Support Forum BEFORE ASKING FOR HELP READ THE EAQ! I'll help if I can. Apologies if I do something obviously stupid. If you don't know basic Java yet, go and follow these tutorials.
January 1, 201510 yr Author I'm really sorry but those links help me in no way what-so-ever. -XenoMustache
January 1, 201510 yr Block#setBlockTextureName is a public method, so if you are having trouble using it, the problem is likely a failure in Java syntax: post your code. http://i.imgur.com/NdrFdld.png[/img]
January 1, 201510 yr Author import com.xenopack.lib.RefStrings; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Blocks; import cpw.mods.fml.common.registry.GameRegistry; public class TestingBlock { public static void mainRegistry(){ initializeBlock(); registerBlock(); } public static Block tBlock; public static void initializeBlock(){ tBlock = new tBlock(Material.ground).setBlockName("tBlock").setCreativeTab(CreativeTabs.tabBlock); } public static void registerBlock(){ GameRegistry.registerBlock(tBlock, tBlock.getUnlocalizedName()); } } This is the direct code that I am using from the package. -XenoMustache
January 1, 201510 yr And where is your 'tBlock' class? Is that even a class? Each word in a class name should begin with an uppercase letter, so 'TBlock' is a proper class name, but 'tBlock' is not. This is important for readability and to avoid ambiguity: does 'tBlock' refer to the class or the Block instance you created earlier (that's rhetorical)? http://i.imgur.com/NdrFdld.png[/img]
January 1, 201510 yr Author The tBlock class just extends the Block class, and has an empty constructor, but this has nothing to do with the texturing of the "Testing block". -XenoMustache
January 1, 201510 yr The tBlock class just extends the Block class, and has an empty constructor, but this has nothing to do with the texturing of the "Testing block". Well it has everything to do with it if you claim it has an empty constructor, but look at your own code: tBlock = new tBlock(Material.ground) // <-- that is NOT empty! .setBlockName("tBlock").setCreativeTab(CreativeTabs.tabBlock); I can tell you with 100% certainty that 'someBlock = new Block(Material.ground).setBlockTextureName("whatever")' works just fine. It is a public method, so whatever you are doing elsewhere in your code, it is wrong. http://i.imgur.com/NdrFdld.png[/img]
January 1, 201510 yr Author There is nothing else in my code that has anything to do with the Block class. -XenoMustache
January 1, 201510 yr Author I began to look in the source code package and found the string "textureName" to be protected. I cannot change this, however, as it is input into the original game and is not editable. -XenoMustache
January 1, 201510 yr This is off topic but, The registerBlockIcons method gives you the IIconRegister for minecraft, you can call "registerIcon", the string is your modid+texture name (same as basic one). This method returns an IIcon, which is stored on a Client side only Variable like so: @SideOnly(Side.CLIENT) public static IIcon yourIcon; The registerBlockIcons would look something like this: public void registerBlockIcons(IIconRegister register){ yourIcon = register.registerIcon("modid:texturename"); } In the getIcon method, it's fairly self explanatory, it's args are the side (0-bottom,1-top etc) and the block's metadata. If you just want to make the block entirely one texture, just return that IIcon: public IIcon getIcon(int side, int metadata){ return yourIcon; } The proud(ish) developer of Ancients
January 1, 201510 yr It's a random variable, type whatever you want just make sure they're the same-it's still a variable The proud(ish) developer of Ancients
January 1, 201510 yr Author Okay, I'm not sure I understand how to set up the @SideOnly part of this, do I put this in my MainRegistry package? -XenoMustache
January 1, 201510 yr There is nothing else in my code that has anything to do with the Block class. Can you at least post your block class, then? You are clearly doing something wrong, which you can prove to yourself by trying this simple test: // in your main mod class, add these lines of code: public static Block test; @Mod.EventHandler public void preInit(FMLPreInitializationEvent event) { // I would have used Block(Material), but it is protected test = new BlockObsidian().setBlockName("test").setBlockTextureName("stone").setCreativeTab(CreativeTabs.tabBlock); GameRegistry.registerBlock(test, test.getUnlocalizedName()); } You will now have a 'tile.test.name' block in your creative tab that is textured like vanilla smooth stone. Ergo, the problem is somewhere specifically in your code and has nothing to do with lack of access to setBlockTextureName. http://i.imgur.com/NdrFdld.png[/img]
January 1, 201510 yr Author I was hoping that what you posted would help with this problem, but sadly, no. I have done nothing else with the Block class, pasting the things you sent just gave me the same results, no access to .setBlockTextureName. -XenoMustache
January 1, 201510 yr Weird, the only thing I can think of is not setting up your workspace correctly (don't ask me how to do it correctly, I can't even understand how I did it before). The proud(ish) developer of Ancients
January 1, 201510 yr Then there is a problem with your workspace or Forge version or both. What version of Forge are you using? http://i.imgur.com/NdrFdld.png[/img]
January 1, 201510 yr Author Then there is a problem with your workspace or Forge version or both. What version of Forge are you using? I am using the latest SRC version for 1.7.10. -XenoMustache
January 1, 201510 yr I can't imagine that they changed the method from public to protected, but perhaps they did. Try using the recommended build 1230 (it's what I used for my test example). If that works, then the problem is Forge changed the method visibility, and you'll have to put it inside your block class. public class YourBlock extends Block { public YourBlock() { super(Material.rock); setBlockTextureName("stone"); } } If it still doesn't work using the recommended build, then the problem is somehow with your workspace, in which case you should re-run 'gradlew --refresh-dependencies setupDecompWorkspace'. http://i.imgur.com/NdrFdld.png[/img]
January 1, 201510 yr Author I don't really want to set up another workspace because I have done that 3 times already. -XenoMustache
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.