Posted June 7, 201411 yr I'm trying to get a block with a texture for sides, top and bottom. But all sides are always the side texture. I've followed several tutorials but it's just not working. This is my code. What am I doing wrong? package com.pixelmoncore.blocks; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.util.IIcon; import com.pixelmoncore.main.Main; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class Wall extends Block { @SideOnly(Side.CLIENT) public IIcon topIcon; @SideOnly(Side.CLIENT) public IIcon bottomIcon; @SideOnly(Side.CLIENT) public IIcon getIcon(int side, int metadata) { return side == 1 || side == 0 ? this.topIcon : (side == 4 ? this.bottomIcon : this.blockIcon); } @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister iconRegister) { this.blockIcon = iconRegister.registerIcon(Main.modid + ":" + "wallSide"); this.topIcon = iconRegister.registerIcon(Main.modid + ":" + "wallTop"); this.bottomIcon = iconRegister.registerIcon(Main.modid + ":" + "wallBottom"); } public Wall() { super(Material.rock); this.setHardness(2F); this.setResistance(20F); } public void setHarvestLevel(String toolClass, int level) { for (int m = 0; m < 16; m++) { setHarvestLevel("pickaxe", 2); } } }
June 8, 201411 yr Hi I don't see any obvious problem there. Perhaps you have accidentally made your three icon files the same? Have you given your block a name? I would suggest you put a breakpoint into getIcon to see whether it gets called with different side values and returns the correct icon. This should give you a clue to eliminate a bunch of possible causes. Alternatively @Override public IIcon getIcon(int side, int metadata) { IIcon retval = side == 1 || side == 0 ? this.topIcon : (side == 4 ? this.bottomIcon : this.blockIcon); System.out.println("Side: " + side + " = " + retval); return retval; } As a general rule it's a good idea to put @Override before methods you are trying to override from a base class, can help pick up subtle mistakes. -TGG
June 9, 201411 yr I tested your code and It works fine, as TheGreyGhost said, maybe you simply just made all your textures the same. By the way I would recommend you to shorten your file a bit by replacing: public void setHarvestLevel(String toolClass, int level) { for (int m = 0; m < 16; m++) { setHarvestLevel("pickaxe", 2); } } with one line in the constructor: this.setHarvestLevel("pickaxe", 2); If I helped please press the Thank You button.
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.