<commit_before>package mcjty.rftoolsdim.dimensions;

import io.netty.buffer.ByteBuf;
import mcjty.lib.network.NetworkTools;
import mcjty.lib.varia.BlockPosTools;
import mcjty.lib.varia.Logging;
import mcjty.rftoolsdim.RFToolsDim;
import mcjty.rftoolsdim.api.dimension.IDimensionInformation;
import mcjty.rftoolsdim.compat.ChiselCompat;
import mcjty.rftoolsdim.config.GeneralConfiguration;
import mcjty.rftoolsdim.config.PowerConfiguration;
import mcjty.rftoolsdim.config.Settings;
import mcjty.rftoolsdim.config.WorldgenConfiguration;
import mcjty.rftoolsdim.dimensions.description.*;
import mcjty.rftoolsdim.dimensions.dimlets.DimletKey;
import mcjty.rftoolsdim.dimensions.dimlets.DimletObjectMapping;
import mcjty.rftoolsdim.dimensions.dimlets.DimletRandomizer;
import mcjty.rftoolsdim.dimensions.dimlets.KnownDimletConfiguration;
import mcjty.rftoolsdim.dimensions.dimlets.types.DimletType;
import mcjty.rftoolsdim.dimensions.dimlets.types.IDimletType;
import mcjty.rftoolsdim.dimensions.types.*;
import mcjty.rftoolsdim.dimensions.world.BiomeControllerMapping;
import mcjty.rftoolsdim.varia.GenericTools;
import net.minecraft.block.Block;
import net.minecraft.block.BlockLiquid;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Biomes;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.*;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraftforge.common.util.Constants;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fml.common.registry.ForgeRegistries;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.Pair;

import java.util.*;

public class DimensionInformation implements IDimensionInformation {
    private final DimensionDescriptor descriptor;
    private String name;
    private String ownerName;
    private UUID owner;

    private BlockPos spawnPoint = null;

    private int probeCounter = 0;

    private long forcedDimensionSeed = 0;               // Seed was forced using a seed dimlet.
    private long baseSeed = 0;                          // World seed we start to generate own seed from.

    private int worldVersion = VERSION_OLD;             // Used for compatilibity checking between generated worlds.
    public static final int VERSION_OLD = 0;            // Old version of worlds. Seed is incorrect.
    public static final int VERSION_CORRECTSEED = 1;    // New version of worlds. Seed is correct.
    public static final int VERSION_DIMLETSSEED = 2;    // Newer version of worlds. Seed is correct and based only on the world seed and dimlets.

    private TerrainType terrainType = TerrainType.TERRAIN_VOID;
    private IBlockState baseBlockForTerrain = null;
    private Block fluidForTerrain = null;
    private IBlockState tendrilBlock = null;
    private IBlockState canyonBlock = null;
    private IBlockState[] pyramidBlocks = new IBlockState[] { Blocks.STONE.getDefaultState() };
    private IBlockState[] sphereBlocks = new IBlockState[] { Blocks.STONE.getDefaultState() };
    private IBlockState[] hugeSphereBlocks = new IBlockState[] { Blocks.STONE.getDefaultState() };
    private IBlockState[] scatteredSphereBlocks = new IBlockState[] { Blocks.STONE.getDefaultState() };
    private IBlockState[] liquidSphereBlocks = new IBlockState[] { Blocks.STONE.getDefaultState() };
    private Block[] liquidSphereFluids = new Block[] { Blocks.WATER };
    private IBlockState[] hugeLiquidSphereBlocks = new IBlockState[] { Blocks.STONE.getDefaultState() };
    private Block[] hugeLiquidSphereFluids = new Block[] { Blocks.WATER };
    private IBlockState[] extraOregen = new IBlockState[] {};
    private Block[] fluidsForLakes = new Block[] {};

    private List<MobDescriptor> extraMobs = new ArrayList<>();
    private boolean peaceful = false;
    private boolean noanimals = false;
    private boolean shelter = false;
    private boolean respawnHere = false;
    private boolean cheater = false;

    private Set<FeatureType> featureTypes = EnumSet.noneOf(FeatureType.class);
    private Set<StructureType> structureTypes = EnumSet.noneOf(StructureType.class);
    private Set<EffectType> effectTypes = EnumSet.noneOf(EffectType.class);

    private ControllerType controllerType = null;
    private List<Biome> biomes = new ArrayList<>();
    private static final Map<Integer, Integer> biomeMapping = new HashMap<>();

    private String digitString = "";

    private Float celestialAngle = null;
    private Float timeSpeed = null;

    private SkyDescriptor skyDescriptor;
    private List<CelestialBodyDescriptor> celestialBodyDescriptors;

    // Patreon effects.
    private long patreon1 = 0;

    private String[] dimensionTypes = new String[0];    // Used for Recurrent Complex if that's present.

    private WeatherDescriptor weatherDescriptor;

    // The actual RF cost after taking into account the features we got in our world.
    private int actualRfCost;

    private String injectedDimlets = "";

    public DimensionInformation(String name, DimensionDescriptor descriptor, World world, String playerName, UUID player) {
        this.name = name;
        this.descriptor = descriptor;
        this.ownerName = playerName;
        this.owner = player;

        this.forcedDimensionSeed = descriptor.getForcedSeed();
        if (GeneralConfiguration.randomizeSeed) {
            baseSeed = (long) (Math.random() * 10000 + 1);
        } else {
            baseSeed = world.getSeed();
        }

        worldVersion = VERSION_DIMLETSSEED;

        setupFromDescriptor(world.getSeed());
        setupBiomeMapping();

        dump(null);
    }

    private void setupFromDescriptor(long seed) {
        List<Pair<DimletKey,List<DimletKey>>> dimlets = descriptor.getDimletsWithModifiers();
        Random random = new Random(descriptor.calculateSeed(seed));<commit_msg>Use the overworld's seed no matter what dimension you're in<commit_after>package mcjty.rftoolsdim.dimensions;

import io.netty.buffer.ByteBuf;
import mcjty.lib.network.NetworkTools;
import mcjty.lib.varia.BlockPosTools;
import mcjty.lib.varia.Logging;
import mcjty.rftoolsdim.RFToolsDim;
import mcjty.rftoolsdim.api.dimension.IDimensionInformation;
import mcjty.rftoolsdim.compat.ChiselCompat;
import mcjty.rftoolsdim.config.GeneralConfiguration;
import mcjty.rftoolsdim.config.PowerConfiguration;
import mcjty.rftoolsdim.config.Settings;
import mcjty.rftoolsdim.config.WorldgenConfiguration;
import mcjty.rftoolsdim.dimensions.description.*;
import mcjty.rftoolsdim.dimensions.dimlets.DimletKey;
import mcjty.rftoolsdim.dimensions.dimlets.DimletObjectMapping;
import mcjty.rftoolsdim.dimensions.dimlets.DimletRandomizer;
import mcjty.rftoolsdim.dimensions.dimlets.KnownDimletConfiguration;
import mcjty.rftoolsdim.dimensions.dimlets.types.DimletType;
import mcjty.rftoolsdim.dimensions.dimlets.types.IDimletType;
import mcjty.rftoolsdim.dimensions.types.*;
import mcjty.rftoolsdim.dimensions.world.BiomeControllerMapping;
import mcjty.rftoolsdim.varia.GenericTools;
import net.minecraft.block.Block;
import net.minecraft.block.BlockLiquid;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Biomes;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.*;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.common.util.Constants;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fml.common.registry.ForgeRegistries;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.Pair;

import java.util.*;

public class DimensionInformation implements IDimensionInformation {
    private final DimensionDescriptor descriptor;
    private String name;
    private String ownerName;
    private UUID owner;

    private BlockPos spawnPoint = null;

    private int probeCounter = 0;

    private long forcedDimensionSeed = 0;               // Seed was forced using a seed dimlet.
    private long baseSeed = 0;                          // World seed we start to generate own seed from.

    private int worldVersion = VERSION_OLD;             // Used for compatilibity checking between generated worlds.
    public static final int VERSION_OLD = 0;            // Old version of worlds. Seed is incorrect.
    public static final int VERSION_CORRECTSEED = 1;    // New version of worlds. Seed is correct.
    public static final int VERSION_DIMLETSSEED = 2;    // Newer version of worlds. Seed is correct and based only on the world seed and dimlets.

    private TerrainType terrainType = TerrainType.TERRAIN_VOID;
    private IBlockState baseBlockForTerrain = null;
    private Block fluidForTerrain = null;
    private IBlockState tendrilBlock = null;
    private IBlockState canyonBlock = null;
    private IBlockState[] pyramidBlocks = new IBlockState[] { Blocks.STONE.getDefaultState() };
    private IBlockState[] sphereBlocks = new IBlockState[] { Blocks.STONE.getDefaultState() };
    private IBlockState[] hugeSphereBlocks = new IBlockState[] { Blocks.STONE.getDefaultState() };
    private IBlockState[] scatteredSphereBlocks = new IBlockState[] { Blocks.STONE.getDefaultState() };
    private IBlockState[] liquidSphereBlocks = new IBlockState[] { Blocks.STONE.getDefaultState() };
    private Block[] liquidSphereFluids = new Block[] { Blocks.WATER };
    private IBlockState[] hugeLiquidSphereBlocks = new IBlockState[] { Blocks.STONE.getDefaultState() };
    private Block[] hugeLiquidSphereFluids = new Block[] { Blocks.WATER };
    private IBlockState[] extraOregen = new IBlockState[] {};
    private Block[] fluidsForLakes = new Block[] {};

    private List<MobDescriptor> extraMobs = new ArrayList<>();
    private boolean peaceful = false;
    private boolean noanimals = false;
    private boolean shelter = false;
    private boolean respawnHere = false;
    private boolean cheater = false;

    private Set<FeatureType> featureTypes = EnumSet.noneOf(FeatureType.class);
    private Set<StructureType> structureTypes = EnumSet.noneOf(StructureType.class);
    private Set<EffectType> effectTypes = EnumSet.noneOf(EffectType.class);

    private ControllerType controllerType = null;
    private List<Biome> biomes = new ArrayList<>();
    private static final Map<Integer, Integer> biomeMapping = new HashMap<>();

    private String digitString = "";

    private Float celestialAngle = null;
    private Float timeSpeed = null;

    private SkyDescriptor skyDescriptor;
    private List<CelestialBodyDescriptor> celestialBodyDescriptors;

    // Patreon effects.
    private long patreon1 = 0;

    private String[] dimensionTypes = new String[0];    // Used for Recurrent Complex if that's present.

    private WeatherDescriptor weatherDescriptor;

    // The actual RF cost after taking into account the features we got in our world.
    private int actualRfCost;

    private String injectedDimlets = "";

    public DimensionInformation(String name, DimensionDescriptor descriptor, World world, String playerName, UUID player) {
        this.name = name;
        this.descriptor = descriptor;
        this.ownerName = playerName;
        this.owner = player;

        this.forcedDimensionSeed = descriptor.getForcedSeed();
        long overworldSeed = RfToolsDimensionManager.getWorldForDimension(world, 0).getSeed();
        if (GeneralConfiguration.randomizeSeed) {
            baseSeed = (long) (Math.random() * 10000 + 1);
        } else {
            baseSeed = overworldSeed;
        }

        worldVersion = VERSION_DIMLETSSEED;

        setupFromDescriptor(overworldSeed);
        setupBiomeMapping();

        dump(null);
    }

    private void setupFromDescriptor(long seed) {
        List<Pair<DimletKey,List<DimletKey>>> dimlets = descriptor.getDimletsWithModifiers();
        Random random = new Random(descriptor.calculateSeed(seed));
{'fraction_non_alphanumeric': 0.08722029624960605, 'fraction_numerical': 0.002915222187204538, 'mean_word_length': 4.2580778790389395, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4112274', 'n_tokens_mistral': 3708, 'n_tokens_neox': 3627, 'n_words': 888}