Cuberite Forum
Enchanting - Printable Version

+- Cuberite Forum (https://forum.cuberite.org)
+-- Forum: Cuberite (https://forum.cuberite.org/forum-4.html)
+--- Forum: Development (https://forum.cuberite.org/forum-13.html)
+--- Thread: Enchanting (/thread-1321.html)

Pages: 1 2 3 4 5 6 7 8 9 10 11


Enchanting - daniel0916 - 01-19-2014

I'm currently working on enchanting for mcserver.

Working:
- opening window
- drop item in the slot 0 when the player close the window


Current Question: How can i send the three enchanting fields to the player?


RE: Enchanting - NiLSPACE - 01-19-2014

Thugie is also working on this.

It seems you have to use the cWindow:SetPropertie function.

Btw here is documentation for the protocol of you need it: http://wiki.vg/Protocol#Window_Property


RE: Enchanting - daniel0916 - 01-19-2014

(01-19-2014, 09:17 PM)STR_Warrior Wrote: Thugie is also working on this.
Ah yes i see now his thread.

(01-19-2014, 09:17 PM)STR_Warrior Wrote: It seems you have to use the cWindow:SetPropertie function.
Thanks.

SetProperty is working. Now the enchantments are available.

Now i must get if a item in the slot. I tried:
Code:
if (this->m_ParentWindow.GetSlot(a_Player, 0)->m_ItemType == -1)
But with this the slot is always empty.

Now I'm checking for items who can be enchanted.

Sometimes this isn't working:
Code:
if (this->m_ParentWindow.GetSlot(a_Player, 0)->m_ItemType == 268)
This check for a wooden sword. But sometimes it is the itemtype -1 and not 268..
Give it a other method for the checking?


RE: Enchanting - tonibm19 - 01-20-2014

itemtype -1 means there is no item there, it's empty.

Also, you should use E_ITEM_WOODEN_SWORD instead of 268


RE: Enchanting - xoft - 01-20-2014

Instead of checking if m_ItemType is -1, you should use the IsEmpty() function. An empty item may be also one that has a valid m_ItemType, but the m_ItemCount is zero.


RE: Enchanting - daniel0916 - 01-20-2014

Okay, but when i click on the item in the console it comes the message that the item is a wooden sword but when i do the item in the enchant slot it is -1. But when i click on the item then it is a wooden sword. Have someone a idea why?

How can i get the item which is currently in the enchantment table?


RE: Enchanting - tonibm19 - 01-20-2014

There is a GetSlot() function.


RE: Enchanting - daniel0916 - 01-20-2014

(01-20-2014, 03:05 AM)tonibm19 Wrote: There is a GetSlot() function.

I use this. But often when i put a sword into the enchantment table it returns -1 and not the item..
Code:
this->m_ParentWindow.GetSlot(a_Player, 0)->m_ItemType

2. Question:
How can i delete the property? because when you put the item out the enchantments should be away.

I tried:
Code:
this->m_ParentWindow.SetProperty(0, NULL);
        this->m_ParentWindow.SetProperty(1, NULL);
        this->m_ParentWindow.SetProperty(2, NULL);



RE: Enchanting - daniel0916 - 01-20-2014

Enchanting Packet is also added to the 1.7 Protocol.


RE: Enchanting - tonibm19 - 01-20-2014

try
this->m_ParentWindow.SetProperty(0, nil);
this->m_ParentWindow.SetProperty(1, nil);
this->m_ParentWindow.SetProperty(2, nil);