Closed t2pellet closed 6 years ago
Unless you want to make stuff like covers, you should probably be extending Multipart. Also implement INormallyOccludingPart and/or ISlottedPart if you don't want to be able to place 10000 of the same part in the same block :P (look in mcmultipart.multipart for more interfaces to implement)
On a side note why are you not using MCMP 2.0.0? It does have some problems but only for special cases I doubt you will be running into. And it's the FUTURE. Here's a guide for MCMP 2
So microblock is to make miniature versions of full size blocks i already have? I'm not using MCMP 2.0.0 since I'm developing in 1.10.2 Edit: Also, do I create a blockstate for a multipart? There's no unlocalized or registry names for them, so does it use the resourcelocation i return in getmodelpath? or gettype? Edit also what if I want my parts to be able to overlap? I just don't implement ISlottedPart, right?
How is this for placing a multipart? https://pastebin.com/LYp14ynR
This is my code for the multipart itself: https://pastebin.com/BgqtF4su
And for registering it: https://pastebin.com/TataA1pt
Edit: I know there's something wrong in what I'm doing, since the command doesn't work, with the error leading to line 99 of MultipartHelper, which is this:
part.setContainer(container);
The command doesn't work since there most likely isn't a multipart already there where MultipartHelper.addPart looks. You also don't seem to be registering the multipart at all. Look at this: https://github.com/MRebhan/RetroComputers/blob/1.10/src/main/java/com/github/mrebhan/retrocomputers/RPCRegistry.java#L92
You need to register the part (first line in the function), you need to register the item (you probably don't need to override the methods in ItemMultiPart that I do, just do new ItemMultiPart();
and look at registerItem (the function right above registerMultipart) for what you need to do to register the item.
But make sure you replace my mod specific strings/stuff with yours
Why do you need a command at all? If you want to know how to place multiparts with a command, look at how ItemMultiPart does it...
Also, if you're making a new mod and don't depend on anything that is 1.10 exclusive, please don't make new mods for 1.10 since, well, there's 1.11
The command is temporary. They'll be placed by an item. Is it absolutely necessary to register an item? What if I don't want/need one (that's the case for what I want to do).
EDIT: Ok, so it works now. The command and itemMultiPart i created both place it, with the two model definitions i've created working (for EnumFacing.UP and DOWN) However, for the EnumFacing.UP variant, it places it at the top of the block, rather than the bottom, even though a conventional block with the exact same model json places fine. Both also share the exact same AABB render box. Also, the selection boxes dont seem to work either, and I can only place one part per block. Oh, and I've synced this to PencilMod on my github: http://github.com/daPoseidonGuy/PencilMod
See, this right here is why I don't really want people to add support for MCMP1 and instead either not support it, or move to 1.11.2 and MCMP2. Don't worry, you're not the only one who's done this, but yeah....
You're treating multiparts like blocks... but not quite? I've seen other people create a single instance and try to use that all the time. It sort of makes sense if you've made blocks before, but it's not how multiparts work. You're creating multiple instances, though... which really confuses me... The way you should think of multiparts in MCMP1 is essentially TileEntities, but with Block's methods inside them.
The factory is there and has that name for a reason. It creates NEW instances of IMultipart, as specified in the javadocs. The system is NOT designed to work with the same instance of a multipart all over the code, so every time you need a multipart, make a new instance. This is what you need to do in the createPart()
method in the item as well.
Another thing I don't quite understand is why in your multipart you're overriding the multipart container getter and setter, and even creating your own TileMultipartContainer. The point of MCMP is to manage all that for you. The multipart container is the object that holds all the multiparts in the same block, so it makes no sense to have the same one for all parts (remember your part is static in your code). MCMP will create a new one and add your part to it when you add your part to the world using MultipartHelper.
People tend to think of MCMP as this extremely complicated thing, but really, if you just want a basic multipart, create an IPartFactory that makes new instances of your part and register it (or register the part's class instead and have an empty constructor in it if you don't want a factory), create a Multipart that returns a "registry name" in getType()
and register an ItemMultiPart or some other thing to place it in the world and you're done :P
I'd personally just move to 1.11.2 or not support MCMP in 1.10. MCMP2's API essentially lets you say "hey, this block is a multipart, do the thing and it uses this item to place it" and that's it. You don't have to do anything else. I've been discouraging the use of MCMP1 ever since I started working on MCMP2 because of all the improvements in the API's usability. Not that it was bad, by any means, because C&B, RS, Mekanism and many other mods used it, but MCMP2's API is far superior in terms of just making things work.
I won't really be around for the next 8 or 9 days because I'm studying for some pre-university-application-thingy exams. Not sure how they're called. But I'll try to have a look in here at least every other day and see what I can help with :)
Closing because this is an MCMP1 issue which has been outdated for a while. (And you probably have solved your problems by now)
Hey, I'm new to java and modding and stuff, and I've been having trouble using your mod to create my own microblock. I was just wondering if you could point me in the right direction to get started. If i want to create a block that can share space with another block (and possibly overlap), should I be extending Multipart or Microblock? I'm just a bit confused as to where to start, any help would be greatly appreciated. Thanks.