aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Client/Common/GameRules/XboxStructureActionPlaceSpawner.cpp
diff options
context:
space:
mode:
authordaoge_cmd <3523206925@qq.com>2026-03-01 12:16:08 +0800
committerdaoge_cmd <3523206925@qq.com>2026-03-01 12:16:08 +0800
commitb691c43c44ff180d10e7d4a9afc83b98551ff586 (patch)
tree3e9849222cbc6ba49f2f1fc6e5fe7179632c7390 /Minecraft.Client/Common/GameRules/XboxStructureActionPlaceSpawner.cpp
parentdef8cb415354ac390b7e89052a50605285f1aca9 (diff)
Initial commit
Diffstat (limited to 'Minecraft.Client/Common/GameRules/XboxStructureActionPlaceSpawner.cpp')
-rw-r--r--Minecraft.Client/Common/GameRules/XboxStructureActionPlaceSpawner.cpp69
1 files changed, 69 insertions, 0 deletions
diff --git a/Minecraft.Client/Common/GameRules/XboxStructureActionPlaceSpawner.cpp b/Minecraft.Client/Common/GameRules/XboxStructureActionPlaceSpawner.cpp
new file mode 100644
index 00000000..1eca3342
--- /dev/null
+++ b/Minecraft.Client/Common/GameRules/XboxStructureActionPlaceSpawner.cpp
@@ -0,0 +1,69 @@
+#include "stdafx.h"
+#include "..\..\..\Minecraft.World\StringHelpers.h"
+#include "XboxStructureActionPlaceSpawner.h"
+#include "..\..\..\Minecraft.World\net.minecraft.world.level.levelgen.structure.h"
+#include "..\..\..\Minecraft.World\net.minecraft.world.level.h"
+#include "..\..\..\Minecraft.World\net.minecraft.world.level.tile.entity.h"
+
+XboxStructureActionPlaceSpawner::XboxStructureActionPlaceSpawner()
+{
+ m_tile = Tile::mobSpawner_Id;
+ m_entityId = L"Pig";
+}
+
+XboxStructureActionPlaceSpawner::~XboxStructureActionPlaceSpawner()
+{
+}
+
+void XboxStructureActionPlaceSpawner::writeAttributes(DataOutputStream *dos, UINT numAttrs)
+{
+ XboxStructureActionPlaceBlock::writeAttributes(dos, numAttrs + 1);
+
+ ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_entity);
+ dos->writeUTF(m_entityId);
+}
+
+void XboxStructureActionPlaceSpawner::addAttribute(const wstring &attributeName, const wstring &attributeValue)
+{
+ if(attributeName.compare(L"entity") == 0)
+ {
+ m_entityId = attributeValue;
+#ifndef _CONTENT_PACKAGE
+ wprintf(L"XboxStructureActionPlaceSpawner: Adding parameter entity=%ls\n",m_entityId.c_str());
+#endif
+ }
+ else
+ {
+ XboxStructureActionPlaceBlock::addAttribute(attributeName, attributeValue);
+ }
+}
+
+bool XboxStructureActionPlaceSpawner::placeSpawnerInLevel(StructurePiece *structure, Level *level, BoundingBox *chunkBB)
+{
+ int worldX = structure->getWorldX( m_x, m_z );
+ int worldY = structure->getWorldY( m_y );
+ int worldZ = structure->getWorldZ( m_x, m_z );
+
+ if ( chunkBB->isInside( worldX, worldY, worldZ ) )
+ {
+ if ( level->getTileEntity( worldX, worldY, worldZ ) != NULL )
+ {
+ // Remove the current tile entity
+ level->removeTileEntity( worldX, worldY, worldZ );
+ level->setTile( worldX, worldY, worldZ, 0 );
+ }
+
+ level->setTile( worldX, worldY, worldZ, m_tile );
+ shared_ptr<MobSpawnerTileEntity> entity = dynamic_pointer_cast<MobSpawnerTileEntity>(level->getTileEntity( worldX, worldY, worldZ ));
+
+#ifndef _CONTENT_PACKAGE
+ wprintf(L"XboxStructureActionPlaceSpawner - placing a %ls spawner at (%d,%d,%d)\n", m_entityId.c_str(), worldX, worldY, worldZ);
+#endif
+ if( entity != NULL )
+ {
+ entity->setEntityId(m_entityId);
+ }
+ return true;
+ }
+ return false;
+} \ No newline at end of file