MCPcopy Create free account
hub / github.com/cuberite/cuberite / MirrorXZ

Method MirrorXZ

src/BlockArea.cpp:1177–1211  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1175
1176
1177void cBlockArea::MirrorXZ(void)
1178{
1179 if (!HasBlockTypes())
1180 {
1181 LOGWARNING("cBlockArea: Cannot mirror meta without blocktypes!");
1182 return;
1183 }
1184
1185 if (!HasBlockMetas())
1186 {
1187 // There are no blockmetas to mirror, just use the NoMeta function
1188 MirrorXZNoMeta();
1189 return;
1190 }
1191
1192 // We are guaranteed that both blocktypes and blockmetas exist; mirror both at the same time:
1193 int HalfY = m_Size.y / 2;
1194 int MaxY = m_Size.y - 1;
1195 for (int y = 0; y < HalfY; y++)
1196 {
1197 for (int z = 0; z < m_Size.z; z++)
1198 {
1199 for (int x = 0; x < m_Size.x; x++)
1200 {
1201 int Idx1 = MakeIndex(x, y, z);
1202 int Idx2 = MakeIndex(x, MaxY - y, z);
1203 std::swap(m_BlockTypes[Idx1], m_BlockTypes[Idx2]);
1204 NIBBLETYPE Meta1 = BlockHandler(m_BlockTypes[Idx2])->MetaMirrorXZ(m_BlockMetas[Idx1]);
1205 NIBBLETYPE Meta2 = BlockHandler(m_BlockTypes[Idx1])->MetaMirrorXZ(m_BlockMetas[Idx2]);
1206 m_BlockMetas[Idx1] = Meta2;
1207 m_BlockMetas[Idx2] = Meta1;
1208 } // for x
1209 } // for z
1210 } // for y
1211}
1212
1213
1214

Callers

nothing calls this directly

Calls 2

BlockHandlerFunction · 0.85
MetaMirrorXZMethod · 0.45

Tested by

no test coverage detected