the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 67 lines 1.7 kB view raw
1#include "stdafx.h" 2#include "net.minecraft.world.level.h" 3#include "net.minecraft.world.phys.h" 4#include "net.minecraft.world.entity.animal.h" 5#include "net.minecraft.world.damagesource.h" 6#include "com.mojang.nbt.h" 7#include "ThrownEgg.h" 8#include "MobCategory.h" 9 10 11 12void ThrownEgg::_init() 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 19ThrownEgg::ThrownEgg(Level *level) : Throwable(level) 20{ 21 _init(); 22} 23 24ThrownEgg::ThrownEgg(Level *level, shared_ptr<LivingEntity> mob) : Throwable(level,mob) 25{ 26 _init(); 27} 28 29ThrownEgg::ThrownEgg(Level *level, double x, double y, double z) : Throwable(level,x,y,z) 30{ 31 _init(); 32} 33 34void ThrownEgg::onHit(HitResult *res) 35{ 36 if (res->entity != NULL) 37 { 38 DamageSource *damageSource = DamageSource::thrown(shared_from_this(), owner); 39 res->entity->hurt(damageSource, 0); 40 delete damageSource; 41 } 42 if (!level->isClientSide && random->nextInt(8) == 0) 43 { 44 if(level->canCreateMore( eTYPE_CHICKEN, Level::eSpawnType_Breed) ) // 4J - added limit for number of chickens in world 45 { 46 int count = 1; 47 if (random->nextInt(32) == 0) count = 4; 48 for (int i = 0; i < count; i++) 49 { 50 shared_ptr<Chicken> chicken = shared_ptr<Chicken>( new Chicken(level) ); 51 chicken->setAge(-20 * 60 * 20); 52 53 chicken->moveTo(x, y, z, yRot, 0); 54 chicken->setDespawnProtected(); // 4J added, default to being protected against despawning 55 level->addEntity(chicken); 56 } 57 } 58 } 59 60 for (int i = 0; i < 8; i++) 61 level->addParticle(eParticleType_snowballpoof, x, y, z, 0, 0, 0); 62 63 if (!level->isClientSide) 64 { 65 remove(); 66 } 67}