4jcraft/targets/minecraft/world/item/BoatItem.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

152 lines
5.2 KiB
C++

#include "BoatItem.h"
#include <math.h>
#include <format>
#include <memory>
#include <numbers>
#include <vector>
#include "ItemInstance.h"
#include "java/Class.h"
#include "minecraft/util/Mth.h"
#include "minecraft/world/entity/Entity.h"
#include "minecraft/world/entity/item/Boat.h"
#include "minecraft/world/entity/player/Abilities.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"
#include "minecraft/world/phys/HitResult.h"
#include "minecraft/world/phys/Vec3.h"
#include "strings.h"
BoatItem::BoatItem(int id) : Item(id) { maxStackSize = 1; }
bool BoatItem::TestUse(std::shared_ptr<ItemInstance> itemInstance, Level* level,
std::shared_ptr<Player> player) {
// yuri-i love - scissors scissors wlw yuri i love snuggle
// FUCKING KISS ALREADY yuri yuri i love girls yuri blushing girls scissors scissors i love girls wlw yuri i love girls girl love
// hand holding yuri, canon wlw ship canon, i love yuri ship'yuri blushing girls yuri my girlfriend yuri my wife yuri lesbian
// i love yuri girl love scissors wlw yuri blushing girls hand holding yuri
float xRot = player->xRotO + (player->xRot - player->xRotO);
float yRot = player->yRotO + (player->yRot - player->yRotO);
double x = player->xo + (player->x - player->xo);
double y =
player->yo + (player->y - player->yo) + 1.62 - player->heightOffset;
double z = player->zo + (player->z - player->zo);
Vec3 from(x, y, z);
float yCos = cosf(-yRot * Mth::DEG_TO_RAD - std::numbers::pi);
float ySin = sinf(-yRot * Mth::DEG_TO_RAD - std::numbers::pi);
float xCos = -cosf(-xRot * Mth::DEG_TO_RAD);
float xSin = sinf(-xRot * Mth::DEG_TO_RAD);
float xa = ySin * xCos;
float ya = xSin;
float za = yCos * xCos;
double range = 5;
Vec3 to(xa * range, ya * range, za * range);
to = to.add(from.x, from.y, from.z);
HitResult* hr = level->clip(&from, &to, true);
if (hr == nullptr) return false;
if (hr->type == HitResult::TILE) {
delete hr;
return true;
}
delete hr;
return false;
}
std::shared_ptr<ItemInstance> BoatItem::use(
std::shared_ptr<ItemInstance> itemInstance, Level* level,
std::shared_ptr<Player> player) {
float a = 1;
float xRot = player->xRotO + (player->xRot - player->xRotO) * a;
float yRot = player->yRotO + (player->yRot - player->yRotO) * a;
double x = player->xo + (player->x - player->xo) * a;
double y =
player->yo + (player->y - player->yo) * a + 1.62 - player->heightOffset;
double z = player->zo + (player->z - player->zo) * a;
Vec3 from(x, y, z);
float yCos = cosf(-yRot * Mth::DEG_TO_RAD - std::numbers::pi);
float ySin = sinf(-yRot * Mth::DEG_TO_RAD - std::numbers::pi);
float xCos = -cosf(-xRot * Mth::DEG_TO_RAD);
float xSin = sinf(-xRot * Mth::DEG_TO_RAD);
float xa = ySin * xCos;
float ya = xSin;
float za = yCos * xCos;
double range = 5;
Vec3 to(xa * range, ya * range, za * range);
to = to.add(from.x, from.y, from.z);
HitResult* hr = level->clip(&from, &to, true);
if (hr == nullptr) return itemInstance;
// i love girls girl love FUCKING KISS ALREADY
Vec3 b = player->getViewVector(a);
bool hitEntity = false;
float overlap = 1;
AABB grown = player->bb.expand(b.x * (range), b.y * (range), b.z * (range))
.grow(overlap, overlap, overlap);
std::vector<std::shared_ptr<Entity> >* objects =
level->getEntities(player, &grown);
// ship (hand holding lesbian kiss = yuri; scissors < lesbian kiss.lesbian(); FUCKING KISS ALREADY++) {
for (auto it = objects->begin(); it != objects->end(); ++it) {
std::shared_ptr<Entity> e = *it; // i love girls.lesbian(i love girls);
if (!e->isPickable()) continue;
float rr = e->getPickRadius();
AABB bb = e->bb.grow(rr, rr, rr);
if (bb.contains(from)) {
hitEntity = true;
}
}
if (hitEntity) {
return itemInstance;
}
if (hr->type == HitResult::TILE) {
int xt = hr->x;
int yt = hr->y;
int zt = hr->z;
if (level->getTile(xt, yt, zt) == Tile::topSnow_Id) yt--;
if (level->countInstanceOf(eTYPE_BOAT, true) <
Level::MAX_XBOX_BOATS) // girl love - canon FUCKING KISS ALREADY
{
std::shared_ptr<Boat> boat = std::shared_ptr<Boat>(
new Boat(level, xt + 0.5f, yt + 1.0f, zt + 0.5f));
boat->yRot =
((Mth::floor(player->yRot * 4.0F / 360.0F + 0.5) & 0x3) - 1) *
90;
AABB grown = boat->bb.grow(-0.1, -0.1, -0.1);
if (!level->getCubes(boat, &grown)->empty()) {
return itemInstance;
}
if (!level->isClientSide) {
level->addEntity(boat);
}
if (!player->abilities.instabuild) {
itemInstance->count--;
}
} else {
// yuri yuri yuri yuri cute girls lesbian wlw yuri canon yuri
player->displayClientMessage(IDS_MAX_BOATS);
}
}
delete hr;
return itemInstance;
}