-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 新增原版的区块 TileEntity 状态判断优化。 - 新增原版的区块 TileEntity 队列数据结构优化。 - 新增 Forge 的 ForgeChunkManager#getPersistentChunksIterableFor 优化。 - 新增 Botania 的数个方块实体优化。 - 改进 IC2 的 MixinGridUpdater 的计算速度。 - 修复 IC2 的 MixinReflectionUtil 不起作用的问题。 - 新增服务端线程优先级优化。
- Loading branch information
1 parent
6112430
commit 6f07a35
Showing
28 changed files
with
709 additions
and
68 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
129 changes: 129 additions & 0 deletions
129
src/main/java/github/kasuminova/stellarcore/common/util/BlockPosSet.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
package github.kasuminova.stellarcore.common.util; | ||
|
||
import com.google.common.collect.Iterators; | ||
import it.unimi.dsi.fastutil.longs.LongIterator; | ||
import it.unimi.dsi.fastutil.longs.LongOpenHashSet; | ||
import it.unimi.dsi.fastutil.longs.LongSet; | ||
import net.minecraft.util.math.BlockPos; | ||
|
||
import javax.annotation.Nonnull; | ||
import java.util.Collection; | ||
import java.util.Iterator; | ||
import java.util.Set; | ||
|
||
public class BlockPosSet implements Set<BlockPos> { | ||
|
||
protected final LongSet internal = new LongOpenHashSet(); | ||
|
||
@Override | ||
public int size() { | ||
return internal.size(); | ||
} | ||
|
||
@Override | ||
public boolean isEmpty() { | ||
return internal.isEmpty(); | ||
} | ||
|
||
@Override | ||
public boolean contains(final Object o) { | ||
if (o instanceof BlockPos) { | ||
return internal.contains(((BlockPos) o).toLong()); | ||
} | ||
return false; | ||
} | ||
|
||
@Nonnull | ||
@Override | ||
public Iterator<BlockPos> iterator() { | ||
return Iterators.transform(internal.iterator(), BlockPos::fromLong); | ||
} | ||
|
||
@Nonnull | ||
@Override | ||
public BlockPos[] toArray() { | ||
final BlockPos[] arr = new BlockPos[internal.size()]; | ||
final LongIterator it = internal.iterator(); | ||
int i = 0; | ||
while (it.hasNext()) { | ||
arr[i] = BlockPos.fromLong(it.nextLong()); | ||
i++; | ||
} | ||
return arr; | ||
} | ||
|
||
@Nonnull | ||
@Override | ||
@SuppressWarnings("unchecked") | ||
public <T> T[] toArray(final T[] a) { | ||
if (a.length < internal.size()) { | ||
return (T[]) toArray(); | ||
} | ||
final LongIterator it = internal.iterator(); | ||
int i = 0; | ||
while (it.hasNext()) { | ||
a[i] = (T) BlockPos.fromLong(it.nextLong()); | ||
i++; | ||
} | ||
return a; | ||
} | ||
|
||
@Override | ||
public boolean add(final BlockPos pos) { | ||
return internal.add(pos.toLong()); | ||
} | ||
|
||
@Override | ||
public boolean remove(final Object o) { | ||
if (o instanceof BlockPos) { | ||
return internal.remove(((BlockPos) o).toLong()); | ||
} | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean containsAll(final Collection<?> c) { | ||
for (final Object o : c) { | ||
if (!contains(o)) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean addAll(final Collection<? extends BlockPos> c) { | ||
for (final BlockPos pos : c) { | ||
add(pos); | ||
} | ||
return !c.isEmpty(); | ||
} | ||
|
||
@Override | ||
public boolean retainAll(final Collection<?> c) { | ||
boolean modified = false; | ||
Iterator<BlockPos> it = iterator(); | ||
while (it.hasNext()) { | ||
if (!c.contains(it.next())) { | ||
it.remove(); | ||
modified = true; | ||
} | ||
} | ||
return modified; | ||
} | ||
|
||
@Override | ||
public boolean removeAll(final Collection<?> c) { | ||
boolean modified = false; | ||
for (final Object o : c) { | ||
modified = remove(o); | ||
} | ||
return modified; | ||
} | ||
|
||
@Override | ||
public void clear() { | ||
internal.clear(); | ||
} | ||
|
||
} |
This file contains 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
This file contains 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
Oops, something went wrong.