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

Hi, I made a custom grass block and coded it, but when I tried to load minecraft, my textures for my custom grass block were unable to load into minecraft and I do not know what I did wrong.

Here is my code:

 

package mymod.blocks;

 

import java.util.Random;

 

import mymod.Main;

import net.minecraft.block.Block;

import net.minecraft.block.material.Material;

import net.minecraft.client.renderer.texture.IconRegister;

import net.minecraft.creativetab.CreativeTabs;

import net.minecraft.util.Icon;

import net.minecraft.world.IBlockAccess;

import net.minecraft.world.World;

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

 

public class FlamingGrass extends Block

{

    @SideOnly(Side.CLIENT)

    private Icon Dirt_1; //Top of Grass

    @SideOnly(Side.CLIENT)

    private Icon Dirt_3; //Bottom of Grass

    @SideOnly(Side.CLIENT)

    private Icon Dirt_2; //Side of Grass

 

    public FlamingGrass(int par1)

    {

        super(par1, Material.grass);

        this.setTickRandomly(true);

        this.setCreativeTab(CreativeTabs.tabBlock);

    }

 

    @SideOnly(Side.CLIENT)

 

    /**

    * From the specified side and block metadata retrieves the blocks texture. Args: side, metadata

    */

    public Icon getIcon(int par1, int par2)

    {

        return par1 == 1 ? this.Dirt_1 : par1 == 0 ? this.Dirt_3 : this.Dirt_2; // 1- Top    0- Bottom  else: Side );

    }

 

    /**

    * Ticks the block if it's been scheduled

    */

    public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)

    {

        if (!par1World.isRemote)

        {

            if (par1World.getBlockLightValue(par2, par3 + 1, par4) < 4 && par1World.getBlockLightOpacity(par2, par3 + 1, par4) > 2)

            {

                par1World.setBlock(par2, par3, par4, Main.Dirt_3.blockID);

            }

            else if (par1World.getBlockLightValue(par2, par3 + 1, par4) >= 9)

            {

                for (int l = 0; l < 4; ++l)

                {

                    int i1 = par2 + par5Random.nextInt(3) - 1;

                    int j1 = par3 + par5Random.nextInt(5) - 3;

                    int k1 = par4 + par5Random.nextInt(3) - 1;

                    int l1 = par1World.getBlockId(i1, j1 + 1, k1);

 

                    if (par1World.getBlockId(i1, j1, k1) == Main.Dirt_3.blockID && par1World.getBlockLightValue(i1, j1 + 1, k1) >= 4 && par1World.getBlockLightOpacity(i1, j1 + 1, k1) <= 2)

                    {

                        par1World.setBlock(i1, j1, k1, this.blockID);

                    }

                }

            }

        }

    }

 

    /**

    * Returns the ID of the items to drop on destruction.

    */

    public int idDropped(int par1, Random par2Random, int par3)

    {

        return Main.Dirt_3.idDropped(0, par2Random, par3);

    }

 

    @SideOnly(Side.CLIENT)

 

    /**

    * Retrieves the block texture to use based on the display side. Args: iBlockAccess, x, y, z, side

    */

    public Icon getBlockTexture(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)

    {

        if (par5 == 1)

        {

            return this.Dirt_1;

        }

        else if (par5 == 0)

        {

            return Main.Dirt_3.getBlockTextureFromSide(par5);

        }

        else

        {

            Material material = par1IBlockAccess.getBlockMaterial(par2, par3 + 1, par4);

            return material != Material.snow && material != Material.craftedSnow ? this.blockIcon : this.Dirt_2;

        }

    }

 

    @SideOnly(Side.CLIENT)

 

    /**

    * When this method is called, your block should register all the icons it needs with the given IconRegister. This

    * is the only chance you get to register icons.

    */

    public void registerIcons(IconRegister par1IconRegister)

    {

        this.Dirt_2 = par1IconRegister.registerIcon(this.getTextureName() + "Side of Grass (Dirt_2)");

        this.Dirt_1 = par1IconRegister.registerIcon(this.getTextureName() + "Top of Grass (Dirt_1)");

        this.Dirt_3 = par1IconRegister.registerIcon("Bottom of Grass (Dirt_3)");

    }

 

    @SideOnly(Side.CLIENT)

 

    /**

    * A randomly called display update to be able to add particles or other items for display

    */

    public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random)

    {

        super.randomDisplayTick(par1World, par2, par3, par4, par5Random);

 

        if (par5Random.nextInt(10) == 0)

        {

            par1World.spawnParticle("townaura", (double)((float)par2 + par5Random.nextFloat()), (double)((float)par3 + 1.1F), (double)((float)par4 + par5Random.nextFloat()), 0.0D, 0.0D, 0.0D);

        }

    }

}

 

 

  • Author

So those Icons will never be called?

 

Btw, I am currently doing a modding course with this program, and they do not teach me this stuff so, I kind of do not know what my intention was  :(

  • Author

No that's not what they do in the course, they teach you and explain to you what is going on in the code. I am just asking because I want to just be able to finish my custom grass block, + that is also how I learn. :)

No that's not what they do in the course, they teach you and explain to you what is going on in the code. I am just asking because I want to just be able to finish my custom grass block, + that is also how I learn. :)

 

It might help understand why registerIcons won't work if you add @Override before it

 

@Override

public void registerIcons(IconRegister par1IconRegister)

 

Adding @Override for methods you expect to inherit from the base class is a really good way for the compiler to tell you "er, that isn't going to do what you think it will do" :)

 

I forget offhand what the method you're looking for is actually called, you will for sure find it if you have a look at BlockGrass.  Most of the time, I find that's the fastest way to see how to do something, i.e. think of a vanilla item or block or command that does something similar to what I want, and then look at that vanilla code for clues.

 

-TGG

 

 

 

 

Side note, why do your textures/code have a terrible syntax?!

this.Dirt_2 = par1IconRegister.registerIcon(this.getTextureName() + "Side of Grass (Dirt_2)");

 

Does the course you're doing also teach how to make your textures/code looks nice? If so, they're doing it wrong.

Former developer for DivineRPG, Pixelmon and now the maker of Essence of the Gods

  • Author

Ok, so I changed a couple things up on the code, but it still will not work. Here it is currently:

 

 

package mymod.blocks;

 

import java.util.Random;

 

import mymod.Main;

import net.minecraft.block.Block;

import net.minecraft.block.material.Material;

import net.minecraft.client.renderer.texture.IconRegister;

import net.minecraft.creativetab.CreativeTabs;

import net.minecraft.util.Icon;

import net.minecraft.world.IBlockAccess;

import net.minecraft.world.World;

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

 

public class FlamingGrass extends Block

{

    @SideOnly(Side.CLIENT)

    private Icon Dirt_1; //Top of Grass

    @SideOnly(Side.CLIENT)

    private Icon Dirt_3; //Bottom of Grass

    @SideOnly(Side.CLIENT)

    private Icon Dirt_2; //Side of Grass

 

    public FlamingGrass(int par1)

    {

        super(par1, Material.grass);

        this.setTickRandomly(true);

        this.setCreativeTab(CreativeTabs.tabBlock);

    }

 

    @SideOnly(Side.CLIENT)

 

    /**

    * From the specified side and block metadata retrieves the blocks texture. Args: side, metadata

    */

    public Icon getIcon(int par1, int par2)

    {

        return par1 == 1 ? this.Dirt_1 : (par1 == 0 ? Main.Dirt_3.getBlockTextureFromSide(par1) : this.blockIcon); // 1- Top    0- Bottom  else: Side );

    }

 

    /**

    * Ticks the block if it's been scheduled

    */

    public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)

    {

        if (!par1World.isRemote)

        {

            if (par1World.getBlockLightValue(par2, par3 + 1, par4) < 4 && par1World.getBlockLightOpacity(par2, par3 + 1, par4) > 2)

            {

                par1World.setBlock(par2, par3, par4, Main.Dirt_3.blockID);

            }

            else if (par1World.getBlockLightValue(par2, par3 + 1, par4) >= 9)

            {

                for (int l = 0; l < 4; ++l)

                {

                    int i1 = par2 + par5Random.nextInt(3) - 1;

                    int j1 = par3 + par5Random.nextInt(5) - 3;

                    int k1 = par4 + par5Random.nextInt(3) - 1;

                    int l1 = par1World.getBlockId(i1, j1 + 1, k1);

 

                    if (par1World.getBlockId(i1, j1, k1) == Main.Dirt_3.blockID && par1World.getBlockLightValue(i1, j1 + 1, k1) >= 4 && par1World.getBlockLightOpacity(i1, j1 + 1, k1) <= 2)

                    {

                        par1World.setBlock(i1, j1, k1, Main.FlamingGrass.blockID);

                    }

                }

            }

        }

    }

 

    /**

    * Returns the ID of the items to drop on destruction.

    */

    public int idDropped(int par1, Random par2Random, int par3)

    {

        return Main.Dirt_3.idDropped(0, par2Random, par3);

    }

 

  @SideOnly(Side.CLIENT)

 

    /**

    * Retrieves the block texture to use based on the display side. Args: iBlockAccess, x, y, z, side

    */

    public Icon getBlockTexture(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)

    {

        if (par5 == 1)

        {

            return this.Dirt_1;

        }

        else if (par5 == 0)

        {

            return Main.Dirt_3.getBlockTextureFromSide(par5);

        }

        else

        {

          return this.Dirt_2;

        }

    }

 

  @SideOnly(Side.CLIENT)

 

    /**

    * When this method is called, your block should register all the icons it needs with the given IconRegister. This

    * is the only chance you get to register icons.

    */

  @Override public void registerIcons(IconRegister par1IconRegister)

    {

        this.blockIcon = par1IconRegister.registerIcon(this.getTextureName() + "_side");

        this.Dirt_2 = par1IconRegister.registerIcon(this.getTextureName() + "Side of Grass (Dirt_2)");

        this.Dirt_1 = par1IconRegister.registerIcon(this.getTextureName() + "Top of Grass (Dirt_1)");

        this.Dirt_3 = par1IconRegister.registerIcon("Bottom of Grass (Dirt_3)");

    }

 

    @SideOnly(Side.CLIENT)

 

    /**

    * A randomly called display update to be able to add particles or other items for display

    */

    public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random)

    {

        super.randomDisplayTick(par1World, par2, par3, par4, par5Random);

 

        if (par5Random.nextInt(10) == 0)

        {

            par1World.spawnParticle("townaura", (double)((float)par2 + par5Random.nextFloat()), (double)((float)par3 + 1.1F), (double)((float)par4 + par5Random.nextFloat()), 0.0D, 0.0D, 0.0D);

        }

    }

}

 

Hi

 

what are the symptoms?

 

eg compiler error messages, what do you see vs what you expect to see, any related error messages in the console?

 

-TGG

  • Author

I want to see my grass block textures on the grass block, but I get this:

 

2015-01-16 18:26:26 [sEVERE] [Minecraft-Client] Using missing texture, unable to load: minecraft:textures/blocks/MISSING_ICON_TILE_253_nullFlaming Grass Top.png

2015-01-16 18:26:26 [sEVERE] [Minecraft-Client] Using missing texture, unable to load: minecraft:textures/blocks/MISSING_ICON_TILE_253_nullFlaming Grass Bottom.png

2015-01-16 18:26:26 [sEVERE] [Minecraft-Client] Using missing texture, unable to load: minecraft:textures/blocks/MISSING_ICON_TILE_253_nullFlaming Grass Side.png

  • Author

I also changed my code again:

 

package mymod.blocks;

 

import java.util.Random;

 

import mymod.Main;

import net.minecraft.block.Block;

import net.minecraft.block.material.Material;

import net.minecraft.client.renderer.texture.IconRegister;

import net.minecraft.creativetab.CreativeTabs;

import net.minecraft.util.Icon;

import net.minecraft.world.IBlockAccess;

import net.minecraft.world.World;

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

 

public class FlamingGrass extends Block

{

//    @SideOnly(Side.CLIENT)

    private Icon Dirt_1; //Top of Grass

//    @SideOnly(Side.CLIENT)

    private Icon Dirt_3; //Bottom of Grass

 

    public FlamingGrass(int par1)

    {

        super(par1, Material.grass);

        this.setTickRandomly(true);

        this.setCreativeTab(CreativeTabs.tabBlock);

    }

 

//  @SideOnly(Side.CLIENT)

 

    /**

    * From the specified side and block metadata retrieves the blocks texture. Args: side, metadata

    */

    public Icon getIcon(int par1, int par2)

    {

        return par1 == 1 ? this.Dirt_1 : par1 == 0 ? this.Dirt_3 : this.blockIcon; // 1- Top    0- Bottom  else: Side );

    }

 

    /**

    * Ticks the block if it's been scheduled

    */

    public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)

    {

        if (!par1World.isRemote)

        {

            if (par1World.getBlockLightValue(par2, par3 + 1, par4) < 4 && par1World.getBlockLightOpacity(par2, par3 + 1, par4) > 2)

            {

                par1World.setBlock(par2, par3, par4, Main.Dirt_3.blockID);

            }

            else if (par1World.getBlockLightValue(par2, par3 + 1, par4) >= 9)

            {

                for (int l = 0; l < 4; ++l)

                {

                    int i1 = par2 + par5Random.nextInt(3) - 1;

                    int j1 = par3 + par5Random.nextInt(5) - 3;

                    int k1 = par4 + par5Random.nextInt(3) - 1;

                    int l1 = par1World.getBlockId(i1, j1 + 1, k1);

 

                    if (par1World.getBlockId(i1, j1, k1) == Main.Dirt_3.blockID && par1World.getBlockLightValue(i1, j1 + 1, k1) >= 4 && par1World.getBlockLightOpacity(i1, j1 + 1, k1) <= 2)

                    {

                        par1World.setBlock(i1, j1, k1, Main.FlamingGrass.blockID);

                    }

                }

            }

        }

    }

 

    /**

    * Returns the ID of the items to drop on destruction.

    */

    public int idDropped(int par1, Random par2Random, int par3)

    {

        return Main.Dirt_3.idDropped(0, par2Random, par3);

    }

 

//  @SideOnly(Side.CLIENT)

 

    /**

    * Retrieves the block texture to use based on the display side. Args: iBlockAccess, x, y, z, side

    */

    public Icon getBlockTexture(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)

    {

        if (par5 == 1)

        {

            return this.Dirt_1;

        }

        else if (par5 == 0)

        {

            return this.Dirt_3;

        }

        else

        {

        return blockIcon;

        }

    }

 

//  @SideOnly(Side.CLIENT)

 

    /**

    * When this method is called, your block should register all the icons it needs with the given IconRegister. This

    * is the only chance you get to register icons.

    */

  @Override public void registerIcons(IconRegister par1IconRegister)

    {

        this.blockIcon = par1IconRegister.registerIcon(this.getTextureName() + "Flaming Grass Side");   

        this.Dirt_1 = par1IconRegister.registerIcon(this.getTextureName() + "Flaming Grass Top");

        this.Dirt_3 = par1IconRegister.registerIcon(this.getTextureName() + "Flaming Grass Bottom");

    }

 

//    @SideOnly(Side.CLIENT)

 

    /**

    * A randomly called display update to be able to add particles or other items for display

    */

    public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random)

    {

        super.randomDisplayTick(par1World, par2, par3, par4, par5Random);

 

        if (par5Random.nextInt(10) == 0)

        {

            par1World.spawnParticle("townaura", (double)((float)par2 + par5Random.nextFloat()), (double)((float)par3 + 1.1F), (double)((float)par4 + par5Random.nextFloat()), 0.0D, 0.0D, 0.0D);

        }

    }

}

this.getTextureName()

 

And is that value ever set anywhere?

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

No, I don't think so.

 

Garbage in, garbage out.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Ummm, what does that mean

 

Exactly what it says on the tin.

 

You didn't put anything into the variable and you're getting nothing out of it.  What did you expect to happen?

 

http://en.wikipedia.org/wiki/Garbage_in,_garbage_out

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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.