Skip to content
This repository was archived by the owner on Jun 3, 2024. It is now read-only.

Add FakePlayer#77

Closed
qouteall wants to merge 4 commits intoPatchworkMC:masterfrom
qouteall:fakeplayer
Closed

Add FakePlayer#77
qouteall wants to merge 4 commits intoPatchworkMC:masterfrom
qouteall:fakeplayer

Conversation

@qouteall
Copy link
Contributor

@qouteall qouteall commented Jun 6, 2020

No description provided.

@TheGlitch76
Copy link
Member

Isn't there a factory that is needed to actually construct the player?
Are there any patches that are related to the player?

@qouteall qouteall marked this pull request as draft June 10, 2020 00:25
@qouteall qouteall marked this pull request as ready for review June 11, 2020 09:48
Copy link
Member

@TheGlitch76 TheGlitch76 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@TheGlitch76 TheGlitch76 requested a review from coderbot16 June 12, 2020 01:23
Copy link
Member

@coderbot16 coderbot16 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks good overall, but can you please move it to a separate patchwork-fake-players module?

Comment on lines +54 to +59
if (!fakePlayers.containsKey(username)) {
FakePlayer fakePlayer = new FakePlayer(world, username);
fakePlayers.put(username, fakePlayer);
}

return fakePlayers.get(username);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK this should do the same thing

Suggested change
if (!fakePlayers.containsKey(username)) {
FakePlayer fakePlayer = new FakePlayer(world, username);
fakePlayers.put(username, fakePlayer);
}
return fakePlayers.get(username);
return fakePlayers.computeIfAbsent(username, $ -> new FakePlayer(world, username));

public static void unloadWorld(ServerWorld world) {
fakePlayers.entrySet().removeIf(entry -> entry.getValue().world == world);

// This shouldn't be strictly necessary, but lets be aggressive.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// This shouldn't be strictly necessary, but lets be aggressive.
// This shouldn't be strictly necessary, but let's be aggressive.

import net.minecraft.text.Text;
import net.minecraft.util.math.Vec3d;

//Preliminary, simple Fake Player class
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//Preliminary, simple Fake Player class
// Preliminary, simple Fake Player class

Comment on lines +66 to +72
if (MINECRAFT_PLAYER != null && MINECRAFT_PLAYER.get() != null && MINECRAFT_PLAYER.get().world == world) {
FakePlayer mc = MINECRAFT_PLAYER.get();

if (mc != null && mc.world == world) {
MINECRAFT_PLAYER = null;
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (MINECRAFT_PLAYER != null && MINECRAFT_PLAYER.get() != null && MINECRAFT_PLAYER.get().world == world) {
FakePlayer mc = MINECRAFT_PLAYER.get();
if (mc != null && mc.world == world) {
MINECRAFT_PLAYER = null;
}
}
if (MINECRAFT_PLAYER == null) {
return;
}
FakePlayer mc = MINECRAFT_PLAYER.get();
if (mc != null && mc.world == world) {
MINECRAFT_PLAYER = null;
}

@TheGlitch76 TheGlitch76 self-requested a review June 18, 2020 00:51
@TheGlitch76 TheGlitch76 added the in progress This is being worked on and is not ready for final review label Jun 23, 2020
@qouteall qouteall closed this Jul 21, 2020
@williambl williambl mentioned this pull request Aug 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

in progress This is being worked on and is not ready for final review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants