Files
MinecraftConsoles/Minecraft.World/PickaxeItem.cpp
ModMaker101 a9be52c41a Project modernization (#630)
* Fixed boats falling and a TP glitch #266

* Replaced every C-style cast with C++ ones

* Replaced every C-style cast with C++ ones

* Fixed boats falling and a TP glitch #266

* Updated NULL to nullptr and fixing some type issues

* Modernized and fixed a few bugs

- Replaced most instances of `NULL` with `nullptr`.
- Replaced most `shared_ptr(new ...)` with `make_shared`.
- Removed the `nullptr` macro as it was interfering with the actual nullptr keyword in some instances.

* Fixing more conflicts

* Replace int loops with size_t and start work on overrides
2026-03-08 09:56:03 +07:00

63 lines
2.3 KiB
C++

#include "stdafx.h"
#include "net.minecraft.world.level.tile.h"
#include "PickaxeItem.h"
TileArray PickaxeItem::diggables;
void PickaxeItem::staticCtor()
{
PickaxeItem::diggables = TileArray( PICKAXE_DIGGABLES);
diggables.data[0] = Tile::cobblestone;
diggables.data[1] = Tile::stoneSlab;
diggables.data[2] = Tile::stoneSlabHalf;
diggables.data[3] = Tile::stone;
diggables.data[4] = Tile::sandStone;
diggables.data[5] = Tile::mossyCobblestone;
diggables.data[6] = Tile::ironOre;
diggables.data[7] = Tile::ironBlock;
diggables.data[8] = Tile::coalOre;
diggables.data[9] = Tile::goldBlock;
diggables.data[10] = Tile::goldOre;
diggables.data[11] = Tile::diamondOre;
diggables.data[12] = Tile::diamondBlock;
diggables.data[13] = Tile::ice;
diggables.data[14] = Tile::netherRack;
diggables.data[15] = Tile::lapisOre;
diggables.data[16] = Tile::lapisBlock;
diggables.data[17] = Tile::redStoneOre;
diggables.data[18] = Tile::redStoneOre_lit;
diggables.data[19] = Tile::rail;
diggables.data[20] = Tile::detectorRail;
diggables.data[21] = Tile::goldenRail;
diggables.data[21] = Tile::activatorRail;
}
PickaxeItem::PickaxeItem(int id, const Tier *tier) : DiggerItem(id, 2, tier, &diggables)
{
}
bool PickaxeItem::canDestroySpecial(Tile *tile)
{
if (tile == Tile::obsidian) return tier->getLevel() == 3;
if (tile == Tile::diamondBlock || tile == Tile::diamondOre) return tier->getLevel() >= 2;
if (tile == Tile::emeraldBlock || tile == Tile::emeraldOre) return tier->getLevel() >= 2;
if (tile == Tile::goldBlock || tile == Tile::goldOre) return tier->getLevel() >= 2;
if (tile == Tile::ironBlock || tile == Tile::ironOre) return tier->getLevel() >= 1;
if (tile == Tile::lapisBlock || tile == Tile::lapisOre) return tier->getLevel() >= 1;
if (tile == Tile::redStoneOre || tile == Tile::redStoneOre_lit) return tier->getLevel() >= 2;
if (tile->material == Material::stone) return true;
if (tile->material == Material::metal) return true;
if (tile->material == Material::heavyMetal) return true;
return false;
}
// 4J - brought forward from 1.2.3
float PickaxeItem::getDestroySpeed(shared_ptr<ItemInstance> itemInstance, Tile *tile)
{
if (tile != nullptr && (tile->material == Material::metal || tile->material == Material::heavyMetal || tile->material == Material::stone))
{
return speed;
}
return DiggerItem::getDestroySpeed(itemInstance, tile);
}