Jump to content

Block acting strange with large metadata


vtsman

Recommended Posts

I have a block that usually has a metadata of over 10000000, and It doesn't seem to register a metadata that high. can anyone help. here's my block code:

 

package vtsman.mine_modus.block;

 

import java.util.List;

 

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

 

import vtsman.mine_modus.tileentity.nodetype;

import net.minecraft.block.Block;

import net.minecraft.block.BlockContainer;

import net.minecraft.block.ITileEntityProvider;

import net.minecraft.block.material.Material;

import net.minecraft.creativetab.CreativeTabs;

import net.minecraft.item.ItemStack;

import net.minecraft.tileentity.TileEntity;

import net.minecraft.world.IBlockAccess;

import net.minecraft.world.World;

 

 

public class node extends Block{

private  String[] types = {"Energy", "Item", "Liquid", "Energy", "Item", "Energy"};

private  int[] radius = {5, 10, 10, 20, 20, 20};

private  int[] capacity = {100, 64, 400, 1000, 1024, 10000};

private  int[] color = {0xA3CADE, 0xCC2900, 0xEDCC47, 0x66CCFF, 0xE62E00, 0x000000};

private nodetype type = null;

vtsman.mine_modus.tileentity.node tile;

public node(int par1, Material par2Material) {

super(par1, par2Material);

// TODO Auto-generated constructor stub

public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List)

    {

par3List.add(new ItemStack(this.blockID, 1, 11000100));

par3List.add(new ItemStack(this.blockID, 1, 12010000));

par3List.add(new ItemStack(this.blockID, 1, 21000064));

par3List.add(new ItemStack(this.blockID, 1, 31000400));

    }

@Override

public boolean renderAsNormalBlock()

{

return false;

}

 

    @SideOnly(Side.CLIENT)

    public int getBlockColor()

    {

   

        return Integer.parseInt(Integer.toString(type.getColor()), 16);

    }

   

@Override

public boolean isOpaqueCube()

{

return false;

}

@Override

public int getRenderType()

{

return -1;

}

@Override

  public boolean hasTileEntity(int metadata)

    {

        return true;

    }

public nodetype getType(int meta){

return new nodetype("Energy", getRange(meta), getCapacity(meta), 0x000000, getRenderRadius(getCapacity(meta), getStringType(meta)));

}

public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6)

    {

System.out.println("hello");

            par1World.removeBlockTileEntity(par2, par3, par4);

    }

/*public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int i, int j, int k)

    {

float min = (float)this.getType(par1IBlockAccess.getBlockMetadata(i, j, k)).getRadius() * -1 + 0.5f;

    float max =(float)this.getType(par1IBlockAccess.getBlockMetadata(i, j, k)).getRadius() + 0.5f;

    this.minX = min;

    this.maxX = max;

    this.minY = min;

    this.maxY = max;

    this.minZ = min;

    this.maxZ = max;

    }*/

    public TileEntity createTileEntity(int meta)

    {

    this.tile = new vtsman.mine_modus.tileentity.node(this.getType(meta));

        return tile;

    }

    private double getRenderRadius(int n, String type){

    if(type == "Item") return (Math.pow(n/64, 1.0/3.0)) * .4;

 

    if(type == "Liquid") return (Math.pow(n/400, 1.0/3.0)) * .4;

   

    if(type == "Energy") return (Math.pow(n/100, 1.0/3.0)) * .2;

    return 0;

    }

    private String getStringType(int meta){

    int x = (meta - meta % 10000000)/10000000;

    if(x == 1){

    return("Energy");

    }

    if(x == 2){

    return("Item");

    }

    if(x == 3){

    return("Liquid");

    }

    return null;

    }

    private int getRange(int meta){

    return ((meta - (meta % 10000))/100000)%100;

    }

    private int getCapacity(int meta){

    return meta % 100000;

    }

}

 

 

 

The block is also an itemBlock

 

Link to comment
Share on other sites

I believe that the meta data range is 0 to 17. So yeah... That could be why :P

I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes.

 

I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there xD

Link to comment
Share on other sites

I believe that the meta data range is 0 to 17. So yeah... That could be why :P

 

0-15 :|

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

Just so you're aware:

 

Blocks in-world aren't item stacks.

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

Wait a sec. What did you planed what that block does do?

 

I mean maybe you even need no metadata.

 

There is a way to make metadata without making it. I mean like buildcraft pipes.

Or my pipes (my mod is hidden).

 

Buildcraft made it like that:

 

When you place the block. The item (pipe) give the block(pipe) his information

and where he has to look and to get it.

 

I made it like that:

i made a new LiquidPipe which is working (at the moment a little bit buggy because the code is 5 hours old). I made a view functions which alow me to change it.

 

When i rightclick the item a basic pipe will be place (and the block loads his TE).

After that (in the same click) the item looks does block is there, does it have a tile, and if that is right is it a pipe? When all this things are true than he looks in the infos of the tile and change a view numbers. Then the click is finish.

 

With that system you safe meta (you can make infinte sub meta with that (submeta is a meta of the meta)). But do not overload it.

Because when you make it so complex like eloraam (her mod is awsome but laggy(the covers are to much)) you will create alot of lag. Its ok you can make a big submeta when it changes only 1-2 numbers but when it change rotation, rendering and everything complicatet stuff you should be becarefull.

Everything has his price.

 

I hope it helps. and i know i wrote to much but thats me xD.

 

Speiger

Link to comment
Share on other sites

I mean like buildcraft pipes.

 

It's called a Tile Entity.

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



×
×
  • Create New...

Important Information

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