It is currently April 26th, 2018, 5:58 am


All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Adding custom blocks
PostPosted: March 15th, 2012, 8:35 pm 

Joined: August 21st, 2011, 6:31 am
Posts: 280
Location: United Kingdom
Does anyone know the easiest way to add custom blocks?

For example, I'd like a custom block which will show as admincrete when placed, but no matter what I try I always get the "An item with the same key has already been added" exception.

Thanks!

_________________
You cannot use certain BBCodes: [img].


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Adding custom blocks
PostPosted: March 16th, 2012, 4:05 am 
fCraft Developer
User avatar

Joined: May 21st, 2011, 10:53 pm
Posts: 1386
There is no easy way. Some previous discussion


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Adding custom blocks
PostPosted: March 16th, 2012, 9:21 am 

Joined: August 21st, 2011, 6:31 am
Posts: 280
Location: United Kingdom
Ah ok, I didn't consider that. Thanks anyway :)

_________________
You cannot use certain BBCodes: [img].


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Adding custom blocks
PostPosted: March 16th, 2012, 5:46 pm 
fCraft Developer
User avatar

Joined: May 21st, 2011, 10:53 pm
Posts: 1386
You can do it, if you don't care about degrading performance somewhat. E.g. MCSharp forks all copy and convert the entire map before sending, and they're still usable.

Also the specific "An item with the same key has already been added" exception is probably from Map's static constructor, that creates a list of block name aliases. Make sure that your block does not have the same ID as any other block (which is possible with enums), and that there is no overlap between alias names and block names.

Also - if you're going to do physics the MCSharp/MCZall/MCLawl way, be prepared for looooong ugly switch() chains. :P


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Adding custom blocks
PostPosted: March 16th, 2012, 6:52 pm 

Joined: August 21st, 2011, 6:31 am
Posts: 280
Location: United Kingdom
Thanks for the help, I'll probably just stick to using collections. Wow that's some ugly stuff! I've pretty much done physics, I wanted a custom block for water / lava physics so it'll be easy to unflood the physics without having to use a < 17 million block collection to identify what is water damage and what was already on the map.

Yesterday I thought about adding redstone and having a custom block for that, then I realized that there's nothing for redstone to interact with :/ haha

_________________
You cannot use certain BBCodes: [img].


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Adding custom blocks
PostPosted: March 16th, 2012, 8:53 pm 
fCraft Developer
User avatar

Joined: May 21st, 2011, 10:53 pm
Posts: 1386
Take a look how I did physics in FemtoCraft, I tried making it as efficient as I could.


Top
Offline Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Theme created StylerBB.net