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.h"
3#include "net.minecraft.world.damagesource.h"
4#include "net.minecraft.world.effect.h"
5#include "net.minecraft.world.entity.h"
6#include "net.minecraft.world.level.h"
7#include "net.minecraft.world.level.tile.h"
8#include "net.minecraft.world.phys.h"
9#include "WitherSkull.h"
10
11WitherSkull::WitherSkull(Level *level) : Fireball(level)
12{
13 defineSynchedData();
14
15 setSize(5 / 16.0f, 5 / 16.0f);
16}
17
18WitherSkull::WitherSkull(Level *level, shared_ptr<LivingEntity> mob, double xa, double ya, double za) : Fireball(level, mob, xa, ya, za)
19{
20 defineSynchedData();
21
22 setSize(5 / 16.0f, 5 / 16.0f);
23}
24
25float WitherSkull::getInertia()
26{
27 return isDangerous() ? 0.73f : Fireball::getInertia();
28}
29
30WitherSkull::WitherSkull(Level *level, double x, double y, double z, double xa, double ya, double za) : Fireball(level, x, y, z, xa, ya, za)
31{
32 defineSynchedData();
33
34 setSize(5 / 16.0f, 5 / 16.0f);
35}
36
37bool WitherSkull::isOnFire()
38{
39 return false;
40}
41
42float WitherSkull::getTileExplosionResistance(Explosion *explosion, Level *level, int x, int y, int z, Tile *tile)
43{
44 float result = Fireball::getTileExplosionResistance(explosion, level, x, y, z, tile);
45
46 if (isDangerous() && tile != Tile::unbreakable && tile != Tile::endPortalTile && tile != Tile::endPortalFrameTile)
47 {
48 result = min(0.8f, result);
49 }
50
51 return result;
52}
53
54void WitherSkull::onHit(HitResult *res)
55{
56 if (!level->isClientSide)
57 {
58 if (res->entity != NULL)
59 {
60 if (owner != NULL)
61 {
62 DamageSource *damageSource = DamageSource::mobAttack(owner);
63 if (res->entity->hurt(damageSource, 8))
64 {
65 if (!res->entity->isAlive())
66 {
67 owner->heal(5);
68 }
69 }
70 delete damageSource;
71 }
72 else
73 {
74 res->entity->hurt(DamageSource::magic, 5);
75 }
76 if ( res->entity->instanceof(eTYPE_LIVINGENTITY) )
77 {
78 int witherSeconds = 0;
79 if (level->difficulty <= Difficulty::EASY)
80 {
81 // Nothing
82 }
83 else if (level->difficulty == Difficulty::NORMAL)
84 {
85 witherSeconds = 10;
86 }
87 else if (level->difficulty == Difficulty::HARD)
88 {
89 witherSeconds = 40;
90 }
91 if (witherSeconds > 0)
92 {
93 dynamic_pointer_cast<LivingEntity>( res->entity )->addEffect(new MobEffectInstance(MobEffect::wither->id, SharedConstants::TICKS_PER_SECOND * witherSeconds, 1));
94 }
95 }
96 }
97 level->explode(shared_from_this(), x, y, z, 1, false, level->getGameRules()->getBoolean(GameRules::RULE_MOBGRIEFING));
98 remove();
99 }
100}
101
102bool WitherSkull::isPickable()
103{
104 return false;
105}
106
107bool WitherSkull::hurt(DamageSource *source, float damage)
108{
109 return false;
110}
111
112void WitherSkull::defineSynchedData()
113{
114 entityData->define(DATA_DANGEROUS, (byte) 0);
115}
116
117bool WitherSkull::isDangerous()
118{
119 return entityData->getByte(DATA_DANGEROUS) == 1;
120}
121
122void WitherSkull::setDangerous(bool value)
123{
124 entityData->set(DATA_DANGEROUS, value ? (byte) 1 : (byte) 0);
125}
126
127bool WitherSkull::shouldBurn()
128{
129 return false;
130}