Skip to content

Commit

Permalink
Merge branch 'OpenCubicChunks:MC_1.20_neoforge' into MC_1.20_neoforge…
Browse files Browse the repository at this point in the history
…_clientlevel
  • Loading branch information
seelderr authored Jan 21, 2024
2 parents c182443 + d4b2b0b commit abd7ddd
Show file tree
Hide file tree
Showing 29 changed files with 1,657 additions and 192 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ dependencies {
targetConfiguration = "testArchivesOutput"
}

libraries("com.github.OpenCubicChunks:dasm:cd078a82cd") {
libraries("com.github.OpenCubicChunks:dasm:4ff381c5a3") {
transitive = false
}
libraries("io.github.opencubicchunks:regionlib:0.63.0-SNAPSHOT")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,9 @@ private static String remapMethodName(Mappings mappings, String methodOwner, Met

private static String remapFieldName(Mappings mappings, String fieldOwner, Type type, String name) {
Mappings.ClassMapping mapEntry = mappings.getClass(fieldOwner.replace('.', '/'));
if (mapEntry == null) {
return name;
}
Mappings.FieldMapping field = mapEntry.getField(name, type.getDescriptor());
if (field == null) {
return name;
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ neo_version_range=[20.4,)
loader_version_range=[2,)

# Disabled due to local variables being named incorrectly (e.g. in DynamicGraphMinFixedPoint)
#neogradle.subsystems.parchment.minecraftVersion=1.20.2
#neogradle.subsystems.parchment.mappingsVersion=2023.12.10
#neogradle.subsystems.parchment.minecraftVersion=1.20.3
#neogradle.subsystems.parchment.mappingsVersion=2023.12.31

## Mod Properties

Expand Down
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

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package io.github.opencubicchunks.cubicchunks.mixin;

public @interface CopyFrom {
Class<?> clazz() default Object.class;

String string() default "";
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

String value();

Class<?> copyFrom() default Object.class;
CopyFrom copyFrom() default @CopyFrom();

Signature signature() default @Signature(fromString = true);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package io.github.opencubicchunks.cubicchunks.mixin;

public @interface TransformFromClass {
CopyFrom value();

TransformFrom.ApplicationStage stage() default TransformFrom.ApplicationStage.PRE_APPLY;
}

This file was deleted.

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,17 @@
package io.github.opencubicchunks.cubicchunks.mixin.core.common.world.level.chunk;

import io.github.opencubicchunks.cubicchunks.world.level.chunklike.ImposterProtoClo;
import io.github.opencubicchunks.cubicchunks.world.level.chunklike.LevelClo;
import net.minecraft.world.level.chunk.ImposterProtoChunk;
import net.minecraft.world.level.chunk.LevelChunk;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;

@Mixin(ImposterProtoChunk.class)
public abstract class MixinImposterProtoChunk implements ImposterProtoClo {
@Override public LevelClo cc_getWrappedClo() {
return (LevelClo) this.getWrapped();
}

@Shadow public abstract LevelChunk getWrapped();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package io.github.opencubicchunks.cubicchunks.mixin.core.common.world.level.chunk;

import io.github.opencubicchunks.cubicchunks.world.level.chunklike.LevelClo;
import net.minecraft.world.level.chunk.LevelChunk;
import org.spongepowered.asm.mixin.Mixin;

@Mixin(LevelChunk.class)
public abstract class MixinLevelChunk implements LevelClo {
}
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
@@ -0,0 +1,8 @@
package io.github.opencubicchunks.cubicchunks.mixin.core.common.world.level.cube;

import org.spongepowered.asm.mixin.Mixin;

// Needed for DASM to apply
@Mixin(targets = "io.github.opencubicchunks.cubicchunks.world.level.cube.LevelCube$BoundTickingBlockEntity")
public class MixinLevelCube$BoundTickingBlockEntity {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package io.github.opencubicchunks.cubicchunks.mixin.core.common.world.level.cube;

import org.spongepowered.asm.mixin.Mixin;

// Needed for DASM to apply
@Mixin(targets = "io.github.opencubicchunks.cubicchunks.world.level.cube.LevelCube$RebindableTickingBlockEntityWrapper")
public class MixinLevelCube$RebindableTickingBlockEntityWrapper {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package io.github.opencubicchunks.cubicchunks.mixin.core.common.world.level.cube;

import io.github.opencubicchunks.cc_core.utils.Coords;
import io.github.opencubicchunks.cubicchunks.world.level.cube.LevelCube;
import net.minecraft.core.BlockPos;
import org.spongepowered.asm.mixin.Dynamic;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

// Needed for DASM to apply
@Mixin(LevelCube.class)
public abstract class MixinLevelCube extends MixinCubeAccess {
/**
* Redirect to use cube section indexing instead of chunk section indexing
*/
@Dynamic @Redirect(method = "cc_dasm$getBlockState", at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cubicchunks/world/level/cube/LevelCube;getSectionIndex(I)I"))
private int cc_onGetBlockState_SectionIndex(LevelCube instance, int i, BlockPos pos) {
return Coords.blockToIndex(pos);
}

/**
* Redirect to use cube section indexing instead of chunk section indexing
*/
@Dynamic @Redirect(method = "cc_dasm$getFluidState(III)Lnet/minecraft/world/level/material/FluidState;", at = @At(value = "INVOKE", target = "Lio/github/opencubicchunks/cubicchunks"
+ "/world/level/cube/LevelCube;getSectionIndex(I)I"))
private int cc_onGetFluidState_SectionIndex(LevelCube instance, int i, int x, int y, int z) {
return Coords.blockToIndex(x, y, z);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,154 @@
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<CloAccess, 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);

// TODO forge method
// @Nullable public net.minecraft.world.level.LevelAccessor getWorldForge() { return null; }
}
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 {
LevelClo cc_getWrappedClo();
}
Loading

0 comments on commit abd7ddd

Please sign in to comment.