the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 64 lines 1.8 kB view raw
1#include "stdafx.h" 2#include "net.minecraft.world.entity.player.h" 3#include "net.minecraft.world.level.h" 4#include "net.minecraft.world.level.tile.h" 5#include "net.minecraft.world.level.tile.entity.h" 6#include "ItemInstance.h" 7#include "SignItem.h" 8#include "GenericStats.h" 9 10SignItem::SignItem(int id) : Item(id) 11{ 12 // 4J-PB - Changed for TU9 13 maxStackSize = 16; 14} 15 16bool SignItem::useOn(shared_ptr<ItemInstance> instance, shared_ptr<Player> player, Level *level, int x, int y, int z, int face, float clickX, float clickY, float clickZ, bool bTestUseOnOnly) 17{ 18 // 4J-PB - Adding a test only version to allow tooltips to be displayed 19 if (face == 0) return false; 20 if (!level->getMaterial(x, y, z)->isSolid()) return false; 21 22 23 if (face == 1) y++; 24 if (face == 2) z--; 25 if (face == 3) z++; 26 if (face == 4) x--; 27 if (face == 5) x++; 28 29 if (!player->mayUseItemAt(x, y, z, face, instance)) return false; 30 31 if (!Tile::sign->mayPlace(level, x, y, z)) return false; 32 33 if (level->isClientSide) 34 { 35 return true; 36 } 37 38 if(!bTestUseOnOnly) 39 { 40 if (face == 1) 41 { 42 int rot = Mth::floor(((player->yRot + 180) * 16) / 360 + 0.5) & 15; 43 level->setTileAndData(x, y, z, Tile::sign_Id, rot, Tile::UPDATE_ALL); 44 } 45 else 46 { 47 level->setTileAndData(x, y, z, Tile::wallSign_Id, face, Tile::UPDATE_ALL); 48 } 49 50 instance->count--; 51 shared_ptr<SignTileEntity> ste = dynamic_pointer_cast<SignTileEntity>( level->getTileEntity(x, y, z) ); 52 if (ste != NULL) player->openTextEdit(ste); 53 54 // 4J-JEV: Hook for durango 'BlockPlaced' event. 55 player->awardStat( 56 GenericStats::blocksPlaced((face==1) ? Tile::sign_Id : Tile::wallSign_Id), 57 GenericStats::param_blocksPlaced( 58 (face==1) ? Tile::sign_Id : Tile::wallSign_Id, 59 instance->getAuxValue(), 60 1) 61 ); 62 } 63 return true; 64}