aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/ArmorSlot.cpp
blob: 2e85fed312a4c191ca4bcdf58e14a4e959cbe225 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include "stdafx.h"
#include "net.minecraft.world.h"
#include "net.minecraft.world.item.h"
#include "net.minecraft.world.level.tile.h"
#include "net.minecraft.world.inventory.h"
#include "net.minecraft.world.item.crafting.h"
#include "ArmorSlot.h"

ArmorSlot::ArmorSlot(int slotNum, shared_ptr<Container> container, int id, int x, int y)
	: Slot( container, id, x, y ),
	slotNum( slotNum )
{
}

int ArmorSlot::getMaxStackSize() const
{
	return 1;
}

bool ArmorSlot::mayPlace(shared_ptr<ItemInstance> item)
{
	if (item == nullptr)
	{
		return false;
	}
	if ( dynamic_cast<ArmorItem *>( item->getItem() ) != nullptr)
	{
		return dynamic_cast<ArmorItem *>( item->getItem() )->slot == slotNum;
	}
	if (item->getItem()->id == Tile::pumpkin_Id || item->getItem()->id == Item::skull_Id)
	{
		return slotNum == 0;
	}
	return false;
}

Icon *ArmorSlot::getNoItemIcon()
{
	return ArmorItem::getEmptyIcon(slotNum);
}

//
//bool ArmorSlot::mayCombine(shared_ptr<ItemInstance> item)
//{
//	shared_ptr<ItemInstance> thisItemI = getItem();
//	if(thisItemI == nullptr || item == nullptr) return false;
//
//	ArmorItem *thisItem = (ArmorItem *)thisItemI->getItem();
//	bool thisIsDyableArmor = thisItem->getMaterial() == ArmorItem::ArmorMaterial::CLOTH;
//	bool itemIsDye = item->id == Item::dye_powder_Id;
//	return thisIsDyableArmor && itemIsDye;
//}
//
//shared_ptr<ItemInstance> ArmorSlot::combine(shared_ptr<ItemInstance> item)
//{
//	shared_ptr<CraftingContainer> craftSlots = shared_ptr<CraftingContainer>( new CraftingContainer(nullptr, 2, 2) );
//	craftSlots->setItem(0, item);
//	craftSlots->setItem(1, getItem()); // Armour item needs to go second
//	shared_ptr<ItemInstance> result = ArmorDyeRecipe::assembleDyedArmor(craftSlots);
//	craftSlots->setItem(0, nullptr);
//	craftSlots->setItem(1, nullptr);
//	return result;
//}