-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: remove deprecated Chunk#getPosition(Vector3i) #4888
chore: remove deprecated Chunk#getPosition(Vector3i) #4888
Conversation
6e6c2ce
to
afeb97c
Compare
Why are so many of the calls to Maybe that's related to your question about how defensive the code needs to be, but I'm not quite connecting the dots. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should add to the description in
Terasology/engine/src/main/java/org/terasology/engine/world/chunks/Chunk.java
Lines 25 to 28 in f85be6d
/** | |
* @return Position of the chunk in world, where units of distance from origin are chunks | |
*/ | |
Vector3ic getPosition(); |
Also, I'm wondering whether some of the new Vector3i(...)
allocations are just because some other API demands to pass in a mutable Vector3i
instead of a immutable Vecor3ic
.
Where possible, we should fix those APIs to work with the immutable type instead. We can likely do that in smaller batches and thereby make better use of Chunk#getPosition()
.
@@ -33,7 +32,7 @@ public TestStorageManager(Map<Vector3ic, ChunkStore> chunkStores) { | |||
} | |||
|
|||
public void add(Chunk chunk) { | |||
chunkStores.put(chunk.getPosition(new Vector3i()), new TestChunkStore(chunk)); | |||
chunkStores.put(chunk.getPosition(), new TestChunkStore(chunk)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, we often recommend to create a copy when storing vectors in a map, but I guess for chunk position it is fine to assume the position to be constant and stable for a chunk, not changing ever. 🤔
engine/src/main/java/org/terasology/engine/monitoring/chunk/ChunkMonitor.java
Outdated
Show resolved
Hide resolved
…re/remove-deprecated-getPositision-Chunk
…re/remove-deprecated-getPositision-Chunk
those shouldn't be wrapped in a new |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does look much better without the extra new Vector
s. 👍 Just once left I wasn't sure about.
I noticed a signature change on fireChunkTessellated, but it looks like there's only one call site for that and it did get updated, so that part seems good too.
engine/src/main/java/org/terasology/engine/entitySystem/sectors/SectorUtil.java
Show resolved
Hide resolved
Currently being held by CI for some unused code checks. I recommend turning on IntelliJ's “optimize imports on the fly“ setting—or, if you don't like it doing stuff on the fly, at least the “optimize imports“ option in the “before commit“ section. |
we've had this method depreacted for a while in Chunk, I made sure to have the Vector3i that's allocated in Chunk fixed in place so once allocated we won't be able to modify the position of a chunk. do you think we should be a bit more defensive @keturn :?