Jump to content

[1.8] Placeable block on specify block


BaXMultigaming

Recommended Posts

Hey,

 

I made a mod with 2 custom simple blocks, but i was thinking how can i make that for example Block numer 2 can only be placed on Block numer 1 and on no other block. I am also interested how can i make a chat message for the block breaker for example when player break a Block number 2 it will show a message on the chat only for the breaker 'Hey its me' :D ??

 

Sorry for my English.

BaX

Link to comment
Share on other sites

I made a mod with 2 custom simple blocks, but i was thinking how can i make that for example Block numer 2 can only be placed on Block numer 1 and on no other block.

 

This will work if the position indeed needs to be corrected with an offset, otherwise remove that part.

 

@Override  // In Block 2
public boolean canPlaceBlockAt(World worldIn, BlockPos pos) 
{
     // Block block1 = new Block1();
     if (worldIn.getBlockState(pos.offset(EnumFacing.DOWN)).getBlock().equals(block1))
     {
          return true;
     }
     else return false;
}

I still haven't published a mod because I can never get that in-dev version just right to warrant a public release. And yes, after two years of mod development I am still learning to speak Java.

 

Follow me on GitHub: https://github.com/yooksi

Contact me on Twitter: https://twitter.com/yooksi

Read my Minecraft blog: https://yooksidoesminecraft.blogspot.de/

Link to comment
Share on other sites

A method like that does not exist in Block, however you can take a look at ItemStack#canPlaceOn. I've never used it so I am unsure about what exactly does it do but I believe it's worth to take a look.

I still haven't published a mod because I can never get that in-dev version just right to warrant a public release. And yes, after two years of mod development I am still learning to speak Java.

 

Follow me on GitHub: https://github.com/yooksi

Contact me on Twitter: https://twitter.com/yooksi

Read my Minecraft blog: https://yooksidoesminecraft.blogspot.de/

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.