Skip to content

Commit

Permalink
- CubicChunks 兼容。
Browse files Browse the repository at this point in the history
  • Loading branch information
KasumiNova committed Nov 2, 2024
1 parent 5a319af commit 8367380
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 9 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ plugins {

// Project properties
group = "github.kasuminova.stellarcore"
version = "1.5.15"
version = "1.5.16"

// Set the toolchain version to decouple the Java we run Gradle with from the Java used to compile and run the mod
java {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public enum Mods {
MM( "modularmachinery"),
EBWIZARDRY( "ebwizardry"),
LIB_NINE( "libnine"),
CUBIC_CHUNKS( "cubicchunks"),
MMCE( "modularmachinery", "github.kasuminova.mmce.mixin.MMCEEarlyMixinLoader"),
CENSORED_ASM( "loliasm", "zone.rong.loliasm.core.LoliLoadingPlugin"),
FERMIUM_OR_BLAHAJ_ASM("normalasm", "mirror.normalasm.core.NormalLoadingPlugin"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@

import com.github.bsideup.jabel.Desugar;
import com.google.common.collect.Iterators;
import github.kasuminova.stellarcore.common.mod.Mods;
import it.unimi.dsi.fastutil.ints.IntCollection;
import it.unimi.dsi.fastutil.longs.Long2IntMap;
import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap;
import it.unimi.dsi.fastutil.objects.AbstractObjectSet;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import it.unimi.dsi.fastutil.objects.ObjectIterator;
import it.unimi.dsi.fastutil.objects.ObjectSet;
import it.unimi.dsi.fastutil.objects.*;
import net.minecraft.util.math.BlockPos;

import javax.annotation.Nonnull;
Expand All @@ -22,6 +20,15 @@ public class BlockPos2IntMap implements Object2IntMap<BlockPos> {
protected EntrySet entrySet = null;
protected KeySet keySet = null;

@Nonnull
public static Object2IntMap<BlockPos> create() {
// Cubic chunks breaks the height limit.
if (Mods.CUBIC_CHUNKS.loaded()) {
return new Object2IntOpenHashMap<>();
}
return new BlockPos2IntMap();
}

@Nonnull
@Override
@SuppressWarnings({"unchecked", "rawtypes"})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package github.kasuminova.stellarcore.common.util;

import com.google.common.collect.Iterators;
import github.kasuminova.stellarcore.common.mod.Mods;
import it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap;
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap;
import net.minecraft.util.math.BlockPos;

import javax.annotation.Nonnull;
Expand All @@ -14,6 +16,15 @@ public class BlockPos2ValueMap<V> implements Map<BlockPos, V> {
protected EntrySet entrySet = null;
protected KeySet keySet = null;

@Nonnull
public static <V> Map<BlockPos, V> create() {
// Cubic chunks breaks the height limit.
if (Mods.CUBIC_CHUNKS.loaded()) {
return new Object2ObjectLinkedOpenHashMap<>();
}
return new BlockPos2ValueMap<>();
}

@Override
public int size() {
return internal.size();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package github.kasuminova.stellarcore.common.util;

import com.google.common.collect.Iterators;
import github.kasuminova.stellarcore.common.mod.Mods;
import it.unimi.dsi.fastutil.longs.LongIterator;
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
import it.unimi.dsi.fastutil.longs.LongSet;
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
import net.minecraft.util.math.BlockPos;

import javax.annotation.Nonnull;
Expand All @@ -15,6 +17,15 @@ public class BlockPosSet implements Set<BlockPos> {

protected final LongSet internal = new LongOpenHashSet();

@Nonnull
public static Set<BlockPos> create() {
// Cubic chunks breaks the height limit.
if (Mods.CUBIC_CHUNKS.loaded()) {
return new ObjectOpenHashSet<>();
}
return new BlockPosSet();
}

@Override
public int size() {
return internal.size();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
public class MixinTilePylon {

@Unique
private final Map<BlockPos, IBlockState> stellar_core$stateCache = new BlockPos2ValueMap<>();
private final Map<BlockPos, IBlockState> stellar_core$stateCache = BlockPos2ValueMap.create();

@Inject(method = "update", at = {@At("HEAD"), @At("RETURN")})
private void injectUpdateStartAndEnd(final CallbackInfo ci) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ private void injectInit(final CallbackInfo ci) {
if (!StellarCoreConfig.PERFORMANCE.industrialCraft2.energyNetLocal) {
return;
}
this.registeredTiles = new BlockPos2ValueMap<>();
this.registeredTiles = BlockPos2ValueMap.create();
}

// @Inject(method = "getIoTile", at = @At(value = "INVOKE", target = "Ljava/util/Queue;iterator()Ljava/util/Iterator;"), cancellable = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import java.util.Set;

@SuppressWarnings("DataFlowIssue")
@Mixin(Chunk.class)
public class MixinChunk {
Expand All @@ -24,7 +26,7 @@ public class MixinChunk {
private World world;

@Unique
private final BlockPosSet stellar_core$invalidTESet = new BlockPosSet();
private final Set<BlockPos> stellar_core$invalidTESet = BlockPosSet.create();

@Inject(method = "createNewTileEntity", at = @At("HEAD"), cancellable = true)
private void injectCreateNewTileEntity(final BlockPos pos, final CallbackInfoReturnable<TileEntity> cir) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ private void injectInit(final World worldIn, final int x, final int z, final Cal
if (!StellarCoreConfig.PERFORMANCE.vanilla.chunkTEMap) {
return;
}
this.tileEntities = new BlockPos2ValueMap<>();
this.tileEntities = BlockPos2ValueMap.create();
}

}

0 comments on commit 8367380

Please sign in to comment.