Skip to content
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

Implement CubeAccess; CloAccess + descendant interfaces #17

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
@Mod("cubicchunks")
public class CubicChunks extends CubicChunksBase {
protected static CommonConfig config = null;
// For hardcoding height in P1
public static final int SUPERFLAT_HEIGHT = 5;

public CubicChunks(IEventBus modEventBus) {
ChunkMap.class.getName();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package io.github.opencubicchunks.cubicchunks.mixin.core.common.world.level.chunk;

import io.github.opencubicchunks.cubicchunks.world.level.chunklike.CloAccess;
import io.github.opencubicchunks.cubicchunks.world.level.chunklike.CloPos;
import net.minecraft.core.Registry;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.LevelHeightAccessor;
import net.minecraft.world.level.chunk.ChunkAccess;
import net.minecraft.world.level.chunk.LevelChunkSection;
import net.minecraft.world.level.chunk.UpgradeData;
import net.minecraft.world.level.levelgen.blending.BlendingData;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(ChunkAccess.class)
public abstract class MixinChunkAccess implements CloAccess {
private CloPos cc_cloPos;

@Inject(method = "<init>", at = @At("RETURN"))
private void onInit(ChunkPos chunkPos, UpgradeData p_187622_, LevelHeightAccessor p_187623_, Registry p_187624_, long p_187625_, LevelChunkSection[] p_187626_, BlendingData p_187627_,
CallbackInfo ci) {
cc_cloPos = CloPos.chunk(chunkPos);
}

public CloPos cc_getCloPos() {
return cc_cloPos;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package io.github.opencubicchunks.cubicchunks.mixin.core.common.world.level.cube;

import io.github.opencubicchunks.cubicchunks.world.level.cube.CubeAccess;
import org.spongepowered.asm.mixin.Mixin;

// Needed for DASM to apply
@Mixin(CubeAccess.class)
public class MixinCubeAccess {
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,151 @@
package io.github.opencubicchunks.cubicchunks.world.level.chunklike;

public interface CloAccess {
import java.util.Collection;
import java.util.Map;
import java.util.Set;
import java.util.function.BiConsumer;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.function.Supplier;

import javax.annotation.Nullable;

import it.unimi.dsi.fastutil.shorts.ShortList;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.LevelHeightAccessor;
import net.minecraft.world.level.biome.BiomeGenerationSettings;
import net.minecraft.world.level.biome.BiomeManager;
import net.minecraft.world.level.biome.BiomeResolver;
import net.minecraft.world.level.biome.Climate;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkAccess;
import net.minecraft.world.level.chunk.ChunkStatus;
import net.minecraft.world.level.chunk.LevelChunkSection;
import net.minecraft.world.level.chunk.LightChunk;
import net.minecraft.world.level.chunk.StructureAccess;
import net.minecraft.world.level.chunk.UpgradeData;
import net.minecraft.world.level.gameevent.GameEventListenerRegistry;
import net.minecraft.world.level.levelgen.BelowZeroRetrogen;
import net.minecraft.world.level.levelgen.Heightmap;
import net.minecraft.world.level.levelgen.NoiseChunk;
import net.minecraft.world.level.levelgen.blending.BlendingData;
import net.minecraft.world.level.levelgen.structure.Structure;
import net.minecraft.world.level.levelgen.structure.StructureStart;
import net.minecraft.world.level.material.Fluid;
import net.minecraft.world.ticks.TickContainerAccess;

public interface CloAccess extends BlockGetter, BiomeManager.NoiseBiomeSource, LightChunk, StructureAccess {
GameEventListenerRegistry getListenerRegistry(int p_251437_);

@Nullable BlockState setBlockState(BlockPos p_62087_, BlockState p_62088_, boolean p_62089_);

void setBlockEntity(BlockEntity p_156114_);

void addEntity(Entity p_62078_);

int getHighestFilledSectionIndex();

// Deprecated
int getHighestSectionPosition();

Set<BlockPos> getBlockEntitiesPos();

LevelChunkSection[] getSections();

LevelChunkSection getSection(int p_187657_);

Collection<Map.Entry<Heightmap.Types, Heightmap>> getHeightmaps();

void setHeightmap(Heightmap.Types p_62083_, long[] p_62084_);

Heightmap getOrCreateHeightmapUnprimed(Heightmap.Types p_62079_);

boolean hasPrimedHeightmap(Heightmap.Types p_187659_);

int getHeight(Heightmap.Types p_62080_, int p_62081_, int p_62082_);

// replacement of ChunkPos getPos()
CloPos cc_getCloPos();

Map<Structure, StructureStart> getAllStarts();

void setAllStarts(Map<Structure, StructureStart> p_62090_);

boolean isYSpaceEmpty(int p_62075_, int p_62076_);

void setUnsaved(boolean p_62094_);

boolean isUnsaved();

ChunkStatus getStatus();

ChunkStatus getHighestGeneratedStatus();

void removeBlockEntity(BlockPos p_62101_);

void markPosForPostprocessing(BlockPos p_62102_);

ShortList[] getPostProcessing();

void addPackedPostProcess(short p_62092_, int p_62093_);

void setBlockEntityNbt(CompoundTag p_62091_);

@Nullable CompoundTag getBlockEntityNbt(BlockPos p_62103_);

@Nullable CompoundTag getBlockEntityNbtForSaving(BlockPos p_62104_);

void findBlocks(Predicate<BlockState> p_285343_, BiConsumer<BlockPos, BlockState> p_285030_);

void findBlocks(java.util.function.BiPredicate<BlockState, BlockPos> p_285343_, BiConsumer<BlockPos, BlockState> p_285030_);

TickContainerAccess<Block> getBlockTicks();

TickContainerAccess<Fluid> getFluidTicks();

ChunkAccess.TicksToSave getTicksForSerialization();

UpgradeData getUpgradeData();

boolean isOldNoiseGeneration();

@Nullable BlendingData getBlendingData();

void setBlendingData(BlendingData p_187646_);

long getInhabitedTime();

void incrementInhabitedTime(long p_187633_);

void setInhabitedTime(long p_62099_);

boolean isLightCorrect();

void setLightCorrect(boolean p_62100_);

NoiseChunk getOrCreateNoiseChunk(Function<ChunkAccess, NoiseChunk> p_223013_);

@Deprecated BiomeGenerationSettings carverBiome(Supplier<BiomeGenerationSettings> p_223015_);

void fillBiomesFromNoise(BiomeResolver p_187638_, Climate.Sampler p_187639_);

boolean hasAnyStructureReferences();

@Nullable BelowZeroRetrogen getBelowZeroRetrogen();

boolean isUpgrading();

LevelHeightAccessor getHeightAccessorForGeneration();

void initializeLightSources();

// TODO static methods
// static ShortList getOrCreateOffsetList(ShortList[] p_62096_, int p_62097_);
//
// static record TicksToSave(SerializableTickContainer<Block> blocks, SerializableTickContainer<Fluid> fluids);
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
package io.github.opencubicchunks.cubicchunks.world.level.chunklike;

public interface ImposterProtoClo extends ProtoClo {
// Every method on ImposterProtoChunk is also on a parent class/interface
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,61 @@
package io.github.opencubicchunks.cubicchunks.world.level.chunklike;

import java.util.Map;
import java.util.function.Consumer;
import java.util.function.Supplier;

import javax.annotation.Nullable;

import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.protocol.game.ClientboundLevelChunkPacketData;
import net.minecraft.server.level.FullChunkStatus;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraft.world.level.material.FluidState;

public interface LevelClo extends CloAccess {
FluidState getFluidState(int p_62815_, int p_62816_, int p_62817_);

@Nullable
BlockEntity getBlockEntity(BlockPos p_62868_, LevelChunk.EntityCreationType p_62869_);

void addAndRegisterBlockEntity(BlockEntity p_156391_);

boolean isTicking(BlockPos p_156411_);

void runPostLoad();

boolean isEmpty();

void replaceWithPacketData(
FriendlyByteBuf p_187972_, CompoundTag p_187973_, Consumer<ClientboundLevelChunkPacketData.BlockEntityTagOutput> p_187974_
);

void replaceBiomes(FriendlyByteBuf p_275574_);

void setLoaded(boolean p_62914_);

Level getLevel();

Map<BlockPos, BlockEntity> getBlockEntities();

void postProcessGeneration();

void unpackTicks(long p_187986_);

void registerTickContainerInLevel(ServerLevel p_187959_);

void unregisterTickContainerFromLevel(ServerLevel p_187980_);

FullChunkStatus getFullStatus();

void setFullStatus(Supplier<FullChunkStatus> p_62880_);

void clearAllBlockEntities();

void registerAllBlockEntitiesAfterLevelLoad();
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,50 @@
package io.github.opencubicchunks.cubicchunks.world.level.chunklike;

import java.util.List;
import java.util.Map;

import javax.annotation.Nullable;

import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.chunk.CarvingMask;
import net.minecraft.world.level.chunk.ChunkStatus;
import net.minecraft.world.level.levelgen.BelowZeroRetrogen;
import net.minecraft.world.level.levelgen.GenerationStep;
import net.minecraft.world.level.lighting.LevelLightEngine;
import net.minecraft.world.level.material.Fluid;
import net.minecraft.world.ticks.LevelChunkTicks;

public interface ProtoClo extends CloAccess {
Map<BlockPos, BlockEntity> getBlockEntities();

void addEntity(CompoundTag p_63243_);

List<CompoundTag> getEntities();

void setStatus(ChunkStatus p_63187_);

Map<BlockPos, CompoundTag> getBlockEntityNbts();

@Nullable
CarvingMask getCarvingMask(GenerationStep.Carving p_188185_);

CarvingMask getOrCreateCarvingMask(GenerationStep.Carving p_188191_);

void setCarvingMask(GenerationStep.Carving p_188187_, CarvingMask p_188188_);

void setLightEngine(LevelLightEngine p_63210_);

void setBelowZeroRetrogen(@Nullable BelowZeroRetrogen p_188184_);

LevelChunkTicks<Block> unpackBlockTicks();

LevelChunkTicks<Fluid> unpackFluidTicks();

// TODO statics
// public static short packOffsetCoordinates(BlockPos p_63281_);
//
// public static BlockPos unpackOffsetCoordinates(short p_63228_, int p_63229_, ChunkPos p_63230_);
}
Loading
Loading