the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 45 lines 1.5 kB view raw
1#include "stdafx.h" 2#include "net.minecraft.world.entity.player.h" 3#include "net.minecraft.world.level.tile.h" 4#include "net.minecraft.world.level.h" 5#include "SnowItem.h" 6 7SnowItem::SnowItem(int id, Tile *parentTile) : AuxDataTileItem(id, parentTile) 8{ 9} 10 11bool SnowItem::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) 12{ 13 if (instance->count == 0) return false; 14 if (!player->mayUseItemAt(x, y, z, face, instance)) return false; 15 16 int currentTile = level->getTile(x, y, z); 17 18 // Are we adding extra snow to an existing tile? 19 if (currentTile == Tile::topSnow_Id) 20 { 21 Tile *snowTile = Tile::tiles[getTileId()]; 22 int currentData = level->getData(x, y, z); 23 int currentHeight = currentData & TopSnowTile::HEIGHT_MASK; 24 25 if (currentHeight <= TopSnowTile::MAX_HEIGHT && level->isUnobstructed(snowTile->getAABB(level, x, y, z))) 26 { 27 if (!bTestUseOnOnly) 28 { 29 // Increase snow tile height 30 if (level->setData(x, y, z, (currentHeight + 1) | (currentData & ~TopSnowTile::HEIGHT_MASK), Tile::UPDATE_CLIENTS)) 31 { 32 level->playSound(x + 0.5f, y + 0.5f, z + 0.5f, snowTile->soundType->getPlaceSound(), (snowTile->soundType->getVolume() + 1) / 2, snowTile->soundType->getPitch() * 0.8f); 33 instance->count--; 34 return true; 35 } 36 } 37 else 38 { 39 return true; 40 } 41 } 42 } 43 44 return AuxDataTileItem::useOn(instance, player, level, x, y, z, face, clickX, clickY, clickZ, bTestUseOnOnly); 45}