XenoMustache Posted January 1, 2015 Share Posted January 1, 2015 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. Quote -XenoMustache Link to comment Share on other sites More sharing options...
memcallen Posted January 1, 2015 Share Posted January 1, 2015 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. Quote The proud(ish) developer of Ancients Link to comment Share on other sites More sharing options...
XenoMustache Posted January 1, 2015 Author Share Posted January 1, 2015 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. Quote -XenoMustache Link to comment Share on other sites More sharing options...
shieldbug1 Posted January 1, 2015 Share Posted January 1, 2015 Access Control in Java Stack Overflow Question with user responses Java Support Forum Quote 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. Link to comment Share on other sites More sharing options...
XenoMustache Posted January 1, 2015 Author Share Posted January 1, 2015 I'm really sorry but those links help me in no way what-so-ever. Quote -XenoMustache Link to comment Share on other sites More sharing options...
coolAlias Posted January 1, 2015 Share Posted January 1, 2015 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. Quote http://i.imgur.com/NdrFdld.png[/img] Link to comment Share on other sites More sharing options...
XenoMustache Posted January 1, 2015 Author Share Posted January 1, 2015 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. Quote -XenoMustache Link to comment Share on other sites More sharing options...
coolAlias Posted January 1, 2015 Share Posted January 1, 2015 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)? Quote http://i.imgur.com/NdrFdld.png[/img] Link to comment Share on other sites More sharing options...
XenoMustache Posted January 1, 2015 Author Share Posted January 1, 2015 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". Quote -XenoMustache Link to comment Share on other sites More sharing options...
coolAlias Posted January 1, 2015 Share Posted January 1, 2015 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. Quote http://i.imgur.com/NdrFdld.png[/img] Link to comment Share on other sites More sharing options...
XenoMustache Posted January 1, 2015 Author Share Posted January 1, 2015 There is nothing else in my code that has anything to do with the Block class. Quote -XenoMustache Link to comment Share on other sites More sharing options...
XenoMustache Posted January 1, 2015 Author Share Posted January 1, 2015 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. Quote -XenoMustache Link to comment Share on other sites More sharing options...
memcallen Posted January 1, 2015 Share Posted January 1, 2015 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; } Quote The proud(ish) developer of Ancients Link to comment Share on other sites More sharing options...
XenoMustache Posted January 1, 2015 Author Share Posted January 1, 2015 What would I type in place of "yourIcon"? Quote -XenoMustache Link to comment Share on other sites More sharing options...
memcallen Posted January 1, 2015 Share Posted January 1, 2015 It's a random variable, type whatever you want just make sure they're the same-it's still a variable Quote The proud(ish) developer of Ancients Link to comment Share on other sites More sharing options...
XenoMustache Posted January 1, 2015 Author Share Posted January 1, 2015 Okay, I'm not sure I understand how to set up the @SideOnly part of this, do I put this in my MainRegistry package? Quote -XenoMustache Link to comment Share on other sites More sharing options...
memcallen Posted January 1, 2015 Share Posted January 1, 2015 Everything goes in your block class Quote The proud(ish) developer of Ancients Link to comment Share on other sites More sharing options...
coolAlias Posted January 1, 2015 Share Posted January 1, 2015 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. Quote http://i.imgur.com/NdrFdld.png[/img] Link to comment Share on other sites More sharing options...
XenoMustache Posted January 1, 2015 Author Share Posted January 1, 2015 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. Quote -XenoMustache Link to comment Share on other sites More sharing options...
memcallen Posted January 1, 2015 Share Posted January 1, 2015 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). Quote The proud(ish) developer of Ancients Link to comment Share on other sites More sharing options...
coolAlias Posted January 1, 2015 Share Posted January 1, 2015 Then there is a problem with your workspace or Forge version or both. What version of Forge are you using? Quote http://i.imgur.com/NdrFdld.png[/img] Link to comment Share on other sites More sharing options...
XenoMustache Posted January 1, 2015 Author Share Posted January 1, 2015 Everything goes in your block class Oh I see now. Quote -XenoMustache Link to comment Share on other sites More sharing options...
XenoMustache Posted January 1, 2015 Author Share Posted January 1, 2015 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. Quote -XenoMustache Link to comment Share on other sites More sharing options...
coolAlias Posted January 1, 2015 Share Posted January 1, 2015 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'. Quote http://i.imgur.com/NdrFdld.png[/img] Link to comment Share on other sites More sharing options...
XenoMustache Posted January 1, 2015 Author Share Posted January 1, 2015 I don't really want to set up another workspace because I have done that 3 times already. Quote -XenoMustache Link to comment Share on other sites More sharing options...
Recommended Posts
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.