Simulate parameter for IPartConverter and IReversePartConverter
rubensworks opened this issue ยท 4 comments
I suggest adding a simulate parameter to the convert() methods in IPartConverter and IReversePartConverter.
The IPartConverter for example is always called twice, once in the context of MultipartHelper#canAddPart() and once in MultipartHelper#addPart().
I need this for a converter that can drop items is some special cases, and I don't want these items to drop twice.
An alternative would be to add a method canConvert() to the converter interfaces instead.
This can be handled in IMultipart#onConverted(), which is only called when the conversion is actually performed, although it's only for IPartConverter. For IReversePartConverter it's not required, since you only return true when you actually convert the parts into a block and it's not called any more times.
If you have any other requests related to this, feel free to open the issue again :)
Thanks, I wasn't aware of that method, but I'm afraid that this still doesn't solve my problem :s
The problem is that my original block can drop certain items when its broken/removed, but I don't want these items to drop when converting to an McMultiPart block.
Even though I can use the IMultipart#onConverted() method, at the time it is called, the original block is already removed (https://github.com/amadornes/MCMultiPart/blob/master/src/main/java/mcmultipart/multipart/MultipartHelper.java#L111) , and the items will thus already have been dropped before I could block that.
I could tell the tileentity to not drop the items when the converter is being called (as can be seen here: https://github.com/CyclopsMC/IntegratedDynamics/blob/feature-mcmultipart-rework/src/main/java/org/cyclops/integrateddynamics/modcompat/mcmultipart/BlockCableConverter.java#L44), but the problem is that this should only happen when the conversion is actually going to happen, not when it is checking if it can convert.
Otherwise this could cause failed conversions to incorrectly tell the tile to not drop items anymore.
So I would still require some way to know if it is doing a preliminary conversion check or the actual conversion.
Ah, this is doable, yes! I'll look into it in a bit so you can have it in 1.0.4 :)