if success then pos = vector.round(vector.add(core.localplayer:get_pos(), pos)) end
return success, pos
end
-
-core.anticheat_protection = minetest.settings:get_bool("anticheat_protection") ~= false
antiknockback (AntiKnockback) bool false
-# Set to true if AntiCheat is enabled on server
-anticheat_protection (AnticheatProtection) bool true
-
autorespawn (AutoRespawn) bool false
show_cheat_hud (CheatHUD) bool true
func = warp.delete,
})
+local function do_warp(param)
+ if param == "" then return false, "Missing parameter." end
+ local success, pos = minetest.parse_pos(param)
+ if not success then
+ local msg
+ success, msg, pos = warp.get(param)
+ if not success then
+ return false, msg
+ end
+ end
+ minetest.localplayer:set_pos(pos)
+ return true, "Warped to " .. minetest.pos_to_string(pos)
+end
+
minetest.register_chatcommand("warp", {
params = "<pos>|<warp>",
- description = "Warp to a set warp or a position. " .. (core.anticheat_protection and "You have to be attached for this to work (sitting in a boat or similar) and you will be disconnected and have to rejoin." or ""),
+ description = "Warp to a set warp or a position.",
+ func = do_warp
+})
+
+minetest.register_chatcommand("warpandexit", {
+ params = "<pos>|<warp>",
+ description = "Warp to a set warp or a position and exit.",
func = function(param)
- if param == "" then return false, "Missing parameter." end
- local success, pos = minetest.parse_pos(param)
- if not success then
- local msg
- success, msg, pos = warp.get(param)
- if not success then
- return false, msg
- end
- end
- minetest.localplayer:set_pos(pos)
- if core.anticheat_protection then
+ local s, m = do_warp(param)
+ if s then
minetest.disconnect()
end
- return true, "Warped to " .. minetest.pos_to_string(pos)
+ return s,m
end
})
-
-
Send(&pkt);
}
-void Client::sendPlayerPos()
+void Client::sendPlayerPos(v3f pos)
{
LocalPlayer *player = m_env.getLocalPlayer();
if (!player)
// return;
if (
- player->last_position == player->getPosition() &&
+ player->last_position == pos &&
player->last_speed == player->getSpeed() &&
player->last_pitch == player->getPitch() &&
player->last_yaw == player->getYaw() &&
player->last_wanted_range == wanted_range)
return;
- player->last_position = player->getPosition();
+ player->last_position = pos;
player->last_speed = player->getSpeed();
player->last_pitch = player->getPitch();
player->last_yaw = player->getYaw();
Send(&pkt);
}
+void Client::sendPlayerPos()
+{
+ LocalPlayer *player = m_env.getLocalPlayer();
+ if (!player)
+ return;
+ sendPlayerPos(player->getPosition());
+}
+
void Client::removeNode(v3s16 p)
{
std::map<v3s16, MapBlock*> modified_blocks;
return m_env.getLocalPlayer()->formspec_prepend;
}
+ void sendPlayerPos(v3f pos);
void sendPlayerPos();
MeshUpdateThread m_mesh_update_thread;
ClientActiveObject *parent = m_env->getActiveObject(parent_id);
if (parent_id != old_parent) {
+ if (old_parent)
+ m_waiting_for_reattach = 10;
if (auto *o = m_env->getActiveObject(old_parent))
o->removeAttachmentChild(m_id);
if (parent)
parent->addAttachmentChild(m_id);
}
-
-
+
updateAttachments();
}
void addAttachmentChild(int child_id);
void removeAttachmentChild(int child_id);
ClientActiveObject *getParent() const;
+ int getParentId() const { return m_attachment_parent_id; }
const std::unordered_set<int> &getAttachmentChildIds() const
{ return m_attachment_child_ids; }
void updateAttachments();
{
return m_prop.infotext;
}
+
+ float m_waiting_for_reattach;
};
ClientMap &map = env.getClientMap();
const NodeDefManager *nodedef = map.getNodeDefManager();
- if (g_settings->getBool("killaura")) {
- std::vector<DistanceSortedActiveObject> allObjects;
- env.getActiveObjects(shootline.start, shootline.getLength() + 10.0f, allObjects);
- const v3f line_vector = shootline.getVector();
- for (const auto &allObject : allObjects) {
- ClientActiveObject *obj = allObject.obj;
- s16 id = obj->getId();
- v3f pos = obj->getPosition();
- v3f intersection;
- v3s16 normal;
- aabb3f selection_box;
- if (! obj->getSelectionBox(&selection_box))
- continue;
- aabb3f offsetted_box(selection_box.MinEdge + pos, selection_box.MaxEdge + pos);
- boxLineCollision(offsetted_box, shootline.start, line_vector, &intersection, &normal);
- PointedThing pointed(id, intersection, normal, (intersection - shootline.start).getLengthSQ());
- client->interact(INTERACT_START_DIGGING, pointed);
- break;
- }
- }
-
+ if (g_settings->getBool("killaura"))
+ handleKillaura(shootline.start, shootline.getLength());
+
runData.selected_object = NULL;
hud->pointing_at_object = false;
RaycastState s(shootline, look_for_object, liquids_pointable);
return result;
}
+void Game::handleKillaura(v3f origin, f32 max_d)
+{
+ ClientEnvironment &env = client->getEnv();
+ std::vector<DistanceSortedActiveObject> allObjects;
+ env.getActiveObjects(origin, max_d, allObjects);
+ for (const auto &allObject : allObjects) {
+ ClientActiveObject *obj = allObject.obj;
+ s16 id = obj->getId();
+ aabb3f selection_box;
+ if (! obj->getSelectionBox(&selection_box))
+ continue;
+ PointedThing pointed(id, v3f(0,0,0), v3s16(0,0,0), 0);
+ client->interact(INTERACT_START_DIGGING, pointed);
+ break;
+ }
+}
void Game::handlePointingAtNothing(const ItemStack &playerItem)
{
PointedThing updatePointedThing(
const core::line3d<f32> &shootline, bool liquids_pointable,
bool look_for_object, const v3s16 &camera_offset);
+ void handleKillaura(v3f origin, f32 max_d);
void handlePointingAtNothing(const ItemStack &playerItem);
void handlePointingAtNode(const PointedThing &pointed,
const ItemStack &selected_item, const ItemStack &hand_item, f32 dtime);
#include "map.h"
#include "client.h"
#include "content_cao.h"
+#include "util/pointedthing.h"
+#include "client/game.h"
/*
LocalPlayer
void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d,
std::vector<CollisionInfo> *collision_info)
{
+ if (m_cao && m_cao->m_waiting_for_reattach > 0)
+ m_cao->m_waiting_for_reattach -= dtime;
+
// Node at feet position, update each ClientEnvironment::step()
if (!collision_info || collision_info->empty())
m_standing_node = floatToInt(m_position, BS);
ClientActiveObject *LocalPlayer::getParent() const
{
- return m_cao ? m_cao->getParent() : nullptr;
+ return (m_cao && ! g_settings->getBool("entity_speed")) ? m_cao->getParent() : nullptr;
}
bool LocalPlayer::isDead() const
return !getCAO()->isImmortal() && hp == 0;
}
+void LocalPlayer::tryReattach(int id)
+{
+ PointedThing pointed(id, v3f(0, 0, 0), v3s16(0, 0, 0), 0);
+ m_client->interact(INTERACT_PLACE, pointed);
+ m_cao->m_waiting_for_reattach = 10;
+}
+
+bool LocalPlayer::isWaitingForReattach() const
+{
+ return g_settings->getBool("entity_speed") && m_cao && ! m_cao->getParent() && m_cao->m_waiting_for_reattach > 0;
+}
+
// 3D acceleration
void LocalPlayer::accelerate(const v3f &target_speed, const f32 max_increase_H,
const f32 max_increase_V, const bool use_pitch)
{
added_velocity += vel;
}
-
+
+ void tryReattach(int id);
+
+ bool isWaitingForReattach() const;
+
private:
void accelerate(const v3f &target_speed, const f32 max_increase_H,
const f32 max_increase_V, const bool use_pitch);
settings->setDefault("increase_tool_range", "true");
settings->setDefault("hud_flags_bypass", "true");
settings->setDefault("antiknockback", "false");
+ settings->setDefault("entity_speed", "false");
// Keymap
settings->setDefault("remote_port", "30000");
#include "server.h"
#include "util/strfnd.h"
#include "client/clientevent.h"
+#include "client/content_cao.h"
#include "client/sound.h"
#include "network/clientopcodes.h"
#include "network/connection.h"
string initialization data
}
*/
-
+
+ LocalPlayer *player = m_env.getLocalPlayer();
+ bool try_reattach = player && player->isWaitingForReattach();
+
try {
u8 type;
u16 removed_count, added_count, id;
for (u16 i = 0; i < added_count; i++) {
*pkt >> id >> type;
m_env.addActiveObject(id, type, pkt->readLongString());
+ if (try_reattach)
+ player->tryReattach(id);
}
} catch (PacketError &e) {
infostream << "handleCommand_ActiveObjectRemoveAdd: " << e.what()
}
void Client::handleCommand_MovePlayer(NetworkPacket* pkt)
-{
+{
LocalPlayer *player = m_env.getLocalPlayer();
assert(player != NULL);
+ if ((player->getCAO() && player->getCAO()->getParentId()) || player->isWaitingForReattach())
+ return;
+
v3f pos;
f32 pitch, yaw;