HyCodeYourTale
classpublicPriority 3

WeightedThicknessLayer

com.hypixel.hytale.builtin.hytalegenerator.materialproviders.spaceanddepth.layers.WeightedThicknessLayer

extends SpaceAndDepthMaterialProvider.Layer

1

Methods

1

Public Methods

3

Fields

1

Constructors

Constructors

public
WeightedThicknessLayer(WeightedMap<Integer> thicknessPool, MaterialProvider<V> materialProvider, SeedBox seedBox)

Methods

Public Methods (1)

public
MaterialProvider<V> getMaterialProvider()
@Override

Fields

Private/Package Fields (3)

privateMaterialProvider<V> materialProvider
privateSeedGenerator seedGenerator
privateWeightedMap<Integer> thicknessPool

Inheritance

Parent
Current
Interface
Child

Use mouse wheel to zoom, drag to pan. Click nodes to navigate.

Related Classes

Source Code

package com.hypixel.hytale.builtin.hytalegenerator.materialproviders.spaceanddepth.layers;

import com.hypixel.hytale.builtin.hytalegenerator.datastructures.WeightedMap;
import com.hypixel.hytale.builtin.hytalegenerator.framework.math.SeedGenerator;
import com.hypixel.hytale.builtin.hytalegenerator.materialproviders.MaterialProvider;
import com.hypixel.hytale.builtin.hytalegenerator.materialproviders.spaceanddepth.SpaceAndDepthMaterialProvider;
import com.hypixel.hytale.builtin.hytalegenerator.seed.SeedBox;
import com.hypixel.hytale.math.util.FastRandom;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;

public class WeightedThicknessLayer<V> extends SpaceAndDepthMaterialProvider.Layer<V> {
   @Nonnull
   private final WeightedMap<Integer> thicknessPool;
   @Nonnull
   private final SeedGenerator seedGenerator;
   @Nullable
   private final MaterialProvider<V> materialProvider;

   public WeightedThicknessLayer(@Nonnull WeightedMap<Integer> thicknessPool, @Nullable MaterialProvider<V> materialProvider, @Nonnull SeedBox seedBox) {
      this.seedGenerator = new SeedGenerator((long)seedBox.createSupplier().get().intValue());
      this.materialProvider = materialProvider;
      this.thicknessPool = thicknessPool;
   }

   @Override
   public int getThicknessAt(
      int x, int y, int z, int depthIntoFloor, int depthIntoCeiling, int spaceAboveFloor, int spaceBelowCeiling, double distanceTOBiomeEdge
   ) {
      if (this.thicknessPool.size() == 0) {
         return 0;
      } else {
         FastRandom random = new FastRandom(this.seedGenerator.seedAt((long)x, (long)z));
         return this.thicknessPool.pick(random);
      }
   }

   @Override
   public MaterialProvider<V> getMaterialProvider() {
      return this.materialProvider;
   }
}