the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#include "stdafx.h"
2#include "net.minecraft.world.phys.h"
3#include "net.minecraft.world.damagesource.h"
4#include "net.minecraft.world.entity.h"
5#include "net.minecraft.world.level.h"
6#include "..\Minecraft.Client\ServerPlayer.h"
7#include "..\Minecraft.Client\PlayerConnection.h"
8#include "ThrownEnderpearl.h"
9
10
11
12ThrownEnderpearl::ThrownEnderpearl(Level *level) : Throwable(level)
13{
14 // 4J Stu - This function call had to be moved here from the Entity ctor to ensure that
15 // the derived version of the function is called
16 this->defineSynchedData();
17}
18
19ThrownEnderpearl::ThrownEnderpearl(Level *level, shared_ptr<LivingEntity> mob) : Throwable(level,mob)
20{
21 // 4J Stu - This function call had to be moved here from the Entity ctor to ensure that
22 // the derived version of the function is called
23 this->defineSynchedData();
24}
25
26ThrownEnderpearl::ThrownEnderpearl(Level *level, double x, double y, double z) : Throwable(level,x,y,z)
27{
28 // 4J Stu - This function call had to be moved here from the Entity ctor to ensure that
29 // the derived version of the function is called
30 this->defineSynchedData();
31}
32
33void ThrownEnderpearl::onHit(HitResult *res)
34{
35 if (res->entity != NULL)
36 {
37 DamageSource *damageSource = DamageSource::thrown(shared_from_this(), getOwner() );
38 res->entity->hurt(damageSource, 0);
39 delete damageSource;
40 }
41 for (int i = 0; i < 32; i++)
42 {
43 level->addParticle(eParticleType_ender, x, y + random->nextDouble() * 2, z, random->nextGaussian(), 0, random->nextGaussian());
44 }
45
46 if (!level->isClientSide)
47 {
48 // Fix for #67486 - TCR #001: BAS Game Stability: Customer Encountered: TU8: Code: Gameplay: The title crashes on Host's console when Client Player leaves the game before the Ender Pearl thrown by him touches the ground.
49 // If the owner has been removed, then ignore
50
51 // 4J-JEV: Cheap type check first.
52 if ( (getOwner() != NULL) && getOwner()->instanceof(eTYPE_SERVERPLAYER) )
53 {
54 shared_ptr<ServerPlayer> serverPlayer = dynamic_pointer_cast<ServerPlayer>(getOwner() );
55 if (!serverPlayer->removed)
56 {
57 if(!serverPlayer->connection->done && serverPlayer->level == this->level)
58 {
59 if (getOwner()->isRiding())
60 {
61 getOwner()->ride(nullptr);
62 }
63 getOwner()->teleportTo(x, y, z);
64 getOwner()->fallDistance = 0;
65 getOwner()->hurt(DamageSource::fall, 5);
66 }
67 }
68 }
69 remove();
70 }
71}