Page 1 of 1
Adding custom blocks
Posted: March 15th, 2012, 8:35 pm
by Jonty800
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!
Re: Adding custom blocks
Posted: March 16th, 2012, 4:05 am
by fragmer
Re: Adding custom blocks
Posted: March 16th, 2012, 9:21 am
by Jonty800
Ah ok, I didn't consider that. Thanks anyway
Re: Adding custom blocks
Posted: March 16th, 2012, 5:46 pm
by fragmer
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.
Re: Adding custom blocks
Posted: March 16th, 2012, 6:52 pm
by Jonty800
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
Re: Adding custom blocks
Posted: March 16th, 2012, 8:53 pm
by fragmer
Take a look how I did physics in
FemtoCraft, I tried making it as efficient as I could.