Chicken-Bones / ForgeMultipart

An API for dynamically handling different functional parts in the one block space.
Other
119 stars 55 forks source link

How to make a mod inject its blocks as multipart compatible? #371

Closed ReikaKalseki closed 8 years ago

ReikaKalseki commented 8 years ago

How do I make my mods automatically whitelist their blocks for multipart (equivalent to putting them in the config)?

Chicken-Bones commented 8 years ago

The easiest way is via IMC key: "microMaterial" value: itemstack for block with damage 0-15

See codechicken.microblock.ConfigContent:121 for more details

If you want more control, codechicken.microblock.MicroMaterialRegistry.registerMaterial

ReikaKalseki commented 8 years ago

I do not understand scala, so the code does not really help me, but is this correct?

  FMLInterModComms.sendMessage("McMultipart", "microMaterial", ChromaBlocks.PYLONSTRUCT.getStackOfMetadata(0));
  FMLInterModComms.sendMessage("McMultipart", "microMaterial", ChromaBlocks.PYLONSTRUCT.getStackOfMetadata(1));
  FMLInterModComms.sendMessage("McMultipart", "microMaterial", ChromaBlocks.PYLONSTRUCT.getStackOfMetadata(2));
  FMLInterModComms.sendMessage("McMultipart", "microMaterial", ChromaBlocks.PYLONSTRUCT.getStackOfMetadata(7));
  FMLInterModComms.sendMessage("McMultipart", "microMaterial", ChromaBlocks.PYLONSTRUCT.getStackOfMetadata(8));
  FMLInterModComms.sendMessage("McMultipart", "microMaterial", ChromaBlocks.PYLONSTRUCT.getStackOfMetadata(10));
  FMLInterModComms.sendMessage("McMultipart", "microMaterial", ChromaBlocks.PYLONSTRUCT.getStackOfMetadata(11));
  FMLInterModComms.sendMessage("McMultipart", "microMaterial", ChromaBlocks.PYLONSTRUCT.getStackOfMetadata(12));

Also, how does it handle things like icon sides, light level, and/or isSideSolid?

amadornes commented 8 years ago

You have to send the message to "ForgeMicroblock" instead of "McMultipart". McMultipart is the one that allows vanilla blocks to be turned into multiparts, whereas ForgeMicroblock adds all the microblocks.

Icons are loaded from the original block into a "safe" version, which makes it so even if you change the icons in your block, they multipart won't get those changes. Note: they are loaded from getIcon(side, meta) instead of getIcon(world, x, y, z, side), so they aren't location-aware. For that you'd need a custom IMicroMaterial. Lighting is determined by the block's getLightValue() (with no arguments) and side solidity is determined by block.isOpaqueCube(). The same goes for hardness and resistance. Cutting level is determined by the harvest level of the block.

That's pretty much all you need to know unless you want to make your own IMicroMaterial :P

ReikaKalseki commented 8 years ago

All of that works for me except the light value (which would need at least a metadata), but that is not a high-priority issue. Thank you. :)

amadornes commented 8 years ago

Np :) Since CB isn't "officially" back, feel free to ask me any FMP-related questions, I'm pretty familiar with the code so I should be able to answer most of them. I'm planning on starting a video tutorial series on CCL/FMP in the next few weeks, so you'll be able to learn a bit more there ;)

ReikaKalseki commented 8 years ago

The only other question I had was regarding Wireless Redstone, so it is not really the topic of this thread. :P

Chicken-Bones commented 8 years ago

@amadornes is correct, thanks for the help. Unfortunately there are only 2 variants of most block property functions (icon, solidity, light value). One that takes no arguments and one that is location aware. I can't use the location aware one so I have to use the no-arg one and that isn't meta dependent. If you care you can always implement IMicroMaterial (or extend BlockMicroMaterial) for additional functionality.