Skip to content

Commit

Permalink
Merge pull request #1098 (Freecam fix) from ZANX3Y/fakeplayer-fix
Browse files Browse the repository at this point in the history
Fix FakePlayerEntity
  • Loading branch information
Alexander01998 authored Dec 29, 2024
2 parents 531549c + c2c0e8b commit 12ee764
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/main/java/net/wurstclient/util/FakePlayerEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,14 @@
*/
package net.wurstclient.util;

import java.util.UUID;

import org.jetbrains.annotations.Nullable;

import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.network.OtherClientPlayerEntity;
import net.minecraft.client.network.PlayerListEntry;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.entity.Entity;
import net.minecraft.entity.data.DataTracker;
Expand All @@ -19,10 +25,12 @@ public class FakePlayerEntity extends OtherClientPlayerEntity
{
private final ClientPlayerEntity player = WurstClient.MC.player;
private final ClientWorld world = WurstClient.MC.world;
private PlayerListEntry playerListEntry;

public FakePlayerEntity()
{
super(WurstClient.MC.world, WurstClient.MC.player.getGameProfile());
setUuid(UUID.randomUUID());
copyPositionAndRotation(player);

copyInventory();
Expand All @@ -33,6 +41,16 @@ public FakePlayerEntity()
spawn();
}

@Override
protected @Nullable PlayerListEntry getPlayerListEntry()
{
if(playerListEntry == null)
playerListEntry = MinecraftClient.getInstance().getNetworkHandler()
.getPlayerListEntry(getGameProfile().getId());

return playerListEntry;
}

private void copyInventory()
{
getInventory().clone(player.getInventory());
Expand Down

0 comments on commit 12ee764

Please sign in to comment.