mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-06 16:37:38 +01:00
Remove unnecessary cast
This commit is contained in:
parent
37ab206cb1
commit
b546a873e3
@ -17,7 +17,7 @@ public class PerChunkThreadProvider extends ThreadProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long findThread(@NotNull Chunk chunk) {
|
public int findThread(@NotNull Chunk chunk) {
|
||||||
return chunk.hashCode();
|
return chunk.hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ public class PerInstanceThreadProvider extends ThreadProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long findThread(@NotNull Chunk chunk) {
|
public int findThread(@NotNull Chunk chunk) {
|
||||||
return chunk.getInstance().hashCode();
|
return chunk.getInstance().hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ public class SingleThreadProvider extends ThreadProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long findThread(@NotNull Chunk chunk) {
|
public int findThread(@NotNull Chunk chunk) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ public abstract class ThreadProvider {
|
|||||||
*
|
*
|
||||||
* @param chunk the chunk
|
* @param chunk the chunk
|
||||||
*/
|
*/
|
||||||
public abstract long findThread(@NotNull Chunk chunk);
|
public abstract int findThread(@NotNull Chunk chunk);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines how often chunks thread should be updated.
|
* Defines how often chunks thread should be updated.
|
||||||
@ -245,7 +245,7 @@ public abstract class ThreadProvider {
|
|||||||
|
|
||||||
private @NotNull ChunkEntry setChunkThread(@NotNull Chunk chunk,
|
private @NotNull ChunkEntry setChunkThread(@NotNull Chunk chunk,
|
||||||
@NotNull Function<TickThread, ChunkEntry> chunkEntrySupplier) {
|
@NotNull Function<TickThread, ChunkEntry> chunkEntrySupplier) {
|
||||||
final int threadId = getThreadId(chunk);
|
final int threadId = Math.abs(findThread(chunk)) % threads.size();
|
||||||
TickThread thread = threads.get(threadId);
|
TickThread thread = threads.get(threadId);
|
||||||
var chunks = threadChunkMap.computeIfAbsent(thread, tickThread -> ConcurrentHashMap.newKeySet());
|
var chunks = threadChunkMap.computeIfAbsent(thread, tickThread -> ConcurrentHashMap.newKeySet());
|
||||||
|
|
||||||
@ -267,16 +267,6 @@ public abstract class ThreadProvider {
|
|||||||
this.chunks.remove(chunk);
|
this.chunks.remove(chunk);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Finds the thread id associated to a {@link Chunk}.
|
|
||||||
*
|
|
||||||
* @param chunk the chunk to find the thread id from
|
|
||||||
* @return the chunk thread id
|
|
||||||
*/
|
|
||||||
private int getThreadId(@NotNull Chunk chunk) {
|
|
||||||
return (int) (Math.abs(findThread(chunk)) % threads.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void processRemovedEntities() {
|
private void processRemovedEntities() {
|
||||||
if (removedEntities.isEmpty())
|
if (removedEntities.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user