Jump to content

[SOLVED] Same Texture = Same Name ?! (Problems concerning LanguageRegistry)


Recommended Posts

Posted

Hello Guys!

 

When I create some new Items which should have the same texture, not only the texture but the name is the same. Every Item is named after the one which was added last. Why is this? (I got this error when I created my landmines with an own Class..)

Main:
landmine		= new BlockLandmine(landmineID, "tnt_side", EnumMobType.mobs, true).setCreativeTab(MoreTools.tabMoreTools).setHardness(0.5F);
playerLandmine		= new BlockLandmine(playerLandmineID, "tnt_side", EnumMobType.players, true).setCreativeTab(MoreTools.tabMoreTools).setHardness(0.5F);
nailBomb		= new BlockLandmine(nailBombID, "tnt_side", EnumMobType.mobs, false).setCreativeTab(MoreTools.tabMoreTools).setHardness(0.5F);
playerNailBomb		= new BlockLandmine(playerNailBombID, "tnt_side", EnumMobType.players, false).setCreativeTab(MoreTools.tabMoreTools).setHardness(0.5F);

GameRegistry.registerBlock(landmine, "Landmine");
GameRegistry.registerBlock(playerLandmine, "Player Landmine");
GameRegistry.registerBlock(playerNailBomb, "Player Nailbomb");
GameRegistry.registerBlock(nailBomb, "Nailbomb");

LanguageRegistry.addName(landmine,"Landmine");
LanguageRegistry.addName(playerLandmine, "Player Landmine");
LanguageRegistry.addName(playerNailBomb,"Player Nail Bomb");
LanguageRegistry.addName(nailBomb, "Nailbomb");

 

BlockLandmine:
package Bedrockminer.MoreTools.Classes;

import java.util.Iterator;
import java.util.List;

import net.minecraft.block.*;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
import net.minecraft.world.Explosion;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;

public class BlockLandmine extends BlockBasePressurePlate {

protected BlockLandmine(int par1, String par2Str, Material par3Material) {
	super(par1, par2Str, par3Material);
}

/** The mob type that can trigger this pressure plate. */
    private EnumMobType triggerMobType;
private EntityLiving EntityLiving;
private boolean destroysBlocks;
private String pictureName;
    
    public BlockLandmine(int par1, String par2Str, EnumMobType par4EnumMobType, boolean destroysStructures)
    {
        super(par1, par2Str, Material.wood);
        this.triggerMobType = par4EnumMobType;
        this.destroysBlocks = destroysStructures;
    }


    /**
     * Returns the current state of the pressure plate. Returns a value between 0 and 
     * 15 based on the number of items on it.
     */
    protected int getPlateState(World par1World, int X, int Y, int Z)
    {
        List list = null;

        if (this.triggerMobType == EnumMobType.everything)
        {
            list = par1World.getEntitiesWithinAABBExcludingEntity((Entity)null, this.getSensitiveAABB(X, Y, Z));
        }

        if (this.triggerMobType == EnumMobType.mobs)
        {
            list = par1World.getEntitiesWithinAABB(EntityLiving.class, this.getSensitiveAABB(X, Y, Z));
        }

        if (this.triggerMobType == EnumMobType.players)
        {
            list = par1World.getEntitiesWithinAABB(EntityPlayer.class, this.getSensitiveAABB(X, Y, Z));
        }

        if (!list.isEmpty())
        {
            Iterator iterator = list.iterator();

            while (iterator.hasNext())
            {
                Entity entity = (Entity)iterator.next();

                if (!entity.doesEntityNotTriggerPressurePlate())
                {
                	explode(par1World, X, Y, Z);  //Explodes if somebody steps on it.
                }
            }
        }
        return 0;
    }
    
    public void onBlockPlacedBy(World world, int X, int Y, int Z, EntityLiving placedby, ItemStack stack){
    	this.EntityLiving = placedby; 
    }
    
    public void onBlockDestroyedByExplosion(World world, int X, int Y, int Z, Explosion expl){
    	explode(world, X, Y, Z);   //Explodes if blown up by another mine, TNT or a creeper
    }

    private void explode(World world, int X, int Y, int Z){
    	world.setBlockToAir(X, Y, Z);
    	world.createExplosion(null, X, Y, Z, 2.6F, this.destroysBlocks);
    }
    
@Override
protected int getPowerSupply(int i) {
	return 0;
}

@Override
protected int getMetaFromWeight(int i) {
	return 0; 
}

        /**
        *  hides itself, it takes the texture from the Block below
        */
@Override
public Icon getBlockTexture(IBlockAccess world, int x, int y, int z, int side) {
    int idBelow = world.getBlockId(x, y - 1, z);
    if (Block.blocksList[idBelow] != null) {
        return Block.blocksList[idBelow].getBlockTexture(world, x, y - 1, z, side);
    } else {
        return blockIcon;// fallback if no block below for some reason
    }
}

public int colorMultiplier(IBlockAccess world, int x, int y, int z){
	Block block = Block.blocksList[world.getBlockId(x, y-1, z)];
	if(block != null)
	    return block.colorMultiplier(world, x, y-1, z);
	else
	    return super.colorMultiplier(world, x, y-1, z);		
}

 public boolean canPlaceBlockAt(World world, int par2, int par3, int par4)
    {
        return world.doesBlockHaveSolidTopSurface(par2, par3 - 1, par4) || 
                                           BlockFence.isIdAFence(world.getBlockId(par2, par3 - 1, par4)) || 
                                           world.getBlockId(par2, par3 -1, par4) == Block.glass.blockID || 
                                           world.getBlockId(par2, par3 -1, par4) == Block.glowStone.blockID;
    }
}

 

If you know, what the error is or if you don't have any Error, please tell me.

Thanks in advance!

Posted

You haven't called setUnlocalizedName(...) in your block 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.

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

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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