mirror of
https://git.neolegacy.dev/neoStudiosLCE/neoLegacy.git
synced 2026-11-26 21:26:38 +01:00
Patch Notes: Blocks + Colored shulker boxes + Concrete powder + Concrete + Glazed terracotta Items + Shulker shell + Iron nugget UI Changes + Added Custom Controls to Keyboard & Mouse, as well as Controller + Added Custom SuperFlat + Added Edit Server Menu + Added Firework Crafting Feature Changes + Host Options + Added Pick Block + Added off-hand slot for maps and arrows. Bug Fixes & changes + TU47: Banner hitbox wrong (and inventory model fixed) + TU47/48: Ice not melting properly + TU48: Dead bushes not dropping sticks + TU48: Guardians and polar bears not dropping cooked fish when on fire + TU48: Bonus chest missing saplings and seeds + TU48: Frosted ice obtainable + TU48: Hoppers not collecting items + TU48: Wither skeletons spawning in 2-high gaps + TU48: End crystals exploding with “TNT Explodes” off + TU48: Tamed ocelots staying hostile + TU48: Signs not placing on tall grass + TU51: Skeleton hitbox wrong + TU53: Fall damage in shallow water + TU53: Squids not spawning in man-made pools + Elytra has been improved to be more accurate to the source material + Removed Spectral Arrow from crafting + Fixed several broken item descriptions + You can no longer cook Pufferfish or Clownfish + Fixed scaling issue with paperdoll and chat + Iron and gold armor can now be smelted into nuggets. + More items can now be used as fuel in a furnace. + Using a firework rocket while gliding with elytra will now give the player a boost. + Changed the color of dyes, wool, carpets, and banners. + Reordered all colored blocks and items in the Creative inventory. Banners now have the same order of colors as all other colored blocks and items. + Fishing rods can now hook on entities without causing knockback or pseudo-damage. + Fixed banner crafting + Fixed Map colors for certain blocks + Fixed Path block height + Fixed String block issues + Fixed Item frame culling. + Fixed Tutorial world NBT/Block State issues + Fixed World Slider + Fixed Enderman AI + Fixed Player animation bug + HUD Flash text changes + Generation accuracy changes + Many other small accuracy changes and fixes
276 lines
6.6 KiB
C++
276 lines
6.6 KiB
C++
#include "stdafx.h"
|
|
#include "StringHelpers.h"
|
|
#include "net.minecraft.world.level.levelgen.flat.h"
|
|
#include "net.minecraft.world.level.tile.h"
|
|
#include "net.minecraft.world.level.biome.h"
|
|
#include "FlatGeneratorInfo.h"
|
|
|
|
const wstring FlatGeneratorInfo::STRUCTURE_VILLAGE = L"village";
|
|
const wstring FlatGeneratorInfo::STRUCTURE_BIOME_SPECIFIC = L"biome_1";
|
|
const wstring FlatGeneratorInfo::STRUCTURE_STRONGHOLD = L"stronghold";
|
|
const wstring FlatGeneratorInfo::STRUCTURE_MINESHAFT = L"mineshaft";
|
|
const wstring FlatGeneratorInfo::STRUCTURE_BIOME_DECORATION = L"decoration";
|
|
const wstring FlatGeneratorInfo::STRUCTURE_LAKE = L"lake";
|
|
const wstring FlatGeneratorInfo::STRUCTURE_LAVA_LAKE = L"lava_lake";
|
|
const wstring FlatGeneratorInfo::STRUCTURE_DUNGEON = L"dungeon";
|
|
const wstring FlatGeneratorInfo::STRUCTURE_CAVES = L"caves";
|
|
const wstring FlatGeneratorInfo::STRUCTURE_RAVINES = L"ravine";
|
|
const wstring FlatGeneratorInfo::STRUCTURE_OCEAN_MONUMENT = L"oceanmonument";
|
|
|
|
FlatGeneratorInfo::FlatGeneratorInfo()
|
|
{
|
|
biome = 1;
|
|
}
|
|
|
|
int FlatGeneratorInfo::getBiome()
|
|
{
|
|
return biome;
|
|
}
|
|
|
|
void FlatGeneratorInfo::setBiome(int biome)
|
|
{
|
|
this->biome = biome;
|
|
}
|
|
|
|
unordered_map<wstring, unordered_map<wstring, wstring> > *FlatGeneratorInfo::getStructures()
|
|
{
|
|
return &structures;
|
|
}
|
|
|
|
bool FlatGeneratorInfo::hasStructure(const wstring &name)
|
|
{
|
|
return structures.find(name) != structures.end();
|
|
}
|
|
|
|
void FlatGeneratorInfo::setStructure(const wstring &name, bool enabled)
|
|
{
|
|
if (enabled)
|
|
{
|
|
if (!hasStructure(name))
|
|
structures[name] = unordered_map<wstring, wstring>();
|
|
}
|
|
else
|
|
{
|
|
structures.erase(name);
|
|
}
|
|
}
|
|
|
|
wstring FlatGeneratorInfo::getOption(const wstring &name, const wstring &option, const wstring &fallback)
|
|
{
|
|
auto it = structures.find(name);
|
|
if (it == structures.end())
|
|
return fallback;
|
|
auto opt = it->second.find(option);
|
|
if (opt == it->second.end())
|
|
return fallback;
|
|
return opt->second;
|
|
}
|
|
|
|
int FlatGeneratorInfo::getIntOption(const wstring &name, const wstring &option, int fallback)
|
|
{
|
|
wstring value = getOption(name, option, L"");
|
|
if (value.empty())
|
|
return fallback;
|
|
return Mth::getInt(value, fallback);
|
|
}
|
|
|
|
void FlatGeneratorInfo::setOption(const wstring &name, const wstring &option, const wstring &value)
|
|
{
|
|
structures[name][option] = value;
|
|
}
|
|
|
|
void FlatGeneratorInfo::setIntOption(const wstring &name, const wstring &option, int value)
|
|
{
|
|
setOption(name, option, std::to_wstring(value));
|
|
}
|
|
|
|
vector<FlatLayerInfo> *FlatGeneratorInfo::getLayers()
|
|
{
|
|
return &layers;
|
|
}
|
|
|
|
int FlatGeneratorInfo::getTotalHeight()
|
|
{
|
|
int total = 0;
|
|
for (auto &layer : layers)
|
|
total += layer.getHeight();
|
|
return total;
|
|
}
|
|
|
|
void FlatGeneratorInfo::updateLayers()
|
|
{
|
|
int y = 0;
|
|
for (auto &layer : layers)
|
|
{
|
|
layer.setStart(y);
|
|
y += layer.getHeight();
|
|
}
|
|
}
|
|
|
|
void FlatGeneratorInfo::addLayerOnTop(int height, int id, int data)
|
|
{
|
|
layers.push_back(FlatLayerInfo(height, id, data));
|
|
updateLayers();
|
|
}
|
|
|
|
void FlatGeneratorInfo::clear()
|
|
{
|
|
layers.clear();
|
|
structures.clear();
|
|
biome = 1;
|
|
}
|
|
|
|
wstring FlatGeneratorInfo::toString()
|
|
{
|
|
wstring result = std::to_wstring(SERIALIZATION_VERSION);
|
|
result += L";";
|
|
for (size_t i = 0; i < layers.size(); i++)
|
|
{
|
|
if (i > 0)
|
|
result += L",";
|
|
result += layers[i].toString();
|
|
}
|
|
result += L";";
|
|
result += std::to_wstring(biome);
|
|
result += L";";
|
|
int structCount = 0;
|
|
for (auto &structure : structures)
|
|
{
|
|
if (structCount++ > 0)
|
|
result += L",";
|
|
result += structure.first;
|
|
if (!structure.second.empty())
|
|
{
|
|
result += L"(";
|
|
int optionCount = 0;
|
|
for (auto &option : structure.second)
|
|
{
|
|
if (optionCount++ > 0)
|
|
result += L" ";
|
|
result += option.first + L"=" + option.second;
|
|
}
|
|
result += L")";
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
bool FlatGeneratorInfo::parseLayer(const wstring &input, FlatLayerInfo &out)
|
|
{
|
|
if (input.empty())
|
|
return false;
|
|
int height = 1;
|
|
wstring identity = input;
|
|
size_t x = input.find(L'x');
|
|
if (x != wstring::npos)
|
|
{
|
|
height = Mth::getInt(input.substr(0, x), 1);
|
|
identity = input.substr(x + 1);
|
|
}
|
|
int id = 0;
|
|
int data = 0;
|
|
size_t colon = identity.find(L':');
|
|
if (colon != wstring::npos)
|
|
{
|
|
id = Mth::getInt(identity.substr(0, colon), 0);
|
|
data = Mth::getInt(identity.substr(colon + 1), 0);
|
|
}
|
|
else
|
|
{
|
|
id = Mth::getInt(identity, 0);
|
|
}
|
|
if (id < 0 || id >= 256 || (id != 0 && Tile::tiles[id] == nullptr))
|
|
{
|
|
id = 0;
|
|
data = 0;
|
|
}
|
|
if (data < 0 || data > 15)
|
|
data = 0;
|
|
if (height < 1)
|
|
height = 1;
|
|
out = FlatLayerInfo(height, id, data);
|
|
return true;
|
|
}
|
|
|
|
FlatGeneratorInfo FlatGeneratorInfo::fromValue(const wstring &input)
|
|
{
|
|
if (input.empty())
|
|
return getDefault();
|
|
std::vector<std::wstring> parts = stringSplit(input, L';');
|
|
if (parts.size() < 2)
|
|
return getDefault();
|
|
int version = Mth::getInt(parts[0], -1);
|
|
if (version < 0 || version > SERIALIZATION_VERSION)
|
|
return getDefault();
|
|
|
|
FlatGeneratorInfo result;
|
|
result.structures.clear();
|
|
int total = 0;
|
|
std::vector<std::wstring> depths = stringSplit(parts[1], L',');
|
|
for (auto &depth : depths)
|
|
{
|
|
FlatLayerInfo layer(1, 0);
|
|
if (!parseLayer(depth, layer))
|
|
continue;
|
|
if (total + layer.getHeight() > MAX_HEIGHT)
|
|
layer.setHeight(MAX_HEIGHT - total);
|
|
if (layer.getHeight() <= 0)
|
|
break;
|
|
total += layer.getHeight();
|
|
result.layers.push_back(layer);
|
|
if ((int)result.layers.size() >= MAX_LAYERS)
|
|
break;
|
|
}
|
|
result.updateLayers();
|
|
|
|
int biome = 1;
|
|
if (parts.size() > 2)
|
|
biome = Mth::getInt(parts[2], 1);
|
|
if (biome < 0 || biome >= 256 || Biome::biomes[biome] == nullptr)
|
|
biome = 1;
|
|
result.setBiome(biome);
|
|
|
|
if (parts.size() > 3 && !parts[3].empty())
|
|
{
|
|
std::vector<std::wstring> entries = stringSplit(parts[3], L',');
|
|
for (auto &entry : entries)
|
|
{
|
|
wstring name = entry;
|
|
wstring options;
|
|
size_t open = entry.find(L'(');
|
|
if (open != wstring::npos)
|
|
{
|
|
name = entry.substr(0, open);
|
|
size_t close = entry.find(L')', open);
|
|
options = entry.substr(open + 1, close == wstring::npos ? wstring::npos : close - open - 1);
|
|
}
|
|
if (name.empty())
|
|
continue;
|
|
unordered_map<wstring, wstring> &opts = result.structures[name];
|
|
if (!options.empty())
|
|
{
|
|
std::vector<std::wstring> pairs = stringSplit(options, L' ');
|
|
for (auto &pair : pairs)
|
|
{
|
|
size_t eq = pair.find(L'=');
|
|
if (eq != wstring::npos && eq > 0)
|
|
opts[pair.substr(0, eq)] = pair.substr(eq + 1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
FlatGeneratorInfo FlatGeneratorInfo::getDefault()
|
|
{
|
|
FlatGeneratorInfo result;
|
|
result.setBiome(Biome::plains->id);
|
|
result.layers.push_back(FlatLayerInfo(1, Tile::bedrock_Id));
|
|
result.layers.push_back(FlatLayerInfo(2, Tile::dirt_Id));
|
|
result.layers.push_back(FlatLayerInfo(1, Tile::grass_Id));
|
|
result.updateLayers();
|
|
result.structures[STRUCTURE_VILLAGE] = unordered_map<wstring, wstring>();
|
|
return result;
|
|
}
|