Creative Mode - 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: Creative Mode (/thread-193.html) |
Creative Mode - rs2k - 10-27-2011 I got creative mode mostly working now. You load into the server in creative, but can still take fall damage, and if you die you respawn in normal mode. Breaking blocks doesn't work yet, but you can place any block from your unlimited inventory without crashing now. I was surprised at how easy it was to add a new packet. I'm sure I probably did something wrong, at least it works though. hehe I'm guessing blocks don't break because it either sends a different packet for block breaks, or the server is waiting for a block dig start packet? I haven't looked yet. I'll upload the files shortly and post the link here. http://code.google.com/p/mc-server/source/detail?r=15 >.> and I changed the port again. RE: Creative Mode - rs2k - 10-27-2011 Creative mode client only sends Started digging. I want the server to support both per client and per server creative mode. For now I think I'll make it so the server is either in or out of creative mode. Creative mode now breaks blocks without providing block drops. I need to work with the player's inventory to get the placement of blocks and current inventory to work with creative mode though. I am also declaring and assigning a value to the constant Int GAMEMODE in two separate areas. That should be changed to a single location. It seems like changing the respawn packet fixed dying in gamemode 1, but you can still take damage. Uploading new files shortly. R16 is here: http://code.google.com/p/mc-server/source/detail?r=16&path=/trunk/ RE: Creative Mode - rs2k - 10-27-2011 Now up to r17. http://code.google.com/p/mc-server/source/detail?r=17 More changes for creative mode. Players can't take damage, but still sometimes spawn dead. Falling through the void doesn't kill you. RE: Creative Mode - FakeTruth - 10-27-2011 You have a giant bug in the cPacket_CreateInventoryAction packet. Code: static const unsigned int c_Size = 1 + 4 + 2 + 2 + 2; I'm still looking at the other changes you made --------- Code: short m_Short; -------- Code: if( m_ItemID <= 0 ) m_ItemID = -1; // Fix, to make sure no invalid values are sent. -------- You made some unnecessary changes to cPlugin.h, cInventory.h and Bindings.cpp. cPlugin.h and cInventory.h both have some classes Forward declared, you only have to do that when you actually use the classes (in this case you're not using cPacket_CreateInventoryAction in those files) Bindings.cpp is automagically generated by "trunk/source/AllToLua.bat", it's a windows executable that reads several *.h files and creates Lua bindings. -------- You added Code: static const int GAMEMODE = 1; //0 = Survival, 1 = Creative; For example: Code: // Create Respawn player packet -------- Since players might want to switch to creative/survival mode on the fly, GAMEMODE should not be a constant value in cClientHandle, just make it a regular int m_GameMode (in cClientHandle OR cPlayer) and initialize it to the current cWorld value (see above) then when a player decides to change game mode, just switch the integer to 0 or 1 (I see you moved it to one spot, but above still applies, and it should actually be in 2 places) RE: Creative Mode - rs2k - 10-27-2011 Thanks, I'll get those errors fixed. I knew I was going to get some things wrong. I completely forgot about changing the c_Size The reason I put m_Short instead of m_Damage was because in cPacket_EntityEquipment I notice it used m_Short instead od m_Damage. I just followed suit instead of trying m_Damage. RE: Creative Mode - FakeTruth - 10-27-2011 These are just some pointers, don't take it too hard I thought you said you're new to C++ so I'm sure there's so much stuff going on you don't even know what's happening. I suspect that I created cPacket_EntityEquipment before the documentation was complete, and nobody had any idea what it did, so I just named it m_Short ^^ RE: Creative Mode - rs2k - 10-27-2011 (10-27-2011, 05:53 AM)FakeTruth Wrote: These are just some pointers, don't take it too hard I thought you said you're new to C++ so I'm sure there's so much stuff going on you don't even know what's happening. Yes, I'm new to C++ and greatly appreciate any help or pointers you can give. I'm open to all advice. Learning this is a handful right now, but it's a ton of fun. I think I added m_Gamemode to cWorld correctly, now I'm working on sending the packets with the correct information. I'll probably have some more questions soon. I fixed most of the problems and made the changes you suggested for the gamemode. I've got it working for the respawn: Code: void cPlayer::Respawn() but I'm not sure where or how the login packet is sent from the server yet. Edit: figured it out. It's just done differently in cClientHandle than it is in cPlayer. Going to upload my changes now. It does appear if( m_ItemID <= 0 ) m_ItemID = -1; // Fix, to make sure no invalid values are sent is correct for this packet. Edit: Changes at: http://code.google.com/p/mc-server/source/detail?r=18 RE: Creative Mode - rs2k - 11-02-2011 I fixed creative mode to allow placement of blocks. Basically, any block added from the creative mode inventory is not acknowledged by the server. cClientHandle.cpp now ignores the check to remove an item in creative mode and allows placement of blocks not in your inventory. I'm planning on changing creative mode to being player based. A player spawns into the world in whatever mode the world is set to, but all checks of creative mode will be based on the player's current mode. RE: Creative Mode - rs2k - 11-02-2011 I added some sanity checks for working with blocks. I want to make the server kick the player if they cause the sanity check to go off too many times now. MCserver crashes when picking up an inventory item. I'm not sure when this bug started since the server's been in GM 1 for a while now. I'll start looking into it. Edit: I added another LOG below the spot I thought was causing the problem and now I can't replicate the crash. Maybe it was just a problem in that one compile. Semms to be working now. I set the interaction limit to 0.1 seconds. This is easy to hit by clicking quickly. I did this so it'd be easier to test. RE: Creative Mode - FakeTruth - 11-02-2011 (11-02-2011, 03:54 AM)rs2k Wrote: I fixed creative mode to allow placement of blocks. Basically, any block added from the creative mode inventory is not acknowledged by the server. cClientHandle.cpp now ignores the check to remove an item in creative mode and allows placement of blocks not in your inventory. That's exactly how I would do it. (11-02-2011, 06:12 AM)rs2k Wrote: I added some sanity checks for working with blocks. I want to make the server kick the player if they cause the sanity check to go off too many times now. I never had those problems on my side. I do notice sometimes when testing from cygwin that the server crashes randomly, and when I do a complete recompile of the entire project it works fine, so my guess is that you sometimes have to do a full recompile when using gcc |