Something went wrong. Try again.
the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
Something went wrong. Try again.
1.8 kB · 73 lines
C++
at master
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273#include "stdafx.h"#include "net.minecraft.world.entity.h"#include "net.minecraft.world.entity.ai.navigation.h"#include "net.minecraft.world.level.h"#include "net.minecraft.world.level.pathfinder.h"#include "net.minecraft.world.level.tile.h"#include "DoorInteractGoal.h"
DoorInteractGoal::DoorInteractGoal(Mob *mob){ doorX = doorY = doorZ = 0; doorTile = NULL; passed = false; doorOpenDirX = doorOpenDirZ = 0.0f;
this->mob = mob;}
bool DoorInteractGoal::canUse(){ if (!mob->horizontalCollision) return false; PathNavigation *pathNav = mob->getNavigation(); Path *path = pathNav->getPath(); if (path == NULL || path->isDone() || !pathNav->canOpenDoors()) return false;
for (int i = 0; i < min(path->getIndex() + 2, path->getSize()); ++i) { Node *n = path->get(i); doorX = n->x; doorY = n->y + 1; doorZ = n->z; if (mob->distanceToSqr(doorX, mob->y, doorZ) > 1.5 * 1.5) continue; doorTile = getDoorTile(doorX, doorY, doorZ); if (doorTile == NULL) continue; return true; }
doorX = Mth::floor(mob->x); doorY = Mth::floor(mob->y + 1); doorZ = Mth::floor(mob->z); doorTile = getDoorTile(doorX, doorY, doorZ); return doorTile != NULL;}
bool DoorInteractGoal::canContinueToUse(){ return !passed;}
void DoorInteractGoal::start(){ passed = false; doorOpenDirX = (float) (doorX + 0.5f - mob->x); doorOpenDirZ = (float) (doorZ + 0.5f - mob->z);}
void DoorInteractGoal::tick(){ float newDoorDirX = (float) (doorX + 0.5f - mob->x); float newDoorDirZ = (float) (doorZ + 0.5f - mob->z); float dot = doorOpenDirX * newDoorDirX + doorOpenDirZ * newDoorDirZ; if (dot < 0) { passed = true; }}
DoorTile *DoorInteractGoal::getDoorTile(int x, int y, int z){ int tileId = mob->level->getTile(x, y, z); if (tileId != Tile::door_wood_Id) return NULL; return (DoorTile *) Tile::tiles[tileId];}