the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 80 lines 2.7 kB view raw
1#include "stdafx.h" 2#include "net.minecraft.world.entity.player.h" 3#include "net.minecraft.world.item.h" 4#include "net.minecraft.world.level.h" 5#include "net.minecraft.world.level.tile.h" 6#include "net.minecraft.h" 7#include "TilePlanterItem.h" 8#include "GenericStats.h" 9// 4J-PB - for the debug option of not removing items 10#include <xuiresource.h> 11#include <xuiapp.h> 12 13TilePlanterItem::TilePlanterItem(int id, Tile *tile) : Item(id) 14{ 15 this->tileId = tile->id; 16} 17 18bool TilePlanterItem::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) 19{ 20 // 4J-PB - Adding a test only version to allow tooltips to be displayed 21 int currentTile = level->getTile(x, y, z); 22 if (currentTile == Tile::topSnow_Id && (level->getData(x, y, z) & TopSnowTile::HEIGHT_MASK) < 1) 23 { 24 face = Facing::UP; 25 } 26 else if (currentTile == Tile::vine_Id || currentTile == Tile::tallgrass_Id || currentTile == Tile::deadBush_Id) 27 { 28 } 29 else 30 { 31 if (face == 0) y--; 32 if (face == 1) y++; 33 if (face == 2) z--; 34 if (face == 3) z++; 35 if (face == 4) x--; 36 if (face == 5) x++; 37 } 38 39 if (!player->mayUseItemAt(x, y, z, face, instance)) return false; 40 if (instance->count == 0) return false; 41 42 if (level->mayPlace(tileId, x, y, z, false, face, nullptr, instance)) 43 { 44 if(!bTestUseOnOnly) 45 { 46 Tile *tile = Tile::tiles[tileId]; 47 int dataValue = tile->getPlacedOnFaceDataValue(level, x, y, z, face, clickX, clickY, clickZ, 0); 48 if (level->setTileAndData(x, y, z, tileId, dataValue, Tile::UPDATE_ALL)) 49 { 50 // 4J-JEV: Hook for durango 'BlockPlaced' event. 51 player->awardStat(GenericStats::blocksPlaced(tileId),GenericStats::param_blocksPlaced(tileId,instance->getAuxValue(),1)); 52 53 // 4J Original comment 54 // ok this may look stupid, but neighbor updates can cause the 55 // placed block to become something else before these methods 56 // are called 57 if (level->getTile(x, y, z) == tileId) 58 { 59 Tile::tiles[tileId]->setPlacedBy(level, x, y, z, player, instance); 60 Tile::tiles[tileId]->finalizePlacement(level, x, y, z, dataValue); 61 } 62 level->playSound(x + 0.5f, y + 0.5f, z + 0.5f, tile->soundType->getPlaceSound(), (tile->soundType->getVolume() + 1) / 2, tile->soundType->getPitch() * 0.8f); 63 // 4J-PB - If we have the debug option on, don't reduce the number of this item 64#ifndef _FINAL_BUILD 65 if(!(app.DebugSettingsOn() && app.GetGameSettingsDebugMask()&(1L<<eDebugSetting_CraftAnything))) 66#endif 67 { 68 instance->count--; 69 } 70 71 } 72 } 73 } 74 else 75 { 76 // Can't place, so return false 77 if(bTestUseOnOnly) return false; 78 } 79 return true; 80}