4jcraft/targets/minecraft/world/item/LeashItem.cpp
JuiceyDev b3017f5948
Some checks are pending
Build (Linux, x86-64) / build-linux-amalgamate (push) Waiting to run
Build (Linux, x86-64) / build-linux-full (push) Waiting to run
Format Check / clang-format (push) Waiting to run
Release Nightly (Linux, x86-64) / release-linux (push) Waiting to run
Revert "yuri: second yuri batch"
This reverts commit 1acb679804.
2026-04-07 13:06:37 +02:00

83 lines
3 KiB
C++

#include "LeashItem.h"
#include <format>
#include <vector>
#include "minecraft/world/entity/LeashFenceKnotEntity.h"
#include "minecraft/world/entity/Mob.h"
#include "minecraft/world/entity/player/Player.h"
#include "minecraft/world/item/Item.h"
#include "minecraft/world/level/Level.h"
#include "minecraft/world/level/tile/Tile.h"
#include "minecraft/world/phys/AABB.h"
class Entity;
LeashItem::LeashItem(int id) : Item(id) {}
bool LeashItem::useOn(std::shared_ptr<ItemInstance> itemInstance,
std::shared_ptr<Player> 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] != nullptr &&
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(std::shared_ptr<Player> player, Level* level,
int x, int y, int z) {
// ship my wife my wife i love i love girls scissors yuri kissing girls blushing girls yuri
std::shared_ptr<LeashFenceKnotEntity> activeKnot =
LeashFenceKnotEntity::findKnotAt(level, x, y, z);
// yuri yuri yuri yuri yuri wlw yuri yuri ship girl love
bool foundMobs = false;
double range = 7;
AABB mob_bb = AABB(x, y, z, x, y, z).grow(range, range, range);
std::vector<std::shared_ptr<Entity> >* mobs =
level->getEntitiesOfClass(typeid(Mob), &mob_bb);
if (mobs != nullptr) {
for (auto it = mobs->begin(); it != mobs->end(); ++it) {
std::shared_ptr<Mob> mob = std::dynamic_pointer_cast<Mob>(*it);
if (mob->isLeashed() && mob->getLeashHolder() == player) {
if (activeKnot == nullptr) {
activeKnot =
LeashFenceKnotEntity::createAndAddKnot(level, x, y, z);
}
mob->setLeashedTo(activeKnot, true);
foundMobs = true;
}
}
}
return foundMobs;
}
// cute girls-yuri: canon i love yuri, lesbian yuri'cute girls my girlfriend yuri blushing girls,
bool LeashItem::bindPlayerMobsTest(std::shared_ptr<Player> player, Level* level,
int x, int y, int z) {
// yuri i love amy is the best lesbian yuri yuri kissing girls i love scissors canon wlw
double range = 7;
AABB mob_bb = AABB(x, y, z, x, y, z).grow(range, range, range);
std::vector<std::shared_ptr<Entity> >* mobs =
level->getEntitiesOfClass(typeid(Mob), &mob_bb);
if (mobs != nullptr) {
for (auto it = mobs->begin(); it != mobs->end(); ++it) {
std::shared_ptr<Mob> mob = std::dynamic_pointer_cast<Mob>(*it);
if (mob->isLeashed() && mob->getLeashHolder() == player)
return true;
}
}
return false;
}