the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 151 lines 3.6 kB view raw
1#include "stdafx.h" 2#include "RemotePlayer.h" 3#include "..\Minecraft.World\net.minecraft.world.item.h" 4#include "..\Minecraft.World\Mth.h" 5 6RemotePlayer::RemotePlayer(Level *level, const wstring& name) : Player(level, name) 7{ 8 // 4J - added initialisers 9 hasStartedUsingItem = false; 10 lSteps = 0; 11 lx = ly = lz = lyr = lxr = 0.0; 12 fallTime = 0.0f; 13 14 app.DebugPrintf("Created RemotePlayer with name %ls\n", name.c_str() ); 15 16 heightOffset = 0; 17 footSize = 0; 18 19 noPhysics = true; 20 21 bedOffsetY = 4 / 16.0f; 22 23 viewScale = 10; 24} 25 26void RemotePlayer::setDefaultHeadHeight() 27{ 28 heightOffset = 0; 29} 30 31bool RemotePlayer::hurt(DamageSource *source, float dmg) 32{ 33 return true; 34} 35 36void RemotePlayer::lerpTo(double x, double y, double z, float yRot, float xRot, int steps) 37{ 38// heightOffset = 0; 39 lx = x; 40 ly = y; 41 lz = z; 42 lyr = yRot; 43 lxr = xRot; 44 45 lSteps = steps; 46} 47 48void RemotePlayer::tick() 49{ 50 bedOffsetY = 0 / 16.0f; 51 Player::tick(); 52 53 walkAnimSpeedO = walkAnimSpeed; 54 double xxd = x - xo; 55 double zzd = z - zo; 56 float wst = Mth::sqrt(xxd * xxd + zzd * zzd) * 4; 57 if (wst > 1) wst = 1; 58 walkAnimSpeed += (wst - walkAnimSpeed) * 0.4f; 59 walkAnimPos += walkAnimSpeed; 60 61 if (!hasStartedUsingItem && isUsingItemFlag() && inventory->items[inventory->selected] != NULL) 62 { 63 shared_ptr<ItemInstance> item = inventory->items[inventory->selected]; 64 startUsingItem(inventory->items[inventory->selected], Item::items[item->id]->getUseDuration(item)); 65 hasStartedUsingItem = true; 66 } 67 else if (hasStartedUsingItem && !isUsingItemFlag()) 68 { 69 stopUsingItem(); 70 hasStartedUsingItem = false; 71 } 72 73 // if (eatItem != null) { 74 // if (eatItemTickCount <= 25 && eatItemTickCount % 4 == 0) { 75 // spawnEatParticles(eatItem, 5); 76 // } 77 // eatItemTickCount--; 78 // if (eatItemTickCount <= 0) { 79 // spawnEatParticles(eatItem, 16); 80 // swing(); 81 // eatItem = null; 82 // } 83 // } 84} 85 86float RemotePlayer::getShadowHeightOffs() 87{ 88 return 0; 89} 90 91void RemotePlayer::aiStep() 92{ 93 Player::serverAiStep(); 94 if (lSteps > 0) 95 { 96 double xt = x + (lx - x) / lSteps; 97 double yt = y + (ly - y) / lSteps; 98 double zt = z + (lz - z) / lSteps; 99 100 double yrd = lyr - yRot; 101 while (yrd < -180) 102 yrd += 360; 103 while (yrd >= 180) 104 yrd -= 360; 105 106 yRot += (float)((yrd) / lSteps); 107 xRot += (float)((lxr - xRot) / lSteps); 108 109 lSteps--; 110 setPos(xt, yt, zt); 111 setRot(yRot, xRot); 112 } 113 oBob = bob; 114 115 float tBob = (float) Mth::sqrt(xd * xd + zd * zd); 116 float tTilt = (float) atan(-yd * 0.2f) * 15.0f; 117 if (tBob > 0.1f) tBob = 0.1f; 118 if (!onGround || getHealth() <= 0) tBob = 0; 119 if (onGround || getHealth() <= 0) tTilt = 0; 120 bob += (tBob - bob) * 0.4f; 121 tilt += (tTilt - tilt) * 0.8f; 122 123} 124 125// 4J Stu - Brought forward change from 1.3 to fix #64688 - Customer Encountered: TU7: Content: Art: Aura of enchanted item is not displayed for other players in online game 126void RemotePlayer::setEquippedSlot(int slot, shared_ptr<ItemInstance> item) 127{ 128 if (slot == 0) 129 { 130 inventory->items[inventory->selected] = item; 131 } 132 else 133 { 134 inventory->armor[slot - 1] = item; 135 } 136} 137 138void RemotePlayer::animateRespawn() 139{ 140// Player.animateRespawn(this, level); 141} 142 143float RemotePlayer::getHeadHeight() 144{ 145 return 1.82f; 146} 147 148Pos RemotePlayer::getCommandSenderWorldPosition() 149{ 150 return new Pos(floor(x + .5), floor(y + .5), floor(z + .5)); 151}