Jump to content

Recommended Posts

Posted

Hello, i'm trying to make 16 slabs using metadata, they work fine up to the 8th, after that i get a problem on placement, when i click to place it on the ground it places the top slab and then if i try to complete it by putting another slab under it it won't work, but if i put it on the top of the upper slab it'll turn into a double slab. Also having problems with the dropped item, again, up to 8th metadata block it works just fine but then it goes back to the start (0-7 meta drops 0-7 meta 8-15 meta drops 0-7 meta).

 

Code:

Recipes, registry and etc:

 

  Reveal hidden contents

 

 

slab.java:

 

  Reveal hidden contents

 

 

slabItemBlock.java (since i'm using metadata i think i need to render the item for the inventory separately):

 

  Reveal hidden contents

 

Posted

      public int damageDropped(int metadata)
          {
         
          return metadata & 7;
         
          }

Try to remove this ... & 7 and return just metadata. I seriously can't see any reason to use bitwise AND here.

 

public void onBlockPlacedBy(World par1World, int x, int y, int z, EntityLiving par5EntityLiving){
         
        if (par1World.getBlockId(x, y - 1, z) == bExpansion.coloredStoneSlabID){
         
         int metadata = par1World.getBlockMetadata(x, y - 1, z);
         
         if(par1World.getBlockMetadata(x, y-1, z) == metadata){
         
          par1World.setBlockWithNotify(x, y, z, 0); //sets the block below to 0
          par1World.setBlockAndMetadataWithNotify(x, y - 1, z, bExpansion.coloredStoneDoubleSlabID, metadata);
         
           //makes the slab a double-slab of the same metadata type
                  }   
              }
       
       }

 

You are able to place stuff on top and it works properly because of this method. However you are checking if there is a halfslab below. Try checking above direction too, or try to mimic what Vanilla minecraft does.

Posted

Slabs use the 0x8 bit of metadata to store where the slab is upside down not.

  Quote
Slabs can be either "right-side-up" or "upside-down"; this information is stored in the most significant metadata bit 0x8 as follows:

  • 0: Slab is right-side-up, occupying the bottom half of its voxel.
  • 1: Slab is upside-down, occupying the top half of its voxel.

 

The &7 is used to return the type of slab (stone, brick, etc.) and &8 returns the up or down position.

If you remove the bitwise AND you can use the full 16 bits to have 16 different slabs but you won't be able to place them upside down as with vanilla slabs.

A bit of a work around using another 'upside-down' slab block class and some placement handling could solve that (ie. if face placed on is bottom face of block, place upside-down slab id. Upside down slabs would drop 'right-side-up' slab id.)

 

 

And instead of this.setLightOpacity(0);

You can use this.useNeighborBrightness[id] = true; to fix the slab and stairs lighting

Posted
  On 1/4/2013 at 10:40 PM, justJenkins said:

Slabs use the 0x8 bit of metadata to store where the slab is upside down not.

  Quote
Slabs can be either "right-side-up" or "upside-down"; this information is stored in the most significant metadata bit 0x8 as follows:

  • 0: Slab is right-side-up, occupying the bottom half of its voxel.
  • 1: Slab is upside-down, occupying the top half of its voxel.

 

The &7 is used to return the type of slab (stone, brick, etc.) and &8 returns the up or down position.

If you remove the bitwise AND you can use the full 16 bits to have 16 different slabs but you won't be able to place them upside down as with vanilla slabs.

A bit of a work around using another 'upside-down' slab block class and some placement handling could solve that (ie. if face placed on is bottom face of block, place upside-down slab id. Upside down slabs would drop 'right-side-up' slab id.)

 

 

And instead of this.setLightOpacity(0);

You can use this.useNeighborBrightness[id] = true; to fix the slab and stairs lighting

 

What if i do 2 classes with 8 slabs each, that would make they work fine right?

About your solution, if i had 2 slab classes i wouldn't be able to figure out if the player clicked on the up or down half of a normal block to place the slab, so the slabs would only work like vanilla if they were placed on the bottom face or the top face of the blocks, not on the sides, am I right?

 

I decided to split the 16 slabs in 2 classes, but i can't get the placement from top to bottom to work, any help?

Code:

public void onBlockPlacedBy(World theWorld, int x, int y, int z, EntityLiving par5EntityLiving){

		 int metadata = theWorld.getBlockMetadata(x, y, z);		 			
	  if (theWorld.getBlockId(x, y - 1, z) == bExpansion.coloredStoneSlabID2 && theWorld.getBlockMetadata(x, y - 1, z) == metadata){
		  
			  theWorld.setBlockWithNotify(x, y, z, 0); //sets the block below to 0

			  theWorld.setBlockAndMetadataWithNotify(x, y - 1, z, bExpansion.coloredStoneDoubleSlabID2, metadata & 7);
	    
	     //makes the slab a double-slab of the same metadata type
	   			
	  		} else {
	  			
	  				int metadata2 = theWorld.getBlockMetadata(x, y, z); 
	  
	  			if (theWorld.getBlockId(x, y + 1, z) == bExpansion.coloredStoneSlabID2 && theWorld.getBlockMetadata(x, y + 1, z) == metadata2){
	  				
	  				  theWorld.setBlockWithNotify(x,y, z, 0); //sets the block below to 0
	  				  theWorld.setBlockAndMetadataWithNotify(x, y + 1, z, bExpansion.coloredStoneDoubleSlabID2, metadata2 & 7);
	 		    
	 		     //makes the slab a double-slab of the same metadata type
	  				}
	  		}
	  
	 }

Edit: The code is actually working, but only if there's no block under it. Ideas?

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • UPDATE: this seems to be an Arch-specific issue. Switching to Ubuntu server fixed EVERYTHING.
    • Yes, Attapoll offers a $20 Sign-up bonus for new users using a code (AOVCQ). Enter the Attapoll Referral Code “AOVCQ” and submit. Yes, Attapoll offers $20 Referral Code {AOVCQ} For New Customers. If you are who wish to join Attapoll, then you should use this exclusive Attapoll referral code $20 Signup Bonus Use this Code (AOVCQ) and get $20 Welcome Bonus. You can get a $20 Signup bonus use this referral code {AOVCQ}. You can get a $20 Attpoll Referral Code {AOVCQ}. This Attapoll $20 Referral code is specifically for existing customers and can be redeemed to receive a $20. Enter $20 Attapoll Referral Code {AOVCQ} at checkout. Enjoy $20Welcome Bonus. Use the best Attapoll referral code $20 (AOVCQ) to get up to $20 first time survey as a new user. Complete the survey and get $20 credited on your Attapoll account. Plus, refer your friend to earn 10% commission on their earning If you're on the hunt for a little extra cash or some cool rewards without too much hassle, you've landed in the right place. Today, we're diving into the world of Attapoll referral codes, a nifty way to boost your earnings while taking surveys. Use this Attapoll Referral Link or code {{AOVCQ}} to get a $20 sign up bonus.
    • Yes, Attapoll offers a $20 Sign-up bonus for new users using a code (AOVCQ). Enter the Attapoll Referral Code “AOVCQ” and submit. Yes, Attapoll offers $20 Referral Code {AOVCQ} For New Customers. If you are who wish to join Attapoll, then you should use this exclusive Attapoll referral code $20 Signup Bonus Use this Code (AOVCQ) and get $20 Welcome Bonus. You can get a $20 Signup bonus use this referral code {AOVCQ}. You can get a $20 Attpoll Referral Code {AOVCQ}. This Attapoll $20 Referral code is specifically for existing customers and can be redeemed to receive a $20. Enter $20 Attapoll Referral Code {AOVCQ} at checkout. Enjoy $20Welcome Bonus. Use the best Attapoll referral code $20 (AOVCQ) to get up to $20 first time survey as a new user. Complete the survey and get $20 credited on your Attapoll account. Plus, refer your friend to earn 10% commission on their earning If you're on the hunt for a little extra cash or some cool rewards without too much hassle, you've landed in the right place. Today, we're diving into the world of Attapoll referral codes, a nifty way to boost your earnings while taking surveys. Use this Attapoll Referral Link or code {{AOVCQ}} to get a $20 sign up bonus.
    • Yes, Attapoll offers a $20 Sign-up bonus for new users using a code (AOVCQ). Enter the Attapoll Referral Code “AOVCQ” and submit. Yes, Attapoll offers $20 Referral Code {AOVCQ} For New Customers. If you are who wish to join Attapoll, then you should use this exclusive Attapoll referral code $20 Signup Bonus Use this Code (AOVCQ) and get $20 Welcome Bonus. You can get a $20 Signup bonus use this referral code {AOVCQ}. You can get a $20 Attpoll Referral Code {AOVCQ}. This Attapoll $20 Referral code is specifically for existing customers and can be redeemed to receive a $20. Enter $20 Attapoll Referral Code {AOVCQ} at checkout. Enjoy $20Welcome Bonus. Use the best Attapoll referral code $20 (AOVCQ) to get up to $20 first time survey as a new user. Complete the survey and get $20 credited on your Attapoll account. Plus, refer your friend to earn 10% commission on their earning If you're on the hunt for a little extra cash or some cool rewards without too much hassle, you've landed in the right place. Today, we're diving into the world of Attapoll referral codes, a nifty way to boost your earnings while taking surveys. Use this Attapoll Referral Link or code {{AOVCQ}} to get a $20 sign up bonus.
    • Yes, Attapoll offers a $20 Sign-up bonus for new users using a code (AOVCQ). Enter the Attapoll Referral Code “AOVCQ” and submit. Yes, Attapoll offers $20 Referral Code {AOVCQ} For New Customers. If you are who wish to join Attapoll, then you should use this exclusive Attapoll referral code $20 Signup Bonus Use this Code (AOVCQ) and get $20 Welcome Bonus. You can get a $20 Signup bonus use this referral code {AOVCQ}. You can get a $20 Attpoll Referral Code {AOVCQ}. This Attapoll $20 Referral code is specifically for existing customers and can be redeemed to receive a $20. Enter $20 Attapoll Referral Code {AOVCQ} at checkout. Enjoy $20Welcome Bonus. Use the best Attapoll referral code $20 (AOVCQ) to get up to $20 first time survey as a new user. Complete the survey and get $20 credited on your Attapoll account. Plus, refer your friend to earn 10% commission on their earning If you're on the hunt for a little extra cash or some cool rewards without too much hassle, you've landed in the right place. Today, we're diving into the world of Attapoll referral codes, a nifty way to boost your earnings while taking surveys. Use this Attapoll Referral Link or code {{AOVCQ}} to get a $20 sign up bonus.
  • Topics

×
×
  • Create New...

Important Information

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