Cuberite Forum
[SOLVED] How does one create a block break particle effect? - Printable Version

+- Cuberite Forum (https://forum.cuberite.org)
+-- Forum: Plugins (https://forum.cuberite.org/forum-1.html)
+--- Forum: Plugin Discussion (https://forum.cuberite.org/forum-8.html)
+--- Thread: [SOLVED] How does one create a block break particle effect? (/thread-1905.html)



[SOLVED] How does one create a block break particle effect? - NathanFlurry - 05-04-2015

Hello,

I'm attempting to make a block break particle effect occur, but I've had no success. Among a couple alterations, I've attempted to do it with this code:

Code:
world:BroadcastParticleEffect("blockdust_152_0", position.x, position.y + Receiver:GetHeight() / 2, position.z, particleRange, particleRange, particleRange, 0.3, 30)

However, the client only shows the default particle effect, meaning it doesn't work.

Can somebody help me out with this?

Thanks,
Nathan


RE: How does one create a block break particle effect? - NiLSPACE - 05-04-2015

I can't give you a big answer, because it's hard to type on my mobile, but here is an example:
World:BroadcastSoundParticleEffect(2001, a_BlockX, a_BlockY, a_BlockZ, BLOCKTYPE)

I believe it's done like this.


RE: How does one create a block break particle effect? - NathanFlurry - 05-04-2015

(05-04-2015, 08:38 AM)NiLSPACE Wrote: I can't give you a big answer, because it's hard to type on my mobile, but here is an example:
World:BroadcastSoundParticleEffect(2001, a_BlockX, a_BlockY, a_BlockZ, BLOCKTYPE)

I believe it's done like this.

Thanks, that works fine. However, I'd still like to know how one would do this without playing a sound.

Thanks,
Nathan


RE: [SOLVED] How does one create a block break particle effect? - NiLSPACE - 05-04-2015

I don't think that's possible. Not because of MCServer, but because vanilla doesn't support it either.


RE: [SOLVED] How does one create a block break particle effect? - DiamondToaster - 05-05-2015

I think it might be possible. I think that the cWorld:BroadcastParticleEffect() function needs to be changed to put in block ID for the effect "blockdust" I can do this:

function OnPlayerRightClick(Player, BlockX, BlockY, BlockZ, BlockFace, CursorX, CursorY, CursorZ)
	if BlockFace == BLOCK_FACE_NONE then
		return false
	end
	local vec = Player:GetPosition() + Player:GetLookVector()
	Player:GetWorld():BroadcastParticleEffect("blockdust", vec.x, vec.y, vec.z, 0, 0, 0, 0, 1)
	return false
end

...but I run into protocol errors where the client gets kicked. The client spits out:
java.lang.IndexOutOfBoundsException: readerIndex(38) + length(1) exceeds writerIndex(38)

So it could probably be done without sound. I'm not a protocol expert though, so what I'm spouting out could be crap. Tongue


RE: [SOLVED] How does one create a block break particle effect? - xoft - 05-05-2015

It seems that the protocol got extended in this packet ( http://wiki.vg/Protocol#Particle ) and we didn't notice / implement the change. It shouldn't be too difficult to implement, but the decision about how to interface the API is somewhat difficult - how do you represent something that has a variable number of parameters, in a future-proof manner? What if the protocol adds a new particle with 3 params in the next version? Etc. And you need to decide both C++ and Lua side of things.


RE: [SOLVED] How does one create a block break particle effect? - NiLSPACE - 05-05-2015

We could make the function take a variable number of arguments?


RE: [SOLVED] How does one create a block break particle effect? - worktycho - 05-05-2015

On the lua side the interface seems obvious, just use varargs. On the c++ side it looks more complicated, and I'd be in favour of completely refactoring of how particle effects are broadcast. I'd personally like to move the logic out of cWorld/cChunkMap/cChunk to simplify things a little.


RE: [SOLVED] How does one create a block break particle effect? - worktycho - 05-07-2015

I'm implementing this now. I've gone for an overload that takes a two element array for c++, which won't be used for one element, and varargs for lua. The lua API is extendable to longer data arrays and the c++ API works for now and can be easily extended. I had to add manual bindings for another refactor I'm doing so separate lua/c++ interfaces is not a issue. Whats more of an issue is what do you do if a plugin specifies data and the protocol doesn't support the additional data field. At the moment I'm ignoring it, but I'm not sure if that is the best answer.