mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-18 12:05:14 -04:00
Fix changing own skin with /skin deleting texture shared by other entities with same old skin. (Thanks Empy)
This commit is contained in:
parent
4115a0d950
commit
22f1fbbd79
@ -48,9 +48,15 @@ namespace ClassicalSharp.Network {
|
||||
game.Entities[id] = new NetPlayer(displayName, skinName, game, id);
|
||||
game.EntityEvents.RaiseAdded(id);
|
||||
} else {
|
||||
game.LocalPlayer.DisplayName = displayName;
|
||||
game.LocalPlayer.SkinName = skinName;
|
||||
game.LocalPlayer.Despawn();
|
||||
// Always reset the texture here, in case other network players are using the same skin as us.
|
||||
// In that case, we don't want the fetching of new skin for us to delete the texture used by them.
|
||||
game.LocalPlayer.TextureId = -1;
|
||||
game.LocalPlayer.MobTextureId = -1;
|
||||
game.LocalPlayer.fetchedSkin = false;
|
||||
|
||||
game.LocalPlayer.DisplayName = displayName;
|
||||
game.LocalPlayer.SkinName = skinName;
|
||||
game.LocalPlayer.UpdateName();
|
||||
}
|
||||
|
||||
|
45
src/Client/Picking.c
Normal file
45
src/Client/Picking.c
Normal file
@ -0,0 +1,45 @@
|
||||
#include "Picking.h"
|
||||
#include "ExtMath.h"
|
||||
|
||||
Real32 PickedPos_dist;
|
||||
void PickedPos_TestAxis(PickedPos* pos, Real32 dAxis, Face fAxis) {
|
||||
dAxis = Math_AbsF(dAxis);
|
||||
if (dAxis >= PickedPos_dist) return;
|
||||
|
||||
PickedPos_dist = dAxis;
|
||||
pos->ClosestFace = fAxis;
|
||||
}
|
||||
|
||||
void PickedPos_SetAsValid(PickedPos* pos, Int32 x, Int32 y, Int32 z,
|
||||
Vector3 min, Vector3 max, BlockID block, Vector3 intersect) {
|
||||
pos->Min = min; pos->Max = max;
|
||||
pos->BlockPos = Vector3I_Create3(x, y, z);
|
||||
pos->Valid = true;
|
||||
pos->Block = block;
|
||||
pos->Intersect = intersect;
|
||||
|
||||
PickedPos_dist = 1000000000.0f;
|
||||
PickedPos_TestAxis(pos, intersect.X - min.X, Face_XMin);
|
||||
PickedPos_TestAxis(pos, intersect.X - max.X, Face_XMax);
|
||||
PickedPos_TestAxis(pos, intersect.Y - min.Y, Face_YMin);
|
||||
PickedPos_TestAxis(pos, intersect.Y - max.Y, Face_YMax);
|
||||
PickedPos_TestAxis(pos, intersect.Z - min.Z, Face_ZMin);
|
||||
PickedPos_TestAxis(pos, intersect.Z - max.Z, Face_ZMax);
|
||||
|
||||
Vector3I offsets[Face_Count];
|
||||
offsets[Face_XMin] = Vector3I_Create3(-1, 0, 0);
|
||||
offsets[Face_XMax] = Vector3I_Create3(+1, 0, 0);
|
||||
offsets[Face_ZMin] = Vector3I_Create3(0, 0, -1);
|
||||
offsets[Face_ZMax] = Vector3I_Create3(0, 0, +1);
|
||||
offsets[Face_YMin] = Vector3I_Create3(0, -1, 0);
|
||||
offsets[Face_YMax] = Vector3I_Create3(0, +1, 0);
|
||||
Vector3I_Add(&pos->TranslatedPos, &pos->BlockPos, &offsets[pos->ClosestFace]);
|
||||
}
|
||||
|
||||
void PickedPos_SetAsInvalid(PickedPos* pos) {
|
||||
pos->Valid = false;
|
||||
pos->BlockPos = Vector3I_MinusOne;
|
||||
pos->TranslatedPos = Vector3I_MinusOne;
|
||||
pos->ClosestFace = (Face)Face_Count;
|
||||
pos->Block = BlockID_Air;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user