Remove unnecessary cast

This commit is contained in:
TheMode 2021-07-09 11:23:18 +02:00
parent 37ab206cb1
commit b546a873e3
4 changed files with 5 additions and 15 deletions

View File

@ -17,7 +17,7 @@ public class PerChunkThreadProvider extends ThreadProvider {
}
@Override
public long findThread(@NotNull Chunk chunk) {
public int findThread(@NotNull Chunk chunk) {
return chunk.hashCode();
}

View File

@ -18,7 +18,7 @@ public class PerInstanceThreadProvider extends ThreadProvider {
}
@Override
public long findThread(@NotNull Chunk chunk) {
public int findThread(@NotNull Chunk chunk) {
return chunk.getInstance().hashCode();
}

View File

@ -13,7 +13,7 @@ public class SingleThreadProvider extends ThreadProvider {
}
@Override
public long findThread(@NotNull Chunk chunk) {
public int findThread(@NotNull Chunk chunk) {
return 0;
}

View File

@ -69,7 +69,7 @@ public abstract class ThreadProvider {
*
* @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.
@ -245,7 +245,7 @@ public abstract class ThreadProvider {
private @NotNull ChunkEntry setChunkThread(@NotNull Chunk chunk,
@NotNull Function<TickThread, ChunkEntry> chunkEntrySupplier) {
final int threadId = getThreadId(chunk);
final int threadId = Math.abs(findThread(chunk)) % threads.size();
TickThread thread = threads.get(threadId);
var chunks = threadChunkMap.computeIfAbsent(thread, tickThread -> ConcurrentHashMap.newKeySet());
@ -267,16 +267,6 @@ public abstract class ThreadProvider {
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() {
if (removedEntities.isEmpty())
return;