From b3feddfef372618c8a9d7a0abcaf18cfad866c18 Mon Sep 17 00:00:00 2001 From: daoge <3523206925@qq.com> Date: Tue, 3 Mar 2026 03:04:10 +0800 Subject: 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 --- Minecraft.World/ArmorItem.cpp | 43 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) (limited to 'Minecraft.World/ArmorItem.cpp') 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 ArmorItem::ArmorDispenseItemBehavior::execute(BlockSource *source, shared_ptr 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 > *entities = source->getWorld()->getEntitiesOfClass(typeid(LivingEntity), bb, selector); + delete selector; + + if (entities->size() > 0) + { + shared_ptr target = dynamic_pointer_cast( entities->at(0) ); + int offset = target->instanceof(eTYPE_PLAYER) ? 1 : 0; + int slot = Mob::getEquipmentSlotForItem(dispensed); + shared_ptr equip = dispensed->copy(); + equip->count = 1; + target->setEquippedSlot(slot - offset, equip); + if (target->instanceof(eTYPE_MOB)) dynamic_pointer_cast(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 item, int spriteLayer) @@ -100,7 +140,6 @@ int ArmorItem::getColor(shared_ptr item, int spriteLayer) return color; } -//@Override bool ArmorItem::hasMultipleSpriteLayers() { return armorType == ArmorMaterial::CLOTH; @@ -145,7 +184,6 @@ int ArmorItem::getColor(shared_ptr item) } } -//@Override Icon *ArmorItem::getLayerIcon(int auxValue, int spriteLayer) { if (spriteLayer == 1) @@ -198,7 +236,6 @@ bool ArmorItem::isValidRepairItem(shared_ptr source, shared_ptr