diff options
| author | daoge <3523206925@qq.com> | 2026-03-03 03:04:10 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-03 03:04:10 +0800 |
| commit | b3feddfef372618c8a9d7a0abcaf18cfad866c18 (patch) | |
| tree | 267761c3bb39241ba5c347bfbe2254d06686e287 /Minecraft.World/ArmorItem.cpp | |
| parent | 84c31a2331f7a0ec85b9d438992e244f60e5020f (diff) | |
feat: TU19 (Dec 2014) Features & Content (#155)
* try to resolve merge conflict
* feat: TU19 (Dec 2014) Features & Content (#32)
* December 2014 files
* Working release build
* Fix compilation issues
* Add sound to Windows64Media
* Add DLC content and force Tutorial DLC
* Revert "Add DLC content and force Tutorial DLC"
This reverts commit 97a43994725008e35fceb984d5549df9c8cea470.
* Disable broken light packing
* Disable breakpoint during DLC texture map load
Allows DLC loading but the DLC textures are still broken
* Fix post build not working
* ...
* fix vs2022 build
* fix cmake build
---------
Co-authored-by: Loki <lokirautio@gmail.com>
Diffstat (limited to 'Minecraft.World/ArmorItem.cpp')
| -rw-r--r-- | Minecraft.World/ArmorItem.cpp | 43 |
1 files changed, 40 insertions, 3 deletions
diff --git a/Minecraft.World/ArmorItem.cpp b/Minecraft.World/ArmorItem.cpp index 0b2c24e4..114b200b 100644 --- a/Minecraft.World/ArmorItem.cpp +++ b/Minecraft.World/ArmorItem.cpp @@ -1,7 +1,11 @@ #include "stdafx.h" #include "..\Minecraft.Client\Minecraft.h" #include "net.minecraft.world.h" +#include "net.minecraft.world.level.tile.h" #include "net.minecraft.world.entity.player.h" +#include "net.minecraft.world.entity.h" +#include "net.minecraft.world.phys.h" +#include "net.minecraft.world.level.h" #include "com.mojang.nbt.h" #include "ArmorItem.h" @@ -17,6 +21,41 @@ const wstring ArmorItem::TEXTURE_EMPTY_SLOTS[] = { L"slot_empty_helmet", L"slot_empty_chestplate", L"slot_empty_leggings", L"slot_empty_boots" }; + +shared_ptr<ItemInstance> ArmorItem::ArmorDispenseItemBehavior::execute(BlockSource *source, shared_ptr<ItemInstance> dispensed, eOUTCOME &outcome) +{ + FacingEnum *facing = DispenserTile::getFacing(source->getData()); + int x = source->getBlockX() + facing->getStepX(); + int y = source->getBlockY() + facing->getStepY(); + int z = source->getBlockZ() + facing->getStepZ(); + AABB *bb = AABB::newTemp(x, y, z, x + 1, y + 1, z + 1); + EntitySelector *selector = new MobCanWearArmourEntitySelector(dispensed); + vector<shared_ptr<Entity> > *entities = source->getWorld()->getEntitiesOfClass(typeid(LivingEntity), bb, selector); + delete selector; + + if (entities->size() > 0) + { + shared_ptr<LivingEntity> target = dynamic_pointer_cast<LivingEntity>( entities->at(0) ); + int offset = target->instanceof(eTYPE_PLAYER) ? 1 : 0; + int slot = Mob::getEquipmentSlotForItem(dispensed); + shared_ptr<ItemInstance> equip = dispensed->copy(); + equip->count = 1; + target->setEquippedSlot(slot - offset, equip); + if (target->instanceof(eTYPE_MOB)) dynamic_pointer_cast<Mob>(target)->setDropChance(slot, 2); + dispensed->count--; + + outcome = ACTIVATED_ITEM; + + delete entities; + return dispensed; + } + else + { + delete entities; + return DefaultDispenseItemBehavior::execute(source, dispensed, outcome); + } +} + typedef ArmorItem::ArmorMaterial _ArmorMaterial; const int _ArmorMaterial::clothArray[] = {1,3,2,1}; @@ -86,6 +125,7 @@ ArmorItem::ArmorItem(int id, const ArmorMaterial *armorType, int icon, int slot) { setMaxDamage(armorType->getHealthForSlot(slot)); maxStackSize = 1; + DispenserTile::REGISTRY.add(this, new ArmorDispenseItemBehavior()); } int ArmorItem::getColor(shared_ptr<ItemInstance> item, int spriteLayer) @@ -100,7 +140,6 @@ int ArmorItem::getColor(shared_ptr<ItemInstance> item, int spriteLayer) return color; } -//@Override bool ArmorItem::hasMultipleSpriteLayers() { return armorType == ArmorMaterial::CLOTH; @@ -145,7 +184,6 @@ int ArmorItem::getColor(shared_ptr<ItemInstance> item) } } -//@Override Icon *ArmorItem::getLayerIcon(int auxValue, int spriteLayer) { if (spriteLayer == 1) @@ -198,7 +236,6 @@ bool ArmorItem::isValidRepairItem(shared_ptr<ItemInstance> source, shared_ptr<It return Item::isValidRepairItem(source, repairItem); } -//@Override void ArmorItem::registerIcons(IconRegister *iconRegister) { Item::registerIcons(iconRegister); |
