the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 52 lines 1.5 kB view raw
1#include "stdafx.h" 2 3#include "..\..\Minecraft.h" 4#include "..\..\MultiplayerLocalPlayer.h" 5#include "AreaConstraint.h" 6#include "..\..\..\Minecraft.World\AABB.h" 7 8AreaConstraint::AreaConstraint( int descriptionId, double x0, double y0, double z0, double x1, double y1, double z1, bool contains /*= true*/, bool restrictsMovement /*=true*/ ) 9 : TutorialConstraint( descriptionId ) 10{ 11 messageArea = AABB::newPermanent(x0+2, y0+2, z0+2, x1-2, y1-2, z1-2); 12 movementArea = AABB::newPermanent(x0, y0, z0, x1, y1, z1); 13 14 this->contains = contains; 15 m_restrictsMovement = restrictsMovement; 16} 17 18AreaConstraint::~AreaConstraint() 19{ 20 delete messageArea; 21 delete movementArea; 22} 23 24bool AreaConstraint::isConstraintSatisfied(int iPad) 25{ 26 Minecraft *minecraft = Minecraft::GetInstance(); 27 return messageArea->contains( minecraft->localplayers[iPad]->getPos(1) ) == contains; 28} 29 30bool AreaConstraint::isConstraintRestrictive(int iPad) 31{ 32 return m_restrictsMovement; 33} 34 35 36bool AreaConstraint::canMoveToPosition(double xo, double yo, double zo, double xt, double yt, double zt) 37{ 38 if(!m_restrictsMovement) return true; 39 40 Vec3 *targetPos = Vec3::newTemp(xt, yt, zt); 41 Minecraft *minecraft = Minecraft::GetInstance(); 42 43 if(movementArea->contains( targetPos ) == contains) 44 { 45 return true; 46 } 47 Vec3 *origPos = Vec3::newTemp(xo, yo, zo); 48 49 double currDist = origPos->distanceTo(movementArea); 50 double targetDist = targetPos->distanceTo(movementArea); 51 return targetDist < currDist; 52}