Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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);
        }
    }

}

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

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.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.