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

so yeah as the title says i need some help with how to get textures to work on meta data blocks.

 

this is my code for the block

 

 

package naturemod.common.blocks;

 

import static net.minecraftforge.common.EnumPlantType.Cave;

import static net.minecraftforge.common.EnumPlantType.Crop;

import static net.minecraftforge.common.EnumPlantType.Desert;

import static net.minecraftforge.common.EnumPlantType.Nether;

import static net.minecraftforge.common.EnumPlantType.Plains;

import static net.minecraftforge.common.EnumPlantType.Water;

 

import java.util.List;

 

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

import net.minecraft.block.Block;

import net.minecraft.block.BlockFlower;

import net.minecraft.block.material.Material;

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

import net.minecraft.creativetab.CreativeTabs;

import net.minecraft.item.ItemStack;

import net.minecraft.util.Icon;

import net.minecraft.world.IBlockAccess;

import net.minecraft.world.World;

import net.minecraftforge.common.EnumPlantType;

import net.minecraftforge.common.IPlantable;

 

public class BlockMoreFlowers extends BlockFlower implements IPlantable

{

private Icon[] icon;

 

    public static final String[] flowerType = new String[] {"flowerOrange", "flowerMagenta", "flowerLBlue", "flowerPink", "flowerCyan", "flowerPurple"};

    private static final String[] field_94370_b = new String[] {"Nature:flower_0", "Nature:flower_1", "Nature:flower_2", "Nature:flower_3", "Nature:flower_4", "Nature:flower_5"};

    @SideOnly(Side.CLIENT)

    private Icon[] flowerIcon;

 

public BlockMoreFlowers(int id)

{

super(id, Material.plants);

this.setStepSound(soundGrassFootstep);

this.setHardness(0.0f);

this.disableStats();

}

 

@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 this.icon[par2 % this.icon.length];

    }

   

    public int getDamageValue(World par1World, int par2, int par3, int par4)

    {

        return par1World.getBlockMetadata(par2, par3, par4);

    }

 

@Override

public int damageDropped (int metadata) {

return metadata;

}

 

@SideOnly(Side.CLIENT)

public void getSubBlocks(int unknown, CreativeTabs tab, List subItems) {

for (int ix = 0; ix < 6; ix++) {

subItems.add(new ItemStack(this, 1, ix));

}

}

 

@Override

@SideOnly(Side.CLIENT)

public void registerIcons(IconRegister par1IconRegister) {

    this.icon = new Icon[6];

    for(int i = 0; i < 6; i++) {

        this.icon = par1IconRegister.registerIcon("Nature:flower_" + i);

    }

}

 

    @Override

    public EnumPlantType getPlantType(World world, int x, int y, int z)

    {

        return Plains;

    }

 

    @Override

    public int getPlantID(World world, int x, int y, int z)

    {

        return blockID;

    }

 

    @Override

    public int getPlantMetadata(World world, int x, int y, int z)

    {

        return world.getBlockMetadata(x, y, z);

    }

}

 

 

 

 

and this is the error im getting:

 

 

2013-07-02 22:08:23 [iNFO] [sTDOUT] Time: 02/07/13 22:08

2013-07-02 22:08:23 [iNFO] [sTDOUT] Description: Unexpected error

2013-07-02 22:08:23 [iNFO] [sTDOUT]

2013-07-02 22:08:23 [iNFO] [sTDOUT] java.lang.NullPointerException

2013-07-02 22:08:23 [iNFO] [sTDOUT] at naturemod.common.blocks.BlockMoreFlowers.getIcon(BlockMoreFlowers.java:50)

2013-07-02 22:08:23 [iNFO] [sTDOUT] at net.minecraft.client.renderer.RenderBlocks.getBlockIconFromSideAndMetadata(RenderBlocks.java:8164)

2013-07-02 22:08:23 [iNFO] [sTDOUT] at net.minecraft.client.renderer.RenderBlocks.drawCrossedSquares(RenderBlocks.java:3604)

2013-07-02 22:08:23 [iNFO] [sTDOUT] at net.minecraft.client.renderer.RenderBlocks.renderCrossedSquares(RenderBlocks.java:3482)

2013-07-02 22:08:23 [iNFO] [sTDOUT] at net.minecraft.client.renderer.RenderBlocks.renderBlockByRenderType(RenderBlocks.java:449)

2013-07-02 22:08:23 [iNFO] [sTDOUT] at net.minecraft.client.renderer.WorldRenderer.updateRenderer(WorldRenderer.java:224)

2013-07-02 22:08:23 [iNFO] [sTDOUT] at net.minecraft.client.renderer.RenderGlobal.updateRenderers(RenderGlobal.java:1561)

2013-07-02 22:08:23 [iNFO] [sTDOUT] at net.minecraft.client.renderer.EntityRenderer.renderWorld(EntityRenderer.java:1129)

2013-07-02 22:08:23 [iNFO] [sTDOUT] at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1006)

2013-07-02 22:08:23 [iNFO] [sTDOUT] at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:930)

2013-07-02 22:08:23 [iNFO] [sTDOUT] at net.minecraft.client.Minecraft.run(Minecraft.java:822)

2013-07-02 22:08:23 [iNFO] [sTDOUT] at net.minecraft.client.main.Main.main(Main.java:93)

2013-07-02 22:08:23 [iNFO] [sTDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

2013-07-02 22:08:23 [iNFO] [sTDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

2013-07-02 22:08:23 [iNFO] [sTDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

2013-07-02 22:08:23 [iNFO] [sTDOUT] at java.lang.reflect.Method.invoke(Unknown Source)

2013-07-02 22:08:23 [iNFO] [sTDOUT] at net.minecraft.launchwrapper.Launch.launch(Launch.java:57)

2013-07-02 22:08:23 [iNFO] [sTDOUT] at net.minecraft.launchwrapper.Launch.main(Launch.java:18)

 

 

You have an issue here:

 

this.icon = par1IconRegister.registerIcon("Nature:flower_" + i);

 

Isn't "this.icon" an array?

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.

[edit] nevermind, im still having some issues

 

Same error, different error?

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.

Same here, been getting that error whenever I try and access one of the blocks my mod adds.

 

Probably another screw-up with the new texture system.

 

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.