Adding custom blocks

For all mod-related questions and custom code.
Post Reply
Jonty800
Offline
Posts: 280
Joined: August 21st, 2011, 6:31 am
Location: United Kingdom
Contact:

Adding custom blocks

Post 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!
You cannot use certain BBCodes: [img].

User avatar
fragmer
fCraft Developer
Offline
Posts: 1386
Joined: May 21st, 2011, 10:53 pm

Re: Adding custom blocks

Post by fragmer »

There is no easy way. Some previous discussion

Jonty800
Offline
Posts: 280
Joined: August 21st, 2011, 6:31 am
Location: United Kingdom
Contact:

Re: Adding custom blocks

Post by Jonty800 »

Ah ok, I didn't consider that. Thanks anyway :)
You cannot use certain BBCodes: [img].

User avatar
fragmer
fCraft Developer
Offline
Posts: 1386
Joined: May 21st, 2011, 10:53 pm

Re: Adding custom blocks

Post 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. :P

Jonty800
Offline
Posts: 280
Joined: August 21st, 2011, 6:31 am
Location: United Kingdom
Contact:

Re: Adding custom blocks

Post 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
You cannot use certain BBCodes: [img].

User avatar
fragmer
fCraft Developer
Offline
Posts: 1386
Joined: May 21st, 2011, 10:53 pm

Re: Adding custom blocks

Post by fragmer »

Take a look how I did physics in FemtoCraft, I tried making it as efficient as I could.

Post Reply