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
Conversation
Member
|
Isn't there a factory that is needed to actually construct the player? |
TheGlitch76
reviewed
Jun 9, 2020
patchwork-extensions/src/main/java/net/minecraftforge/common/util/FakePlayer.java
Outdated
Show resolved
Hide resolved
coderbot16
suggested changes
Jun 12, 2020
Member
coderbot16
left a comment
There was a problem hiding this comment.
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); |
Member
There was a problem hiding this comment.
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. |
Member
There was a problem hiding this comment.
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 |
Member
There was a problem hiding this comment.
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; | ||
| } | ||
| } |
Member
There was a problem hiding this comment.
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; | |
| } |
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.