the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 117 lines 3.4 kB view raw
1#include "stdafx.h" 2#include "net.minecraft.h" 3#include "net.minecraft.world.phys.h" 4#include "net.minecraft.world.damagesource.h" 5#include "net.minecraft.world.level.tile.h" 6#include "net.minecraft.world.item.h" 7#include "net.minecraft.world.level.h" 8#include "HangingEntityItem.h" 9#include "HangingEntity.h" 10#include "Painting.h" 11#include "GenericStats.h" 12#include "ItemFrame.h" 13 14 15HangingEntityItem::HangingEntityItem(int id, eINSTANCEOF eClassType) : Item(id) 16{ 17 this->eType=eClassType; 18} 19 20bool HangingEntityItem::useOn(shared_ptr<ItemInstance> instance, shared_ptr<Player> player, Level *level, int xt, int yt, int zt, int face, float clickX, float clickY, float clickZ, bool bTestOnly) 21{ 22 if (face == Facing::DOWN) return false; 23 if (face == Facing::UP) return false; 24 25 if(bTestOnly) 26 { 27 if (!player->mayUseItemAt(xt, yt, zt, face, instance)) return false; 28 29 return true; 30 } 31 32 int dir = Direction::FACING_DIRECTION[face]; 33 34 shared_ptr<HangingEntity> entity = createEntity(level, xt, yt, zt, dir, instance->getAuxValue() ); 35 36 if (!player->mayUseItemAt(xt, yt, zt, face, instance)) return false; 37 38 if (entity != NULL && entity->survives()) 39 { 40 if (!level->isClientSide) 41 { 42 if(level->addEntity(entity)==TRUE) 43 { 44 // 4J-JEV: Hook for durango 'BlockPlaced' event. 45 if (eType==eTYPE_PAINTING) player->awardStat(GenericStats::blocksPlaced(Item::painting_Id), GenericStats::param_blocksPlaced(Item::painting_Id,instance->getAuxValue(),1)); 46 else if (eType==eTYPE_ITEM_FRAME) player->awardStat(GenericStats::blocksPlaced(Item::itemFrame_Id), GenericStats::param_blocksPlaced(Item::itemFrame_Id,instance->getAuxValue(),1)); 47 48 instance->count--; 49 } 50 else 51 { 52 player->displayClientMessage(IDS_MAX_HANGINGENTITIES ); 53 return false; 54 } 55 } 56 else 57 { 58 instance->count--; 59 } 60 } 61 return true; 62} 63 64 65shared_ptr<HangingEntity> HangingEntityItem::createEntity(Level *level, int x, int y, int z, int dir, int auxValue) // 4J added auxValue 66{ 67 if (eType == eTYPE_PAINTING) 68 { 69 shared_ptr<Painting> painting = shared_ptr<Painting>(new Painting(level, x, y, z, dir)); 70 71#ifndef _CONTENT_PACKAGE 72 if (app.DebugArtToolsOn() && auxValue > 0) 73 { 74 painting->PaintingPostConstructor(dir, auxValue - 1); 75 } 76 else 77#endif 78 { 79 painting->PaintingPostConstructor(dir); 80 } 81 82 return dynamic_pointer_cast<HangingEntity> (painting); 83 } 84 else if (eType == eTYPE_ITEM_FRAME) 85 { 86 shared_ptr<ItemFrame> itemFrame = shared_ptr<ItemFrame>(new ItemFrame(level, x, y, z, dir)); 87 88 return dynamic_pointer_cast<HangingEntity> (itemFrame); 89 } 90 else 91 { 92 return nullptr; 93 } 94} 95 96// 4J Adding overrides for art tools 97void HangingEntityItem::appendHoverText(shared_ptr<ItemInstance> itemInstance, shared_ptr<Player> player, vector<HtmlString> *lines, bool advanced) 98{ 99#ifndef _CONTENT_PACKAGE 100 if (eType == eTYPE_PAINTING && app.DebugArtToolsOn() && itemInstance->getAuxValue() > 0 ) 101 { 102 int motive = itemInstance->getAuxValue() - 1; 103 104 wchar_t formatted[256]; 105 ZeroMemory(formatted, 256 * sizeof(wchar_t)); 106 swprintf(formatted, 256, L"** %ls %dx%d",Painting::Motive::values[motive]->name.c_str(),Painting::Motive::values[motive]->w/16,Painting::Motive::values[motive]->h/16); 107 108 wstring motiveName = formatted; 109 110 lines->push_back(HtmlString(motiveName.c_str(), eHTMLColor_c)); 111 } 112 else 113#endif 114 { 115 return Item::appendHoverText(itemInstance, player, lines, advanced); 116 } 117}