mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-04-24 15:23:37 +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
119 lines
3.1 KiB
C++
119 lines
3.1 KiB
C++
#include "../../Platform/stdafx.h"
|
|
#include <iostream>
|
|
#include "../../IO/Streams/InputOutputStream.h"
|
|
#include "../../Headers/net.minecraft.world.level.h"
|
|
#include "PacketListener.h"
|
|
#include "ExplodePacket.h"
|
|
|
|
ExplodePacket::ExplodePacket() {
|
|
x = 0;
|
|
y = 0;
|
|
z = 0;
|
|
r = 0.0f;
|
|
m_bKnockbackOnly = false;
|
|
knockbackX = 0.0f;
|
|
knockbackY = 0.0f;
|
|
knockbackZ = 0.0f;
|
|
}
|
|
|
|
ExplodePacket::ExplodePacket(
|
|
double x, double y, double z, float r,
|
|
std::unordered_set<TilePos, TilePosKeyHash, TilePosKeyEq>* toBlow,
|
|
Vec3* knockback, bool knockBackOnly) {
|
|
this->x = x;
|
|
this->y = y;
|
|
this->z = z;
|
|
this->r = r;
|
|
m_bKnockbackOnly = knockBackOnly;
|
|
|
|
if (toBlow != nullptr) {
|
|
this->toBlow.assign(toBlow->begin(), toBlow->end());
|
|
// for( auto it = toBlow->begin(); it != toBlow->end(); it++ )
|
|
//{
|
|
// this->toBlow.push_back(*it);
|
|
// }
|
|
}
|
|
|
|
if (knockback != nullptr) {
|
|
knockbackX = (float)knockback->x;
|
|
knockbackY = (float)knockback->y;
|
|
knockbackZ = (float)knockback->z;
|
|
}
|
|
}
|
|
|
|
void ExplodePacket::read(DataInputStream* dis) // throws IOException
|
|
{
|
|
m_bKnockbackOnly = dis->readBoolean();
|
|
|
|
if (!m_bKnockbackOnly) {
|
|
x = dis->readDouble();
|
|
y = dis->readDouble();
|
|
z = dis->readDouble();
|
|
r = dis->readFloat();
|
|
int count = dis->readInt();
|
|
|
|
int xp = (int)x;
|
|
int yp = (int)y;
|
|
int zp = (int)z;
|
|
for (int i = 0; i < count; i++) {
|
|
int xx = ((signed char)dis->readByte()) + xp;
|
|
int yy = ((signed char)dis->readByte()) + yp;
|
|
int zz = ((signed char)dis->readByte()) + zp;
|
|
toBlow.push_back(TilePos(xx, yy, zz));
|
|
}
|
|
}
|
|
|
|
knockbackX = dis->readFloat();
|
|
knockbackY = dis->readFloat();
|
|
knockbackZ = dis->readFloat();
|
|
}
|
|
|
|
void ExplodePacket::write(DataOutputStream* dos) // throws IOException
|
|
{
|
|
dos->writeBoolean(m_bKnockbackOnly);
|
|
|
|
if (!m_bKnockbackOnly) {
|
|
dos->writeDouble(x);
|
|
dos->writeDouble(y);
|
|
dos->writeDouble(z);
|
|
dos->writeFloat(r);
|
|
dos->writeInt((int)toBlow.size());
|
|
|
|
int xp = (int)x;
|
|
int yp = (int)y;
|
|
int zp = (int)z;
|
|
|
|
//(Myset::const_iterator it = c1.begin();
|
|
// it != c1.end(); ++it)
|
|
|
|
for (auto it = toBlow.begin(); it != toBlow.end(); it++) {
|
|
TilePos tp = *it;
|
|
|
|
int xx = tp.x - xp;
|
|
int yy = tp.y - yp;
|
|
int zz = tp.z - zp;
|
|
dos->writeByte((uint8_t)xx);
|
|
dos->writeByte((uint8_t)yy);
|
|
dos->writeByte((uint8_t)zz);
|
|
}
|
|
}
|
|
|
|
dos->writeFloat(knockbackX);
|
|
dos->writeFloat(knockbackY);
|
|
dos->writeFloat(knockbackZ);
|
|
}
|
|
|
|
void ExplodePacket::handle(PacketListener* listener) {
|
|
listener->handleExplosion(shared_from_this());
|
|
}
|
|
|
|
int ExplodePacket::getEstimatedSize() {
|
|
return 8 * 3 + 4 + 4 + (int)toBlow.size() * 3 + 12;
|
|
}
|
|
|
|
float ExplodePacket::getKnockbackX() { return knockbackX; }
|
|
|
|
float ExplodePacket::getKnockbackY() { return knockbackY; }
|
|
|
|
float ExplodePacket::getKnockbackZ() { return knockbackZ; }
|