the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 57 lines 1.8 kB view raw
1#include "stdafx.h" 2#include "net.minecraft.commands.h" 3#include "net.minecraft.world.entity.item.h" 4#include "net.minecraft.world.item.h" 5#include "net.minecraft.network.packet.h" 6#include "..\Minecraft.Client\ServerPlayer.h" 7#include "GiveItemCommand.h" 8 9EGameCommand GiveItemCommand::getId() 10{ 11 return eGameCommand_Give; 12} 13 14int GiveItemCommand::getPermissionLevel() 15{ 16 return LEVEL_GAMEMASTERS; 17} 18 19void GiveItemCommand::execute(shared_ptr<CommandSender> source, byteArray commandData) 20{ 21 ByteArrayInputStream bais(commandData); 22 DataInputStream dis(&bais); 23 24 PlayerUID uid = dis.readPlayerUID(); 25 int item = dis.readInt(); 26 int amount = dis.readInt(); 27 int aux = dis.readInt(); 28 wstring tag = dis.readUTF(); 29 30 bais.reset(); 31 32 shared_ptr<ServerPlayer> player = getPlayer(uid); 33 if(player != NULL && item > 0 && Item::items[item] != NULL) 34 { 35 shared_ptr<ItemInstance> itemInstance = shared_ptr<ItemInstance>(new ItemInstance(item, amount, aux)); 36 shared_ptr<ItemEntity> drop = player->drop(itemInstance); 37 drop->throwTime = 0; 38 //logAdminAction(source, L"commands.give.success", ChatPacket::e_ChatCustom, Item::items[item]->getName(itemInstance), item, amount, player->getAName()); 39 logAdminAction(source, ChatPacket::e_ChatCustom, L"commands.give.success", item, player->getAName()); 40 } 41} 42 43shared_ptr<GameCommandPacket> GiveItemCommand::preparePacket(shared_ptr<Player> player, int item, int amount, int aux, const wstring &tag) 44{ 45 if(player == NULL) return nullptr; 46 47 ByteArrayOutputStream baos; 48 DataOutputStream dos(&baos); 49 50 dos.writePlayerUID(player->getXuid()); 51 dos.writeInt(item); 52 dos.writeInt(amount); 53 dos.writeInt(aux); 54 dos.writeUTF(tag); 55 56 return shared_ptr<GameCommandPacket>( new GameCommandPacket(eGameCommand_Give, baos.toByteArray() )); 57}