mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-04-25 16:03:42 +00:00
# Conflicts: # Minecraft.Client/Network/PlayerChunkMap.cpp # Minecraft.Client/Network/PlayerList.cpp # Minecraft.Client/Network/ServerChunkCache.cpp # Minecraft.Client/Platform/Common/Consoles_App.cpp # Minecraft.Client/Platform/Common/DLC/DLCManager.cpp # Minecraft.Client/Platform/Common/GameRules/LevelGenerationOptions.cpp # Minecraft.Client/Platform/Common/GameRules/LevelRuleset.cpp # Minecraft.Client/Platform/Common/Tutorial/Tutorial.cpp # Minecraft.Client/Platform/Common/Tutorial/TutorialTask.cpp # Minecraft.Client/Platform/Common/UI/IUIScene_CreativeMenu.cpp # Minecraft.Client/Platform/Common/UI/UIComponent_Panorama.cpp # Minecraft.Client/Platform/Common/UI/UIController.cpp # Minecraft.Client/Platform/Common/UI/UIController.h # Minecraft.Client/Platform/Extrax64Stubs.cpp # Minecraft.Client/Platform/Windows64/4JLibs/inc/4J_Input.h # Minecraft.Client/Platform/Windows64/4JLibs/inc/4J_Storage.h # Minecraft.Client/Player/EntityTracker.cpp # Minecraft.Client/Player/ServerPlayer.cpp # Minecraft.Client/Rendering/EntityRenderers/PlayerRenderer.cpp # Minecraft.Client/Textures/Packs/DLCTexturePack.cpp # Minecraft.Client/Textures/Stitching/StitchedTexture.cpp # Minecraft.Client/Textures/Stitching/TextureMap.cpp # Minecraft.Client/Textures/Textures.cpp # Minecraft.World/Blocks/NotGateTile.cpp # Minecraft.World/Blocks/PressurePlateTile.cpp # Minecraft.World/Blocks/TileEntities/PotionBrewing.cpp # Minecraft.World/Enchantments/EnchantmentHelper.cpp # Minecraft.World/Entities/HangingEntity.cpp # Minecraft.World/Entities/LeashFenceKnotEntity.cpp # Minecraft.World/Entities/LivingEntity.cpp # Minecraft.World/Entities/Mobs/Boat.cpp # Minecraft.World/Entities/Mobs/Minecart.cpp # Minecraft.World/Entities/Mobs/Witch.cpp # Minecraft.World/Entities/SyncedEntityData.cpp # Minecraft.World/Items/LeashItem.cpp # Minecraft.World/Items/PotionItem.cpp # Minecraft.World/Level/BaseMobSpawner.cpp # Minecraft.World/Level/CustomLevelSource.cpp # Minecraft.World/Level/Level.cpp # Minecraft.World/Level/Storage/DirectoryLevelStorage.cpp # Minecraft.World/Level/Storage/McRegionLevelStorage.cpp # Minecraft.World/Level/Storage/RegionFileCache.cpp # Minecraft.World/Player/Player.cpp # Minecraft.World/WorldGen/Biomes/BiomeCache.cpp # Minecraft.World/WorldGen/Features/RandomScatteredLargeFeature.cpp # Minecraft.World/WorldGen/Layers/BiomeOverrideLayer.cpp
162 lines
6.6 KiB
C++
162 lines
6.6 KiB
C++
#include "../../Minecraft.World/Platform/stdafx.h"
|
|
#include "ConsoleGenerateStructure.h"
|
|
#include "ConsoleGameRules.h"
|
|
#include "../../Minecraft.World/Headers/net.minecraft.world.level.h"
|
|
#include "../../Minecraft.World/Headers/net.minecraft.world.level.dimension.h"
|
|
#include "../../Minecraft.World/Headers/net.minecraft.world.level.levelgen.structure.h"
|
|
#include "../../Minecraft.World/Util/StringHelpers.h"
|
|
#include "../../Minecraft.World/Headers/net.minecraft.h"
|
|
|
|
ConsoleGenerateStructure::ConsoleGenerateStructure() : StructurePiece(0) {
|
|
m_x = m_y = m_z = 0;
|
|
boundingBox = nullptr;
|
|
orientation = Direction::NORTH;
|
|
m_dimension = 0;
|
|
}
|
|
|
|
void ConsoleGenerateStructure::getChildren(
|
|
std::vector<GameRuleDefinition*>* children) {
|
|
GameRuleDefinition::getChildren(children);
|
|
|
|
for (auto it = m_actions.begin(); it != m_actions.end(); it++)
|
|
children->push_back(*it);
|
|
}
|
|
|
|
GameRuleDefinition* ConsoleGenerateStructure::addChild(
|
|
ConsoleGameRules::EGameRuleType ruleType) {
|
|
GameRuleDefinition* rule = nullptr;
|
|
if (ruleType == ConsoleGameRules::eGameRuleType_GenerateBox) {
|
|
rule = new XboxStructureActionGenerateBox();
|
|
m_actions.push_back((XboxStructureActionGenerateBox*)rule);
|
|
} else if (ruleType == ConsoleGameRules::eGameRuleType_PlaceBlock) {
|
|
rule = new XboxStructureActionPlaceBlock();
|
|
m_actions.push_back((XboxStructureActionPlaceBlock*)rule);
|
|
} else if (ruleType == ConsoleGameRules::eGameRuleType_PlaceContainer) {
|
|
rule = new XboxStructureActionPlaceContainer();
|
|
m_actions.push_back((XboxStructureActionPlaceContainer*)rule);
|
|
} else if (ruleType == ConsoleGameRules::eGameRuleType_PlaceSpawner) {
|
|
rule = new XboxStructureActionPlaceSpawner();
|
|
m_actions.push_back((XboxStructureActionPlaceSpawner*)rule);
|
|
} else {
|
|
#ifndef _CONTENT_PACKAGE
|
|
wprintf(
|
|
L"ConsoleGenerateStructure: Attempted to add invalid child rule - "
|
|
L"%d\n",
|
|
ruleType);
|
|
#endif
|
|
}
|
|
return rule;
|
|
}
|
|
|
|
void ConsoleGenerateStructure::writeAttributes(DataOutputStream* dos,
|
|
unsigned int numAttrs) {
|
|
GameRuleDefinition::writeAttributes(dos, numAttrs + 5);
|
|
|
|
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_x);
|
|
dos->writeUTF(_toString(m_x));
|
|
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_y);
|
|
dos->writeUTF(_toString(m_y));
|
|
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_z);
|
|
dos->writeUTF(_toString(m_z));
|
|
|
|
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_orientation);
|
|
dos->writeUTF(_toString(orientation));
|
|
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_dimension);
|
|
dos->writeUTF(_toString(m_dimension));
|
|
}
|
|
|
|
void ConsoleGenerateStructure::addAttribute(
|
|
const std::wstring& attributeName, const std::wstring& attributeValue) {
|
|
if (attributeName.compare(L"x") == 0) {
|
|
int value = _fromString<int>(attributeValue);
|
|
m_x = value;
|
|
app.DebugPrintf("ConsoleGenerateStructure: Adding parameter x=%d\n",
|
|
m_x);
|
|
} else if (attributeName.compare(L"y") == 0) {
|
|
int value = _fromString<int>(attributeValue);
|
|
m_y = value;
|
|
app.DebugPrintf("ConsoleGenerateStructure: Adding parameter y=%d\n",
|
|
m_y);
|
|
} else if (attributeName.compare(L"z") == 0) {
|
|
int value = _fromString<int>(attributeValue);
|
|
m_z = value;
|
|
app.DebugPrintf("ConsoleGenerateStructure: Adding parameter z=%d\n",
|
|
m_z);
|
|
} else if (attributeName.compare(L"orientation") == 0) {
|
|
int value = _fromString<int>(attributeValue);
|
|
orientation = value;
|
|
app.DebugPrintf(
|
|
"ConsoleGenerateStructure: Adding parameter orientation=%d\n",
|
|
orientation);
|
|
} else if (attributeName.compare(L"dim") == 0) {
|
|
m_dimension = _fromString<int>(attributeValue);
|
|
if (m_dimension > 1 || m_dimension < -1) m_dimension = 0;
|
|
app.DebugPrintf(
|
|
"ApplySchematicRuleDefinition: Adding parameter dimension=%d\n",
|
|
m_dimension);
|
|
} else {
|
|
GameRuleDefinition::addAttribute(attributeName, attributeValue);
|
|
}
|
|
}
|
|
|
|
BoundingBox* ConsoleGenerateStructure::getBoundingBox() {
|
|
if (boundingBox == nullptr) {
|
|
// Find the max bounds
|
|
int maxX, maxY, maxZ;
|
|
maxX = maxY = maxZ = 1;
|
|
for (auto it = m_actions.begin(); it != m_actions.end(); ++it) {
|
|
ConsoleGenerateStructureAction* action = *it;
|
|
maxX = std::max(maxX, action->getEndX());
|
|
maxY = std::max(maxY, action->getEndY());
|
|
maxZ = std::max(maxZ, action->getEndZ());
|
|
}
|
|
|
|
boundingBox =
|
|
new BoundingBox(m_x, m_y, m_z, m_x + maxX, m_y + maxY, m_z + maxZ);
|
|
}
|
|
return boundingBox;
|
|
}
|
|
|
|
bool ConsoleGenerateStructure::postProcess(Level* level, Random* random,
|
|
BoundingBox* chunkBB) {
|
|
if (level->dimension->id != m_dimension) return false;
|
|
|
|
for (auto it = m_actions.begin(); it != m_actions.end(); ++it) {
|
|
ConsoleGenerateStructureAction* action = *it;
|
|
|
|
switch (action->getActionType()) {
|
|
case ConsoleGameRules::eGameRuleType_GenerateBox: {
|
|
XboxStructureActionGenerateBox* genBox =
|
|
(XboxStructureActionGenerateBox*)action;
|
|
genBox->generateBoxInLevel(this, level, chunkBB);
|
|
} break;
|
|
case ConsoleGameRules::eGameRuleType_PlaceBlock: {
|
|
XboxStructureActionPlaceBlock* pPlaceBlock =
|
|
(XboxStructureActionPlaceBlock*)action;
|
|
pPlaceBlock->placeBlockInLevel(this, level, chunkBB);
|
|
} break;
|
|
case ConsoleGameRules::eGameRuleType_PlaceContainer: {
|
|
XboxStructureActionPlaceContainer* pPlaceContainer =
|
|
(XboxStructureActionPlaceContainer*)action;
|
|
pPlaceContainer->placeContainerInLevel(this, level, chunkBB);
|
|
} break;
|
|
case ConsoleGameRules::eGameRuleType_PlaceSpawner: {
|
|
XboxStructureActionPlaceSpawner* pPlaceSpawner =
|
|
(XboxStructureActionPlaceSpawner*)action;
|
|
pPlaceSpawner->placeSpawnerInLevel(this, level, chunkBB);
|
|
} break;
|
|
default:
|
|
break;
|
|
};
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
bool ConsoleGenerateStructure::checkIntersects(int x0, int y0, int z0, int x1,
|
|
int y1, int z1) {
|
|
return getBoundingBox()->intersects(x0, y0, z0, x1, y1, z1);
|
|
}
|
|
|
|
int ConsoleGenerateStructure::getMinY() { return getBoundingBox()->y0; }
|