Removed old End Caves (temporary), added new Caves and Cave API (WIP)

This commit is contained in:
paulevsGitch 2021-03-09 02:40:26 +03:00
parent 2135fe50b5
commit 231794363b
14 changed files with 384 additions and 28 deletions

View file

@ -0,0 +1,46 @@
package ru.betterend.mixin.common;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.source.BiomeArray;
import ru.betterend.interfaces.IBiomeArray;
@Mixin(BiomeArray.class)
public class BiomeArrayMixin implements IBiomeArray {
@Final
@Shadow
private Biome[] data;
@Final
@Shadow
private static int HORIZONTAL_SECTION_COUNT;
@Final
@Shadow
public static int HORIZONTAL_BIT_MASK;
@Final
@Shadow
public static int VERTICAL_BIT_MASK;
@Override
public void setBiome(Biome biome, BlockPos pos) {
int biomeX = pos.getX() >> 2;
int biomeY = pos.getY() >> 2;
int biomeZ = pos.getZ() >> 2;
int index = be_getArrayIndex(biomeX, biomeY, biomeZ);
data[index] = biome;
}
private int be_getArrayIndex(int biomeX, int biomeY, int biomeZ) {
int i = biomeX & HORIZONTAL_BIT_MASK;
int j = MathHelper.clamp(biomeY, 0, VERTICAL_BIT_MASK);
int k = biomeZ & HORIZONTAL_BIT_MASK;
return j << HORIZONTAL_SECTION_COUNT + HORIZONTAL_SECTION_COUNT | k << HORIZONTAL_SECTION_COUNT | i;
}
}