Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.7.10]Textures That Change Based on metadata


NEG2013
 Share

Recommended Posts

 

 

 

 

 

 

 

 

 

 

 

 

 

I added a tank that works in all aspects beside the fact that the texture will not load at all I posted the entire class below.

 

 

 

 

 

 

 

 

 

package neg2013.acsension.infrastructure;

 

 

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

import neg2013.acsension.block.BlockCopperIngot;

import net.minecraft.block.Block;

import net.minecraft.block.material.Material;

import net.minecraft.client.Minecraft;

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

import net.minecraft.entity.boss.IBossDisplayData;

import net.minecraft.entity.item.EntityItem;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.entity.player.EntityPlayerMP;

import net.minecraft.init.Blocks;

import net.minecraft.init.Items;

import net.minecraft.inventory.Container;

import net.minecraft.item.ItemArmor;

import net.minecraft.item.ItemStack;

import net.minecraft.util.ChatComponentText;

import net.minecraft.util.IChatComponent;

import net.minecraft.util.IIcon;

import net.minecraft.util.MathHelper;

import net.minecraft.world.World;

 

public class BlockTank extends Block{

 

@SideOnly(Side.CLIENT)

    private IIcon field_150035_a;

    @SideOnly(Side.CLIENT)

    private IIcon field_150034_b;

    private static final String __OBFID = "CL_00000221";

 

    @Override

    public boolean isOpaqueCube() {

    return false;

    }

 

    @Override

    public boolean renderAsNormalBlock() {

    return false;

    }

   

public BlockTank(Material material) {

super(material);

this.setHardness(2f);

}

 

 

 

 

   

    //storage things

   

   

    public void func_150024_a(World world, int a, int b, int c, int p_150024_5_)

    {

        world.setBlockMetadataWithNotify(a, b, c, MathHelper.clamp_int(p_150024_5_, 0, 44), 2);

        world.func_147453_f(a, b, c, this);

    }   

    public static int func_150027_b(int a)

    {

        return a;

    } 

 

    public boolean onBlockActivated( World world, int p_149727_2_, int p_149727_3_, int p_149727_4_, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_)

    {

        if (world.isRemote)

        {

            return true;

        }

        else

        {

         

       

       

        ItemStack itemstack = player.inventory.getCurrentItem();

 

            if (itemstack == null)

            {

                return true;

           

            }

           

           

           

           

           

           

            else

            {

                int i1 = world.getBlockMetadata(p_149727_2_, p_149727_3_, p_149727_4_);

                int j1 = func_150027_b(i1);

 

               

             

               

               

               

               

                if (itemstack.getItem() == Items.water_bucket)

                {

                    if (j1 < 10)

                    {

                        if (!player.capabilities.isCreativeMode)

                        {

                            player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(Items.bucket));

                        }

 

                        this.func_150024_a(world, p_149727_2_, p_149727_3_, p_149727_4_, j1 + 1);

                    }

                    if (itemstack.getItem() == Items.bucket)

                    {

                        if (j1 > 0)

                        {

                            if (!player.capabilities.isCreativeMode)

                            {

                                player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(Items.water_bucket));

                            }

 

                            this.func_150024_a(world, p_149727_2_, p_149727_3_, p_149727_4_,j1 + 1);

                        }

 

                        return true;

                    }

                   

                    return true;

                }

                else

                {

                    if (itemstack.getItem() == Items.glass_bottle)

                    {

                        if (j1 > 0)

                        {

                            if (!player.capabilities.isCreativeMode)

                            {

                                ItemStack itemstack1 = new ItemStack(Items.potionitem, 1, 0);

 

                                if (!player.inventory.addItemStackToInventory(itemstack1))

                                {

                                    world.spawnEntityInWorld(new EntityItem(world, (double)p_149727_2_ + 0.5D, (double)p_149727_3_ + 1.5D, (double)p_149727_4_ + 0.5D, itemstack1));

                                }

                                else if (player instanceof EntityPlayerMP)

                                {

                                    ((EntityPlayerMP)player).sendContainerToPlayer(player.inventoryContainer);

                                }

 

                                --itemstack.stackSize;

 

                                if (itemstack.stackSize <= 0)

                                {

                                    player.inventory.setInventorySlotContents(player.inventory.currentItem, (ItemStack)null);

                                }

                            }

 

                            this.func_150024_a(world, p_149727_2_, p_149727_3_, p_149727_4_, j1 - 1);

                        }

                    }

                    else if (j1 > 0 && itemstack.getItem() instanceof ItemArmor && ((ItemArmor)itemstack.getItem()).getArmorMaterial() == ItemArmor.ArmorMaterial.CLOTH)

                    {

                        ItemArmor itemarmor = (ItemArmor)itemstack.getItem();

                        itemarmor.removeColor(itemstack);

                        this.func_150024_a(world, p_149727_2_, p_149727_3_, p_149727_4_, j1 - 1);

                        return true;

                    }

                    if(itemstack.getItem() == Items.bucket && j1 > 0)

                    {

                    if (j1 < 10)

                        {

                            if (!player.capabilities.isCreativeMode)

                            {

                                player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(Items.water_bucket));

                            }

 

                            this.func_150024_a(world, p_149727_2_, p_149727_3_, p_149727_4_, j1 - 1);

                        }

                        if (itemstack.getItem() == Items.water_bucket)

                        {

                            if (j1 > 0)

                            {

                                if (!player.capabilities.isCreativeMode)

                                {

                                    player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(Items.water_bucket));

                                }

 

                                this.func_150024_a(world, p_149727_2_, p_149727_3_, p_149727_4_, j1 - 1);

                            }

 

                            return true;

                        }

                        this.func_150024_a(world, p_149727_2_, p_149727_3_, p_149727_4_, j1 - 1);

                        return true;

                    }

                   

                   

                    return false;

                }

            }

           

       

           

        }

    }

   

 

    @SideOnly(Side.CLIENT)

    public void registerBlockIcons(IIconRegister p_149651_1_, World world, int z, int y, int x)

 

    {

       

   

   

    int i1 = world.getBlockMetadata(x, y, z);

        int j1 = func_150027_b(i1);

 

   

   

    if(i1 == 0){

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

                this.field_150034_b = p_149651_1_.registerIcon(this.getTextureName() + "_side");

               

        }if(i1 <= 4){

        this.blockIcon = p_149651_1_.registerIcon(this.getTextureName() + "_side1"  );

                this.field_150034_b = p_149651_1_.registerIcon(this.getTextureName() + "_side1");

               

        }if(i1 <= 8){

        this.blockIcon = p_149651_1_.registerIcon(this.getTextureName() + "_side2"  );

                this.field_150034_b = p_149651_1_.registerIcon(this.getTextureName() + "_side2");

               

        }if(i1 <= 12){

        this.blockIcon = p_149651_1_.registerIcon(this.getTextureName() + "_side3"  );

                this.field_150034_b = p_149651_1_.registerIcon(this.getTextureName() + "_side3");

               

        }if(j1 <= 16){

        this.blockIcon = p_149651_1_.registerIcon(this.getTextureName() + "_side4"  );

                this.field_150034_b = p_149651_1_.registerIcon(this.getTextureName() + "_side4");

               

        }if(j1 <= 20){

        this.blockIcon = p_149651_1_.registerIcon(this.getTextureName() + "_side5"  );

                this.field_150034_b = p_149651_1_.registerIcon(this.getTextureName() + "_side5");

               

        }if(j1 <= 24){

        this.blockIcon = p_149651_1_.registerIcon(this.getTextureName() + "_side6"  );

                this.field_150034_b = p_149651_1_.registerIcon(this.getTextureName() + "_side6");

               

        }if(j1 <= 28){

        this.blockIcon = p_149651_1_.registerIcon(this.getTextureName() + "_side7"  );

                this.field_150034_b = p_149651_1_.registerIcon(this.getTextureName() + "_side7");

               

        }if(j1 <= 32){

        this.blockIcon = p_149651_1_.registerIcon(this.getTextureName() + "_side8"  );

                this.field_150034_b = p_149651_1_.registerIcon(this.getTextureName() + "_side8");

               

        }if(j1 <= 36){

        this.blockIcon = p_149651_1_.registerIcon(this.getTextureName() + "_side9"  );

                this.field_150034_b = p_149651_1_.registerIcon(this.getTextureName() + "_side9");

               

        }if(j1 <= 40){

        this.blockIcon = p_149651_1_.registerIcon(this.getTextureName() + "_side10"  );

                this.field_150034_b = p_149651_1_.registerIcon(this.getTextureName() + "_side10");

               

        }if(j1 <= 44){

        this.blockIcon = p_149651_1_.registerIcon(this.getTextureName() + "_side11"  );

                this.field_150034_b = p_149651_1_.registerIcon(this.getTextureName() + "_side11");

               

        }

    this.field_150035_a = p_149651_1_.registerIcon(this.getTextureName() + "_top");

       

    }

 

 

    @Override

public IIcon getIcon(int p_149691_1_, int p_149691_2_)

    {

        return p_149691_1_ == 1 ? this.field_150035_a : (p_149691_1_ == 0 ? this.field_150035_a : (p_149691_1_ != 2 && p_149691_1_ != 4 ? this.blockIcon : this.field_150034_b));

    }

 

 

 

    /*if(j1 <= 0){

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

            this.field_150034_b = p_149651_1_.registerIcon(this.getTextureName() + "_side");

           

    }if(j1 <= 4){

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

            this.field_150034_b = p_149651_1_.registerIcon(this.getTextureName() + "_side");

           

    }if(j1 <= 8){

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

            this.field_150034_b = p_149651_1_.registerIcon(this.getTextureName() + "_side");

           

    }if(j1 <= 12){

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

            this.field_150034_b = p_149651_1_.registerIcon(this.getTextureName() + "_side");

           

    }if(j1 <= 16){

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

            this.field_150034_b = p_149651_1_.registerIcon(this.getTextureName() + "_side");

           

    }if(j1 <= 20){

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

            this.field_150034_b = p_149651_1_.registerIcon(this.getTextureName() + "_side");

           

    }if(j1 <= 24){

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

            this.field_150034_b = p_149651_1_.registerIcon(this.getTextureName() + "_side");

           

    }if(j1 <= 28){

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

            this.field_150034_b = p_149651_1_.registerIcon(this.getTextureName() + "_side");

           

    }if(j1 <= 32){

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

            this.field_150034_b = p_149651_1_.registerIcon(this.getTextureName() + "_side");

           

    }if(j1 <= 36){

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

            this.field_150034_b = p_149651_1_.registerIcon(this.getTextureName() + "_side");

           

    }if(j1 <= 40){

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

            this.field_150034_b = p_149651_1_.registerIcon(this.getTextureName() + "_side");

           

    }if(j1 <= 44){

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

            this.field_150034_b = p_149651_1_.registerIcon(this.getTextureName() + "_side");

           

    }*/

 

   

 

 

}

 

Link to comment
Share on other sites

Please use spoiler and code tags or pastebin

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.

Link to comment
Share on other sites

 

Why, try quoting this post to see what I did

Or taking a trip over here.

 

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.

Link to comment
Share on other sites

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

 Share



×
×
  • Create New...

Important Information

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