Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
OEOTYAN committed Sep 6, 2022
1 parent 10ef34e commit 08ae21f
Show file tree
Hide file tree
Showing 15 changed files with 1,850 additions and 1,698 deletions.
2,931 changes: 1,310 additions & 1,621 deletions FastNoise/FastNoiseLite.h

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Template/WorldEdit.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ namespace worldedit {
std::unordered_map<std::string, std::pair<BlockPos, std::pair<int, int>>> playerMainPosMap;
std::unordered_map<std::string, std::pair<BlockPos, std::pair<int, int>>> playerVicePosMap;
std::unordered_map<std::string, Clipboard> playerClipboardMap;
std::unordered_map<std::string, std::unordered_map<std::string, Tool*>> playerHandToolMap;
std::unordered_map<std::string, std::unordered_map<std::string,class Tool*>> playerHandToolMap;
std::unordered_map<std::string, std::unordered_map<std::string, Brush*>> playerBrushMap;
std::unordered_map<std::string, std::string> playerGMaskMap;
std::unordered_map<std::string, std::pair<std::vector<Clipboard>, std::pair<int, int>>> playerHistoryMap;
Expand Down
1 change: 1 addition & 0 deletions core/brush/Brush.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace worldedit {
class BlockPattern* pattern = nullptr;
bool setted = false;
std::string mask = "";
bool needFace = false;
Brush() = default;
Brush(unsigned short, BlockPattern*);
void setMask(std::string const& str = "") { mask = str; };
Expand Down
37 changes: 36 additions & 1 deletion core/command/BrushCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace worldedit {
using ParamType = DynamicCommand::ParameterType;
using ParamData = DynamicCommand::ParameterData;

// brush bmask bsize
// brush bmask bsize ruseface

void brushCommandSetup() {
DynamicCommand::setup(
Expand Down Expand Up @@ -247,5 +247,40 @@ namespace worldedit {
}
},
CommandPermissionLevel::GameMasters);

DynamicCommand::setup(
"ruseface", // command name
"set right click useface", // command description
{}, {ParamData("bool", ParamType::Bool, "bool")}, {{"bool"}},
// dynamic command callback
[](DynamicCommand const& command, CommandOrigin const& origin, CommandOutput& output,
std::unordered_map<std::string, DynamicCommand::Result>& results) {
auto& mod = worldedit::getMod();
auto player = origin.getPlayer();
auto* item = player->getHandSlot();
std::string brushName = item->getTypeName() + std::to_string(item->getAuxValue());
auto xuid = player->getXuid();
int i = 0;
if (mod.playerBrushMap.find(xuid) != mod.playerBrushMap.end() &&
mod.playerBrushMap[xuid].find(brushName) != mod.playerBrushMap[xuid].end()) {
auto* brush = mod.playerBrushMap[xuid][brushName];
auto useface = results["bool"].get<bool>();
brush->needFace = useface;
output.success("§aBrush useface set to " + std::to_string(useface));
++i;
}
if (mod.playerHandToolMap.find(xuid) != mod.playerHandToolMap.end() &&
mod.playerHandToolMap[xuid].find(brushName) != mod.playerHandToolMap[xuid].end()) {
auto* tool = mod.playerHandToolMap[xuid][brushName];
auto useface = results["bool"].get<bool>();
tool->needFace = useface;
output.success("§aTool useface set to " + std::to_string(useface));
++i;
}
if (i == 0) {
output.error("You need to choose a brush or tool first");
}
},
CommandPermissionLevel::GameMasters);
}
} // namespace worldedit
40 changes: 22 additions & 18 deletions core/command/ClipboardCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,18 @@ namespace worldedit {
auto boundingBox = region->getBoundBox();
auto blockSource = Level::getBlockSource(dimID);

if (mod.maxHistoryLength > 0) { auto history = mod.getPlayerNextHistory(xuid);
*history = Clipboard(boundingBox.max - boundingBox.min);
history->playerRelPos.x = dimID;
history->playerPos = boundingBox.min;
if (mod.maxHistoryLength > 0) {
auto history = mod.getPlayerNextHistory(xuid);
*history = Clipboard(boundingBox.max - boundingBox.min);
history->playerRelPos.x = dimID;
history->playerPos = boundingBox.min;

region->forEachBlockInRegion([&](const BlockPos& pos) {
auto localPos = pos - boundingBox.min;
auto blockInstance = blockSource->getBlockInstance(pos);
history->storeBlock(blockInstance, localPos);
});}
region->forEachBlockInRegion([&](const BlockPos& pos) {
auto localPos = pos - boundingBox.min;
auto blockInstance = blockSource->getBlockInstance(pos);
history->storeBlock(blockInstance, localPos);
});
}

auto pPos = origin.getPlayer()->getPosition() - Vec3(0.0, 1.62, 0.0);

Expand Down Expand Up @@ -180,16 +182,18 @@ namespace worldedit {
auto dimID = origin.getPlayer()->getDimensionId();
if (!arg_n) {
auto blockSource = Level::getBlockSource(dimID);
if (mod.maxHistoryLength > 0) { auto history = mod.getPlayerNextHistory(xuid);
*history = Clipboard(box.max - box.min);
history->playerRelPos.x = dimID;
history->playerPos = box.min;
if (mod.maxHistoryLength > 0) {
auto history = mod.getPlayerNextHistory(xuid);
*history = Clipboard(box.max - box.min);
history->playerRelPos.x = dimID;
history->playerPos = box.min;

box.forEachBlockInBox([&](const BlockPos& pos) {
auto localPos = pos - box.min;
auto blockInstance = blockSource->getBlockInstance(pos);
history->storeBlock(blockInstance, localPos);
});}
box.forEachBlockInBox([&](const BlockPos& pos) {
auto localPos = pos - box.min;
auto blockInstance = blockSource->getBlockInstance(pos);
history->storeBlock(blockInstance, localPos);
});
}

if (arg_a) {
clipboard->forEachBlockInClipboard([&](const BlockPos& pos) {
Expand Down
59 changes: 54 additions & 5 deletions core/command/HandToolCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
#include "string/StringTool.h"
#include "MC/ItemStack.hpp"
#include "WorldEdit.h"
#include "store/BlockPattern.hpp"

namespace worldedit {
using ParamType = DynamicCommand::ParameterType;
using ParamData = DynamicCommand::ParameterData;

// tool
// tool luseface

void handToolCommandSetup() {
DynamicCommand::setup(
Expand All @@ -24,6 +25,7 @@ namespace worldedit {
{"airwand", {"airwand"}},
{"cycler", {"cycler"}},
{"info", {"info"}},
{"rep", {"rep"}},
{"flood", {"flood"}},
{"none", {"none"}},
},
Expand All @@ -34,11 +36,13 @@ namespace worldedit {
ParamData("airwand", ParamType::Enum, "airwand"),
ParamData("cycler", ParamType::Enum, "cycler"),
ParamData("info", ParamType::Enum, "info"),
ParamData("rep", ParamType::Enum, "rep"),
ParamData("flood", ParamType::Enum, "flood"),
ParamData("none", ParamType::Enum, "none"),
ParamData("block", ParamType::Block, "block"),
ParamData("blockPattern", ParamType::String, "blockPattern"),
ParamData("distance", ParamType::Float, "distance"),
ParamData("dis", ParamType::Int, true, "dis"),
ParamData("needEdge", ParamType::Bool, true, "needEdge"),
},
{
{"tree"},
Expand All @@ -47,8 +51,9 @@ namespace worldedit {
{"airwand"},
{"cycler"},
{"info"},
{"flood", "block", "distance"},
{"flood", "blockPattern", "distance"},
{"rep"},
{"flood", "block", "dis", "needEdge"},
{"flood", "blockPattern", "dis", "needEdge"},
{"none"},
},
// dynamic command callback
Expand Down Expand Up @@ -83,14 +88,58 @@ namespace worldedit {
mod.playerHandToolMap[xuid][toolName] = new InfoTool();
output.success(fmt::format("§aBlock info tool bound to {}", toolrName));
} else if (results["flood"].isSet) {
mod.playerHandToolMap[xuid][toolName] = new FloodFillTool();
std::string bps = "minecraft:air";
if (results["blockPattern"].isSet) {
bps = results["blockPattern"].get<std::string>();
} else if (results["block"].isSet) {
bps = results["block"].get<Block const*>()->getTypeName();
}

int radius = 5;
if (results["dis"].isSet) {
radius = results["dis"].get<int>();
}
int needEdge = false;
if (results["needEdge"].isSet) {
needEdge = results["needEdge"].get<bool>();
}
mod.playerHandToolMap[xuid][toolName] =
new FloodFillTool(new BlockPattern(bps, xuid, nullptr), radius, needEdge);
output.success(fmt::format("§aFlood fill tool bound to {}", toolrName));
} else if (results["rep"].isSet) {
mod.playerHandToolMap[xuid][toolName] = new RepTool();
output.success(fmt::format("§aRep fill tool bound to {}", toolrName));
} else if (results["none"].isSet) {
delete mod.playerHandToolMap[xuid][toolName];
mod.playerHandToolMap[xuid].erase(toolName);
output.success(fmt::format("§aHand tool cleared"));
}
},
CommandPermissionLevel::GameMasters);

DynamicCommand::setup(
"luseface", // command name
"set left click useface", // command description
{}, {ParamData("bool", ParamType::Bool, "bool")}, {{"bool"}},
// dynamic command callback
[](DynamicCommand const& command, CommandOrigin const& origin, CommandOutput& output,
std::unordered_map<std::string, DynamicCommand::Result>& results) {
auto& mod = worldedit::getMod();
auto player = origin.getPlayer();
auto* item = player->getHandSlot();
std::string toolName = item->getTypeName() + std::to_string(item->getAuxValue());
auto xuid = player->getXuid();

if (mod.playerHandToolMap.find(xuid) != mod.playerHandToolMap.end() &&
mod.playerHandToolMap[xuid].find(toolName) != mod.playerHandToolMap[xuid].end()) {
auto* tool = mod.playerHandToolMap[xuid][toolName];
auto useface = results["bool"].get<bool>();
tool->lneedFace = useface;
output.success("§aTool size set to " + std::to_string(useface));
} else {
output.error("You need to choose a tool first");
}
},
CommandPermissionLevel::GameMasters);
}
} // namespace worldedit
40 changes: 32 additions & 8 deletions core/eval/CppEval.h
Original file line number Diff line number Diff line change
Expand Up @@ -316,24 +316,48 @@ namespace cpp_eval {
return 0.577215664901532860606512090082;
case do_hash("e"):
return 2.718281828459045235360287471352;

// cellular disFunc
case do_hash("sqrted"):
return 0;
case do_hash("fbm"):
case do_hash("square"):
return 1;
case do_hash("ridged"):
case do_hash("manhattan"):
return 2;
case do_hash("pingpong"):
case do_hash("hybird"):
return 3;

// cellular returnType
case do_hash("value"):
return 0;
case do_hash("dis"):
case do_hash("dis1"):
return 1;
case do_hash("dis2"):
return 2;
case do_hash("disadd"):
return 3;
case do_hash("dissub"):
return 4;
// simplex(x,y,z,seed,fractaltype,octaves,lacunarity,gain,weighted,ppStrength)
// perlin(x,y,z,seed,fractaltype,octaves,lacunarity,gain,weighted,ppStrength)
// cubic(x,y,z,seed,fractaltype,octaves,lacunarity,gain,weighted,ppStrength)
// value(x,y,z,seed,fractaltype,octaves,lacunarity,gain,weighted,ppStrength)
// cellular(x,y,z,seed,disFunc,returnType,jitter,fractaltype,octaves,lacunarity,gain,weighted,ppStrength)
case do_hash("dismul"):
return 5;
case do_hash("disdiv"):
return 6;

// fractalType
case do_hash("none"):
return 0;
case do_hash("fbm"):
return 1;
case do_hash("ridged"):
return 2;
case do_hash("pingpong"):
return 3;
// simplex(x,y,z,seed,fractalType,octaves,lacunarity,gain,weighted,ppStrength)
// perlin(x,y,z,seed,fractalType,octaves,lacunarity,gain,weighted,ppStrength)
// cubic(x,y,z,seed,fractalType,octaves,lacunarity,gain,weighted,ppStrength)
// value(x,y,z,seed,fractalType,octaves,lacunarity,gain,weighted,ppStrength)
// voronoi(x,y,z,seed,returnType,disFunc,jitter,fractalType,octaves,lacunarity,gain,weighted,ppStrength)
default:
if (mVariables.find(id) == mVariables.end())
return 0;
Expand Down
Loading

0 comments on commit 08ae21f

Please sign in to comment.