Implementing banner
#5
Just an update, banners can now be placed but I only see them when reconnecting. I'm assuming I need to send an update to let the client know about the new banner. Looking at the other item handlers it must be something like this, but it doesn't work. Any pointers?

	virtual bool OnPlayerPlace(
		cWorld & a_World, cPlayer & a_Player, const cItem & a_EquippedItem,
		int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
		int a_CursorX, int a_CursorY, int a_CursorZ
	) override
	{
		// If the regular placement doesn't work, do no further processing:
		if (!super::OnPlayerPlace(a_World, a_Player, a_EquippedItem, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ))
		{
			return false;
		}

		AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace);
		
		// Use a callback to set the properties of the banner entity
		class cCallback : public cBlockEntityCallback
		{
			cPlayer & m_Player;
			NIBBLETYPE m_BlockMeta;

			virtual bool Item(cBlockEntity * a_BlockEntity)
			{
				if (!(a_BlockEntity->GetBlockType() == E_BLOCK_STANDING_BANNER || a_BlockEntity->GetBlockType() == E_BLOCK_WALL_BANNER))
				{
					return false;
				}
				auto BannerEntity = static_cast<cBannerEntity *>(a_BlockEntity);

				//TODO base color and patterns

				BannerEntity->GetWorld()->BroadcastBlockEntity(BannerEntity->GetPosX(), BannerEntity->GetPosY(), BannerEntity->GetPosZ());
				//m_Player.GetClientHandle()->SendUpdateBlockEntity(*a_BlockEntity);
				return false;
			}

		public:
			cCallback(cPlayer & a_CBPlayer, NIBBLETYPE a_BlockMeta) :
				m_Player(a_CBPlayer),
				m_BlockMeta(a_BlockMeta)
			{}
		};
		cCallback Callback(a_Player, static_cast<NIBBLETYPE>(a_BlockFace));
		a_World.DoWithBlockEntityAt(a_BlockX, a_BlockY, a_BlockZ, Callback);

		return true;
	}
Reply
Thanks given by: Jammet


Messages In This Thread
Implementing banner - by Seyaku - 05-21-2016, 06:53 AM
RE: Implementing banner - by xoft - 05-21-2016, 11:14 PM
RE: Implementing banner - by Seyaku - 05-22-2016, 01:04 AM
RE: Implementing banner - by Jammet - 05-22-2016, 01:07 AM
RE: Implementing banner - by Seyaku - 05-22-2016, 01:41 AM
RE: Implementing banner - by Jammet - 05-22-2016, 03:26 AM
RE: Implementing banner - by xoft - 05-22-2016, 06:41 AM
RE: Implementing banner - by Seyaku - 05-22-2016, 11:41 PM
RE: Implementing banner - by xoft - 05-23-2016, 01:02 AM
RE: Implementing banner - by Seyaku - 05-23-2016, 01:47 AM
RE: Implementing banner - by xoft - 05-23-2016, 02:04 AM
RE: Implementing banner - by Seyaku - 05-23-2016, 02:53 AM
RE: Implementing banner - by xoft - 05-23-2016, 05:22 AM
RE: Implementing banner - by Seyaku - 05-23-2016, 05:37 AM
RE: Implementing banner - by Seyaku - 05-24-2016, 02:23 AM
RE: Implementing banner - by xoft - 05-24-2016, 04:20 AM
RE: Implementing banner - by sphinxc0re - 05-24-2016, 05:01 AM
RE: Implementing banner - by Seyaku - 05-24-2016, 05:52 AM
RE: Implementing banner - by tigerw - 05-24-2016, 08:00 AM
RE: Implementing banner - by Seyaku - 05-24-2016, 09:29 AM
RE: Implementing banner - by xoft - 05-24-2016, 04:32 PM
RE: Implementing banner - by tigerw - 05-24-2016, 11:17 PM
RE: Implementing banner - by tigerw - 05-24-2016, 11:21 PM
RE: Implementing banner - by Seyaku - 05-25-2016, 12:30 AM
RE: Implementing banner - by tigerw - 05-25-2016, 01:52 AM
RE: Implementing banner - by Seyaku - 05-25-2016, 02:09 AM
RE: Implementing banner - by xoft - 05-25-2016, 02:30 AM
RE: Implementing banner - by tigerw - 05-25-2016, 05:06 AM
RE: Implementing banner - by Seyaku - 05-25-2016, 07:33 AM
RE: Implementing banner - by PureTryOut - 11-14-2016, 02:29 AM
RE: Implementing banner - by Seyaku - 12-02-2016, 09:44 AM
RE: Implementing banner - by PureTryOut - 12-05-2016, 03:37 AM
RE: Implementing banner - by xoft - 12-05-2016, 05:22 AM
RE: Implementing banner - by PureTryOut - 12-06-2016, 06:00 AM
RE: Implementing banner - by xoft - 12-06-2016, 05:51 PM
RE: Implementing banner - by Seyaku - 12-08-2016, 05:36 AM
RE: Implementing banner - by Seadragon91 - 03-23-2017, 09:16 PM



Users browsing this thread: 12 Guest(s)