the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 168 lines 4.8 kB view raw
1#include "stdafx.h" 2#include "net.minecraft.world.phys.h" 3#include "net.minecraft.world.entity.item.h" 4#include "net.minecraft.world.item.h" 5#include "net.minecraft.world.level.h" 6#include "net.minecraft.world.level.material.h" 7#include "net.minecraft.world.damagesource.h" 8#include "com.mojang.nbt.h" 9#include "Painting.h" 10#include "Material.h" 11 12 13 14typedef Painting::Motive _Motive; 15const _Motive *Painting::Motive::values[] = { 16 new _Motive(L"Kebab", 16, 16, 0 * 16, 0 * 16), 17 new _Motive(L"Aztec", 16, 16, 1 * 16, 0 * 16), // 18 new _Motive(L"Alban", 16, 16, 2 * 16, 0 * 16), // 19 new _Motive(L"Aztec2", 16, 16, 3 * 16, 0 * 16), // 20 new _Motive(L"Bomb", 16, 16, 4 * 16, 0 * 16), // 21 new _Motive(L"Plant", 16, 16, 5 * 16, 0 * 16), // 22 new _Motive(L"Wasteland", 16, 16, 6 * 16, 0 * 16), // 23 24 new _Motive(L"Pool", 32, 16, 0 * 16, 2 * 16), // 25 new _Motive(L"Courbet", 32, 16, 2 * 16, 2 * 16), // 26 new _Motive(L"Sea", 32, 16, 4 * 16, 2 * 16), // 27 new _Motive(L"Sunset", 32, 16, 6 * 16, 2 * 16), // 28 new _Motive(L"Creebet", 32, 16, 8 * 16, 2 * 16), // 29 30 new _Motive(L"Wanderer", 16, 32, 0 * 16, 4 * 16), // 31 new _Motive(L"Graham", 16, 32, 1 * 16, 4 * 16), // 32 33 new _Motive(L"Match", 32, 32, 0 * 16, 8 * 16), // 34 new _Motive(L"Bust", 32, 32, 2 * 16, 8 * 16), // 35 new _Motive(L"Stage", 32, 32, 4 * 16, 8 * 16), // 36 new _Motive(L"Void", 32, 32, 6 * 16, 8 * 16), // 37 new _Motive(L"SkullAndRoses", 32, 32, 8 * 16, 8 * 16), // 38 new _Motive(L"Wither", 32, 32, 10 * 16, 8 * 16), 39 new _Motive(L"Fighters", 64, 32, 0 * 16, 6 * 16), // 40 41 new _Motive(L"Pointer", 64, 64, 0 * 16, 12 * 16), // 42 new _Motive(L"Pigscene", 64, 64, 4 * 16, 12 * 16), // 43 new _Motive(L"BurningSkull", 64, 64, 8 * 16, 12 * 16), // 44 45 new _Motive(L"Skeleton", 64, 48, 12 * 16, 4 * 16), // 46 new _Motive(L"DonkeyKong", 64, 48, 12 * 16, 7 * 16), // 47}; 48 49// 4J Stu - Rather than creating a new string object here I am just using the 50// actual number value of the characters in "SkullandRoses" which should be the 51// longest name from the above 52const int Painting::Motive::MAX_MOTIVE_NAME_LENGTH = 13; //JAVA: "SkullAndRoses".length(); 53 54// 4J - added for common ctor code 55void Painting::_init( Level *level ) 56{ 57 motive = NULL; 58}; 59 60Painting::Painting(Level *level) : HangingEntity( level ) 61{ 62 // 4J Stu - This function call had to be moved here from the Entity ctor to ensure that 63 // the derived version of the function is called 64 this->defineSynchedData(); 65 66 _init( level ); 67} 68 69Painting::Painting(Level *level, int xTile, int yTile, int zTile, int dir) : HangingEntity( level , xTile, yTile, zTile, dir) 70{ 71 _init(level); 72 73 // 4J Stu - If you use this ctor, then you need to call the PaintingPostConstructor 74} 75 76// 4J Stu - Added this so that we can use some shared_ptr functions that were needed in the ctor 77// 4J Stu - Added motive param for debugging/artists only 78void Painting::PaintingPostConstructor(int dir, int motive) 79{ 80#ifndef _CONTENT_PACKAGE 81 if (app.DebugArtToolsOn() && motive >= 0) 82 { 83 this->motive = (Motive *)Motive::values[motive]; 84 setDir(dir); 85 } 86 else 87#endif 88 { 89 vector<Motive *> *survivableMotives = new vector<Motive *>(); 90 for (int i = 0 ; i < LAST_VALUE; i++) 91 { 92 this->motive = (Motive *)Motive::values[i]; 93 setDir(dir); 94 if (survives()) 95 { 96 survivableMotives->push_back(this->motive); 97 } 98 } 99 if (!survivableMotives->empty()) 100 { 101 this->motive = survivableMotives->at(random->nextInt((int)survivableMotives->size())); 102 } 103 setDir(dir); 104 } 105} 106 107Painting::Painting(Level *level, int x, int y, int z, int dir, wstring motiveName) : HangingEntity( level , x, y, z, dir ) 108{ 109 _init(level); 110 111 for (int i = 0 ; i < LAST_VALUE; i++) 112 { 113 if ( (Motive::values[i])->name.compare(motiveName) == 0) 114 { 115 this->motive = (Motive *)Motive::values[i]; 116 break; 117 } 118 } 119 setDir(dir); 120} 121 122void Painting::addAdditonalSaveData(CompoundTag *tag) 123{ 124 ///TODO Safe to cast to non-const type? 125 tag->putString(L"Motive", motive->name); 126 127 HangingEntity::addAdditonalSaveData(tag); 128 } 129 130void Painting::readAdditionalSaveData(CompoundTag *tag) 131{ 132 wstring motiveName = tag->getString(L"Motive"); 133 vector<Motive *>::iterator it; 134 for (int i = 0 ; i < LAST_VALUE; i++) 135 { 136 if ( Motive::values[i]->name.compare(motiveName) == 0) 137 { 138 this->motive = (Motive *)Motive::values[i]; 139 } 140 } 141 if (this->motive == NULL) motive = (Motive *)Motive::values[ Kebab ]; 142 143 HangingEntity::readAdditionalSaveData(tag); 144} 145 146int Painting::getWidth() 147{ 148 return motive->w; 149} 150 151int Painting::getHeight() 152{ 153 return motive->h; 154} 155 156void Painting::dropItem(shared_ptr<Entity> causedBy) 157{ 158 if ( (causedBy != NULL) && causedBy->instanceof(eTYPE_PLAYER) ) 159 { 160 shared_ptr<Player> player = dynamic_pointer_cast<Player>(causedBy); 161 if (player->abilities.instabuild) 162 { 163 return; 164 } 165 } 166 167 spawnAtLocation(shared_ptr<ItemInstance>(new ItemInstance(Item::painting)), 0.0f); 168}