Jump to content

Metadata Questions [1.7.10]


TheEpicTekkit

Recommended Posts

Hello all.

 

Okay, so I have a few questions on metadata, and couldn't find anything useful on Google.

 

1) I'm mostly sure about this, but is there only 16 possible metadata sub blocks? or can I make more than 16 blocks with the same id?

 

2) If I were to make several machines for my mod (I'm thinking about 10 - 12 machines) I would have 8 metadata types for each, 1 - 4 for the rotation directions with the machine off, and 5 - 8 for the rotation directions with the machine on. I would like to be able to make all these machines under the same block class, and have all of them with the same id (because there is still only 4096 block ids available) So how would I go about doing this?

 

Thanks.

I ask complicated questions, and apparently like to write really long detailed posts. But I also help others when I can.

Link to comment
Share on other sites

Okay, thanks.

 

one question, what does the <...> do? I know that it is called a generic (I think) but even after some research, I still dont understand, I found things saying that they help debug, and stop compilement errors, but im not so sure.

I ask complicated questions, and apparently like to write really long detailed posts. But I also help others when I can.

Link to comment
Share on other sites

Oh... okay.

 

Right, so I have been working on the rotation of the block, and I have done this before, with things like a custom furnace, but because before I was using 2 separate blocks, I could just use the same numbers as the vanilla furnace, but now that I am storing the on/off state in metadata (because as I was told before by diesieben07, I shouldn't do that because of limited block numbers), it is getting a bit more complex. So this is basically how I want to do it:

 

there are 4 rotation values for the off state, and 4 for the on state, so 0, 2, 4, and 6 are the rotation values when it is off, and when it is on, I would like to add one to those values (I will get to why I have used even intervals in a minute) so the on rotation values are 1, 3, 5, and 7.

 

Now I can easily use this to determine if the machine is on or off using modulo to find if it is even of odd (even being off, and odd being on.

                if (meta % 2 == 0) { //metadata is even (machine is off)
		this.isOn = false;
	} else { //metadata is odd (machine is on)
		this.isOn = true;
	}

 

Now how do I set the rotation of the block from the metadata from the onBlockPlacedBy method? the vanilla furnace uses really confusing metadata values "2, 5, 3 and 4" (in that order) now I dont understand what these numbers mean, and why they aren't 0, 1, 2, and 3. Before I have just coppied this method into my block, and it worked fine, but as I said, before I was using 2 blocks for on/off state.

 

So I want to be able to set a custom direction for the metadata, so how do I make it so when my metadata is 0, or 1, the machine faces north, 2, or 3, the machine faces east, 4, or 5, the machine faces south, and finally 6, or 7, the machine faces west? From here, I can get which direction the player is facing, and make the machine face the opposite direction.

I ask complicated questions, and apparently like to write really long detailed posts. But I also help others when I can.

Link to comment
Share on other sites

Okay, so i put isOn in the tileentity, and set it there, but reference it in the block from the onBlockPlacedBy... right?

 

and is that a method you made? and where would I put it? in the tileentity again?

 

This block rotation stuff is very much different from how I did it in 1.6, and a lot more complicated...

I ask complicated questions, and apparently like to write really long detailed posts. But I also help others when I can.

Link to comment
Share on other sites

That didn't really help...

 

now I am confused... I really really don't want to use 2 blocks for on/off state, and that is what I used to do, but I want to learn to do it the proper way, using metadata.

 

Can we go back a few steps to my reply about the vanilla furnace, why do they use the values 2, 5, 3 and 4, in that order? what do they mean, and how and where in the code does that define the rotation? because in the furnace block class, they are just metadata values, how does this rotate it, there isn't anything in the tileentity, or anywhere else to define that.

 

This is the code I am talking about:

        public void onBlockPlacedBy(World p_149689_1_, int p_149689_2_, int p_149689_3_, int p_149689_4_, EntityLivingBase p_149689_5_, ItemStack p_149689_6_)
    {
        int l = MathHelper.floor_double((double)(p_149689_5_.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;

        if (l == 0)
        {
            p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, 2, 2);
        }

        if (l == 1)
        {
            p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, 5, 2);
        }

        if (l == 2)
        {
            p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, 3, 2);
        }

        if (l == 3)
        {
            p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, 4, 2);
        }

        if (p_149689_6_.hasDisplayName())
        {
            ((TileEntityFurnace)p_149689_1_.getTileEntity(p_149689_2_, p_149689_3_, p_149689_4_)).func_145951_a(p_149689_6_.getDisplayName());
        }
    }

I am talking about the setBlockMetadataWithNotify(...) the 4th variable is the metadata, and the 5th is the flag.

 

Sorry if I am annoying you with me not understanding, I feel like I am starting to be annoying, but I really wanna learn this, so I dont keep asking for help.

I ask complicated questions, and apparently like to write really long detailed posts. But I also help others when I can.

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.

Announcements



×
×
  • Create New...

Important Information

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