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/LeashItem.cpp | 74 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 Minecraft.World/LeashItem.cpp (limited to 'Minecraft.World/LeashItem.cpp') diff --git a/Minecraft.World/LeashItem.cpp b/Minecraft.World/LeashItem.cpp new file mode 100644 index 00000000..d8d7b3fc --- /dev/null +++ b/Minecraft.World/LeashItem.cpp @@ -0,0 +1,74 @@ +#include "stdafx.h" +#include "net.minecraft.world.level.tile.h" +#include "net.minecraft.world.level.h" +#include "net.minecraft.world.entity.h" +#include "net.minecraft.world.phys.h" +#include "LeashItem.h" + +LeashItem::LeashItem(int id) : Item(id) +{ +} + +bool LeashItem::useOn(shared_ptr itemInstance, shared_ptr player, Level *level, int x, int y, int z, int face, float clickX, float clickY, float clickZ, bool bTestUseOnOnly) +{ + int tile = level->getTile(x, y, z); + if (Tile::tiles[tile] != NULL && Tile::tiles[tile]->getRenderShape() == Tile::SHAPE_FENCE) + { + if (bTestUseOnOnly) return bindPlayerMobsTest(player, level, x,y,z); + + if (level->isClientSide) + { + return true; + } + + bindPlayerMobs(player, level, x, y, z); + return true; + } + return false; +} + +bool LeashItem::bindPlayerMobs(shared_ptr player, Level *level, int x, int y, int z) +{ + // check if there is a knot at the given coordinate + shared_ptr activeKnot = LeashFenceKnotEntity::findKnotAt(level, x, y, z); + + // look for entities that can be attached to the fence + bool foundMobs = false; + double range = 7; + vector > *mobs = level->getEntitiesOfClass(typeid(Mob), AABB::newTemp(x - range, y - range, z - range, x + range, y + range, z + range)); + if (mobs != NULL) + { + for(AUTO_VAR(it,mobs->begin()); it != mobs->end(); ++it) + { + shared_ptr mob = dynamic_pointer_cast(*it); + if (mob->isLeashed() && mob->getLeashHolder() == player) + { + if (activeKnot == NULL) + { + activeKnot = LeashFenceKnotEntity::createAndAddKnot(level, x, y, z); + } + mob->setLeashedTo(activeKnot, true); + foundMobs = true; + } + } + } + return foundMobs; +} + +// 4J-JEV: Similar to bindPlayerMobs, but doesn't actually bind mobs, +bool LeashItem::bindPlayerMobsTest(shared_ptr player, Level *level, int x, int y, int z) +{ + // look for entities that can be attached to the fence + double range = 7; + vector > *mobs = level->getEntitiesOfClass(typeid(Mob), AABB::newTemp(x - range, y - range, z - range, x + range, y + range, z + range)); + + if (mobs != NULL) + { + for(AUTO_VAR(it,mobs->begin()); it != mobs->end(); ++it) + { + shared_ptr mob = dynamic_pointer_cast(*it); + if (mob->isLeashed() && mob->getLeashHolder() == player) return true; + } + } + return false; +} \ No newline at end of file -- cgit v1.2.3