Created
June 25, 2020 03:53
-
-
Save electronicboy/98db627e07a78fe06f7ab5e76bacf2dd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package net.minecraft.server; | |
import com.google.common.collect.ImmutableList; | |
import com.google.common.collect.Lists; | |
import com.google.common.collect.Maps; | |
import com.google.common.collect.Sets; | |
import com.mojang.serialization.Codec; | |
import com.mojang.serialization.codecs.RecordCodecBuilder; | |
import it.unimi.dsi.fastutil.longs.Long2FloatLinkedOpenHashMap; | |
import java.util.Arrays; | |
import java.util.Collection; | |
import java.util.List; | |
import java.util.Map; | |
import java.util.Optional; | |
import java.util.Random; | |
import java.util.Set; | |
import java.util.function.Function; | |
import java.util.stream.Collectors; | |
import java.util.stream.Stream; | |
import javax.annotation.Nullable; | |
import org.apache.logging.log4j.LogManager; | |
import org.apache.logging.log4j.Logger; | |
public class BiomeBase { | |
public static final Logger LOGGER = LogManager.getLogger(); | |
public static final Codec<BiomeBase> b = RecordCodecBuilder.<BiomeBase>create((var0) -> { | |
// $FF: Couldn't be decompiled | |
}); | |
public static final Set<BiomeBase> c = Sets.<BiomeBase>newHashSet(); | |
public static final RegistryBlockID<BiomeBase> d = new RegistryBlockID<BiomeBase>(); | |
protected static final NoiseGenerator3 e = new NoiseGenerator3(new SeededRandom(1234L), ImmutableList.of(0)); | |
public static final NoiseGenerator3 f = new NoiseGenerator3(new SeededRandom(2345L), ImmutableList.of(0)); | |
@Nullable | |
protected String g; | |
protected final float h; | |
protected final float i; | |
protected final float j; | |
protected final float k; | |
private final int t; | |
@Nullable | |
protected final String l; | |
protected final WorldGenSurfaceComposite<?> m; | |
protected final BiomeBase.Geography n; | |
protected final BiomeBase.Precipitation o; | |
protected final BiomeFog p; | |
protected final Map<WorldGenStage.Features, List<WorldGenCarverWrapper<?>>> q; | |
protected final Map<WorldGenStage.Decoration, List<WorldGenFeatureConfigured<?, ?>>> r; | |
protected final List<WorldGenFeatureConfigured<?, ?>> s = Lists.<WorldGenFeatureConfigured<?, ?>>newArrayList(); | |
private final Map<StructureGenerator<?>, StructureFeature<?, ?>> u; | |
private final Map<EnumCreatureType, List<BiomeBase.BiomeMeta>> v; | |
private final Map<EntityTypes<?>, BiomeBase.e> w = Maps.<EntityTypes<?>, BiomeBase.e>newHashMap(); | |
private final List<BiomeBase.d> x; | |
private final ThreadLocal<Long2FloatLinkedOpenHashMap> y = ThreadLocal.withInitial(() -> { | |
return (Long2FloatLinkedOpenHashMap)SystemUtils.a(() -> { | |
Long2FloatLinkedOpenHashMap var0 = new Long2FloatLinkedOpenHashMap(1024, 0.25F) { | |
protected void rehash(int var0) { | |
} | |
}; | |
var0.defaultReturnValue(Float.NaN); | |
return var0; | |
}); | |
}); | |
@Nullable | |
public static BiomeBase a(BiomeBase var0) { | |
return d.fromId(IRegistry.BIOME.a(var0)); | |
} | |
public static <C extends WorldGenCarverConfiguration> WorldGenCarverWrapper<C> a(WorldGenCarverAbstract<C> var0, C var1) { | |
return new WorldGenCarverWrapper<C>(var0, var1); | |
} | |
protected BiomeBase(BiomeBase.a var0) { | |
if (var0.a != null && var0.b != null && var0.c != null && var0.d != null && var0.e != null && var0.f != null && var0.g != null && var0.j != null) { | |
this.m = var0.a; | |
this.o = var0.b; | |
this.n = var0.c; | |
this.h = var0.d; | |
this.i = var0.e; | |
this.j = var0.f; | |
this.k = var0.g; | |
this.t = this.D(); | |
this.l = var0.h; | |
this.x = (List<BiomeBase.d>)(var0.i != null ? var0.i : ImmutableList.of()); | |
this.p = var0.j; | |
this.q = Maps.<WorldGenStage.Features, List<WorldGenCarverWrapper<?>>>newHashMap(); | |
this.u = Maps.<StructureGenerator<?>, StructureFeature<?, ?>>newHashMap(); | |
this.r = Maps.<WorldGenStage.Decoration, List<WorldGenFeatureConfigured<?, ?>>>newHashMap(); | |
for(WorldGenStage.Decoration var4 : WorldGenStage.Decoration.values()) { | |
this.r.put(var4, Lists.newArrayList()); | |
} | |
this.v = Maps.<EnumCreatureType, List<BiomeBase.BiomeMeta>>newHashMap(); | |
for(EnumCreatureType var4 : EnumCreatureType.values()) { | |
this.v.put(var4, Lists.newArrayList()); | |
} | |
} else { | |
throw new IllegalStateException("You are missing parameters to build a proper biome for " + this.getClass().getSimpleName() + "\n" + var0); | |
} | |
} | |
private BiomeBase(BiomeBase.Precipitation var0, BiomeBase.Geography var1, float var2, float var3, float var4, float var5, BiomeFog var6, int var7, WorldGenSurfaceComposite<?> var8, Map<WorldGenStage.Features, List<WorldGenCarverWrapper<?>>> var9, Map<WorldGenStage.Decoration, List<WorldGenFeatureConfigured<?, ?>>> var10, List<StructureFeature<?, ?>> var11, Map<EnumCreatureType, List<BiomeBase.BiomeMeta>> var12, List<BiomeBase.d> var13, Optional<String> var14) { | |
this.o = var0; | |
this.n = var1; | |
this.h = var2; | |
this.i = var3; | |
this.j = var4; | |
this.k = var5; | |
this.p = var6; | |
this.t = var7; | |
this.m = var8; | |
this.q = var9; | |
this.r = var10; | |
this.u = (Map)var11.stream().collect(Collectors.toMap((var0x) -> { | |
return var0x.b; | |
}, Function.identity())); | |
this.v = var12; | |
this.x = var13; | |
this.l = (String)var14.orElse((Object)null); | |
var10.values().stream().flatMap(Collection::stream).filter((var0x) -> { | |
return var0x.d == WorldGenerator.DECORATED_FLOWER; | |
}).forEach(this.s::add); | |
} | |
public boolean b() { | |
return this.l != null; | |
} | |
private int D() { | |
float var0 = this.j; | |
var0 = var0 / 3.0F; | |
var0 = MathHelper.a(var0, -1.0F, 1.0F); | |
return MathHelper.f(0.62222224F - var0 * 0.05F, 0.5F + var0 * 0.1F, 1.0F); | |
} | |
protected void a(EnumCreatureType var0, BiomeBase.BiomeMeta var1) { | |
((List)this.v.get(var0)).add(var1); | |
} | |
protected void a(EntityTypes<?> var0, double var1, double var3) { | |
this.w.put(var0, new BiomeBase.e(var3, var1)); | |
} | |
public List<BiomeBase.BiomeMeta> getMobs(EnumCreatureType var0) { | |
return (List)this.v.get(var0); | |
} | |
@Nullable | |
public BiomeBase.e a(EntityTypes<?> var0) { | |
return (BiomeBase.e)this.w.get(var0); | |
} | |
public BiomeBase.Precipitation d() { | |
return this.o; | |
} | |
public boolean e() { | |
return this.getHumidity() > 0.85F; | |
} | |
public float f() { | |
return 0.1F; | |
} | |
protected float a(BlockPosition var0) { | |
if (var0.getY() > 64) { | |
float var1 = (float)(e.a((double)((float)var0.getX() / 8.0F), (double)((float)var0.getZ() / 8.0F), false) * 4.0D); | |
return this.getTemperature() - (var1 + (float)var0.getY() - 64.0F) * 0.05F / 30.0F; | |
} else { | |
return this.getTemperature(); | |
} | |
} | |
public final float getAdjustedTemperature(BlockPosition var0) { | |
long var1 = var0.asLong(); | |
Long2FloatLinkedOpenHashMap var3 = (Long2FloatLinkedOpenHashMap)this.y.get(); | |
float var4 = var3.get(var1); | |
if (!Float.isNaN(var4)) { | |
return var4; | |
} else { | |
float var5 = this.a(var0); | |
if (var3.size() == 1024) { | |
var3.removeFirstFloat(); | |
} | |
var3.put(var1, var5); | |
return var5; | |
} | |
} | |
public boolean a(IWorldReader var0, BlockPosition var1) { | |
return this.a(var0, var1, true); | |
} | |
public boolean a(IWorldReader var0, BlockPosition var1, boolean var2) { | |
if (this.getAdjustedTemperature(var1) >= 0.15F) { | |
return false; | |
} else { | |
if (var1.getY() >= 0 && var1.getY() < 256 && var0.getBrightness(EnumSkyBlock.BLOCK, var1) < 10) { | |
IBlockData var3 = var0.getType(var1); | |
Fluid var4 = var0.getFluid(var1); | |
if (var4.getType() == FluidTypes.WATER && var3.getBlock() instanceof BlockFluids) { | |
if (!var2) { | |
return true; | |
} | |
boolean var5 = var0.A(var1.west()) && var0.A(var1.east()) && var0.A(var1.north()) && var0.A(var1.south()); | |
if (!var5) { | |
return true; | |
} | |
} | |
} | |
return false; | |
} | |
} | |
public boolean b(IWorldReader var0, BlockPosition var1) { | |
if (this.getAdjustedTemperature(var1) >= 0.15F) { | |
return false; | |
} else { | |
if (var1.getY() >= 0 && var1.getY() < 256 && var0.getBrightness(EnumSkyBlock.BLOCK, var1) < 10) { | |
IBlockData var2 = var0.getType(var1); | |
if (var2.isAir() && Blocks.SNOW.getBlockData().canPlace(var0, var1)) { | |
return true; | |
} | |
} | |
return false; | |
} | |
} | |
public void a(WorldGenStage.Decoration var0, WorldGenFeatureConfigured<?, ?> var1) { | |
if (var1.d == WorldGenerator.DECORATED_FLOWER) { | |
this.s.add(var1); | |
} | |
((List)this.r.get(var0)).add(var1); | |
} | |
public <C extends WorldGenCarverConfiguration> void a(WorldGenStage.Features var0, WorldGenCarverWrapper<C> var1) { | |
((List)this.q.computeIfAbsent(var0, (var0x) -> { | |
return Lists.newArrayList(); | |
})).add(var1); | |
} | |
public List<WorldGenCarverWrapper<?>> a(WorldGenStage.Features var0) { | |
return (List)this.q.computeIfAbsent(var0, (var0x) -> { | |
return Lists.newArrayList(); | |
}); | |
} | |
public void a(StructureFeature<?, ?> var0) { | |
this.u.put(var0.b, var0); | |
} | |
public boolean a(StructureGenerator<?> var0) { | |
return this.u.containsKey(var0); | |
} | |
public Iterable<StructureFeature<?, ?>> g() { | |
return this.u.values(); | |
} | |
public StructureFeature<?, ?> b(StructureFeature<?, ?> var0) { | |
return (StructureFeature)this.u.getOrDefault(var0.b, var0); | |
} | |
public List<WorldGenFeatureConfigured<?, ?>> h() { | |
return this.s; | |
} | |
public List<WorldGenFeatureConfigured<?, ?>> a(WorldGenStage.Decoration var0) { | |
return (List)this.r.get(var0); | |
} | |
public void a(WorldGenStage.Decoration var0, StructureManager var1, ChunkGenerator var2, GeneratorAccessSeed var3, long var4, SeededRandom var6, BlockPosition var7) { | |
int var8 = 0; | |
if (var1.a()) { | |
for(StructureGenerator<?> var10 : IRegistry.STRUCTURE_FEATURE) { | |
if (var10.f() == var0) { | |
var6.b(var4, var8, var0.ordinal()); | |
int var11 = var7.getX() >> 4; | |
int var12 = var7.getZ() >> 4; | |
int var13 = var11 << 4; | |
int var14 = var12 << 4; | |
try { | |
var1.a(SectionPosition.a(var7), var10).forEach((var8x) -> { | |
var8x.a(var3, var1, var2, var6, new StructureBoundingBox(var13, var14, var13 + 15, var14 + 15), new ChunkCoordIntPair(var11, var12)); | |
}); | |
} catch (Exception var19) { | |
CrashReport var16 = CrashReport.a(var19, "Feature placement"); | |
var16.a("Feature").a("Id", IRegistry.STRUCTURE_FEATURE.getKey(var10)).a("Description", () -> { | |
return var10.toString(); | |
}); | |
throw new ReportedException(var16); | |
} | |
++var8; | |
} | |
} | |
} | |
for(WorldGenFeatureConfigured<?, ?> var10 : (List)this.r.get(var0)) { | |
var6.b(var4, var8, var0.ordinal()); | |
try { | |
var10.a(var3, var1, var2, var6, var7); | |
} catch (Exception var18) { | |
CrashReport var12 = CrashReport.a(var18, "Feature placement"); | |
var12.a("Feature").a("Id", IRegistry.FEATURE.getKey(var10.d)).a("Config", var10.e).a("Description", () -> { | |
return var10.d.toString(); | |
}); | |
throw new ReportedException(var12); | |
} | |
++var8; | |
} | |
} | |
public void a(Random var0, IChunkAccess var1, int var2, int var3, int var4, double var5, IBlockData var7, IBlockData var8, int var9, long var10) { | |
this.m.a(var10); | |
this.m.a(var0, var1, this, var2, var3, var4, var5, var7, var8, var9, var10); | |
} | |
public BiomeBase.EnumTemperature j() { | |
if (this.n == BiomeBase.Geography.OCEAN) { | |
return BiomeBase.EnumTemperature.OCEAN; | |
} else if ((double)this.getTemperature() < 0.2D) { | |
return BiomeBase.EnumTemperature.COLD; | |
} else { | |
return (double)this.getTemperature() < 1.0D ? BiomeBase.EnumTemperature.MEDIUM : BiomeBase.EnumTemperature.WARM; | |
} | |
} | |
public final float k() { | |
return this.h; | |
} | |
public final float getHumidity() { | |
return this.k; | |
} | |
public String n() { | |
if (this.g == null) { | |
this.g = SystemUtils.a("biome", IRegistry.BIOME.getKey(this)); | |
} | |
return this.g; | |
} | |
public final float o() { | |
return this.i; | |
} | |
public final float getTemperature() { | |
return this.j; | |
} | |
public BiomeFog q() { | |
return this.p; | |
} | |
public final BiomeBase.Geography y() { | |
return this.n; | |
} | |
public WorldGenSurfaceComposite<?> z() { | |
return this.m; | |
} | |
public WorldGenSurfaceConfiguration A() { | |
return this.m.a(); | |
} | |
public Stream<BiomeBase.d> B() { | |
return this.x.stream(); | |
} | |
@Nullable | |
public String C() { | |
return this.l; | |
} | |
public static class BiomeMeta extends WeightedRandom.WeightedRandomChoice { | |
public static final Codec<BiomeBase.BiomeMeta> b = RecordCodecBuilder.<BiomeBase.BiomeMeta>create((var0) -> { | |
// $FF: Couldn't be decompiled | |
}); | |
public final EntityTypes<?> c; | |
public final int d; | |
public final int e; | |
public BiomeMeta(EntityTypes<?> var0, int var1, int var2, int var3) { | |
super(var1); | |
this.c = var0.e() == EnumCreatureType.MISC ? EntityTypes.PIG : var0; | |
this.d = var2; | |
this.e = var3; | |
} | |
public String toString() { | |
return EntityTypes.getName(this.c) + "*(" + this.d + "-" + this.e + "):" + this.a; | |
} | |
} | |
public static enum EnumTemperature { | |
OCEAN("ocean"), | |
COLD("cold"), | |
MEDIUM("medium"), | |
WARM("warm"); | |
private static final Map<String, BiomeBase.EnumTemperature> e = (Map)Arrays.stream(values()).collect(Collectors.toMap(BiomeBase.EnumTemperature::a, (var0) -> { | |
return var0; | |
})); | |
private final String f; | |
private EnumTemperature(String var2) { | |
this.f = var2; | |
} | |
public String a() { | |
return this.f; | |
} | |
} | |
public static enum Geography implements INamable { | |
NONE("none"), | |
TAIGA("taiga"), | |
EXTREME_HILLS("extreme_hills"), | |
JUNGLE("jungle"), | |
MESA("mesa"), | |
PLAINS("plains"), | |
SAVANNA("savanna"), | |
ICY("icy"), | |
THEEND("the_end"), | |
BEACH("beach"), | |
FOREST("forest"), | |
OCEAN("ocean"), | |
DESERT("desert"), | |
RIVER("river"), | |
SWAMP("swamp"), | |
MUSHROOM("mushroom"), | |
NETHER("nether"); | |
public static final Codec<BiomeBase.Geography> r = INamable.<BiomeBase.Geography>a(BiomeBase.Geography::values, BiomeBase.Geography::a); | |
private static final Map<String, BiomeBase.Geography> s = (Map)Arrays.stream(values()).collect(Collectors.toMap(BiomeBase.Geography::b, (var0) -> { | |
return var0; | |
})); | |
private final String t; | |
private Geography(String var2) { | |
this.t = var2; | |
} | |
public String b() { | |
return this.t; | |
} | |
public static BiomeBase.Geography a(String var0) { | |
return (BiomeBase.Geography)s.get(var0); | |
} | |
public String getName() { | |
return this.t; | |
} | |
} | |
public static enum Precipitation implements INamable { | |
NONE("none"), | |
RAIN("rain"), | |
SNOW("snow"); | |
public static final Codec<BiomeBase.Precipitation> d = INamable.<BiomeBase.Precipitation>a(BiomeBase.Precipitation::values, BiomeBase.Precipitation::a); | |
private static final Map<String, BiomeBase.Precipitation> e = (Map)Arrays.stream(values()).collect(Collectors.toMap(BiomeBase.Precipitation::b, (var0) -> { | |
return var0; | |
})); | |
private final String f; | |
private Precipitation(String var2) { | |
this.f = var2; | |
} | |
public String b() { | |
return this.f; | |
} | |
public static BiomeBase.Precipitation a(String var0) { | |
return (BiomeBase.Precipitation)e.get(var0); | |
} | |
public String getName() { | |
return this.f; | |
} | |
} | |
public static class a { | |
@Nullable | |
private WorldGenSurfaceComposite<?> a; | |
@Nullable | |
private BiomeBase.Precipitation b; | |
@Nullable | |
private BiomeBase.Geography c; | |
@Nullable | |
private Float d; | |
@Nullable | |
private Float e; | |
@Nullable | |
private Float f; | |
@Nullable | |
private Float g; | |
@Nullable | |
private String h; | |
@Nullable | |
private List<BiomeBase.d> i; | |
@Nullable | |
private BiomeFog j; | |
public <SC extends WorldGenSurfaceConfiguration> BiomeBase.a a(WorldGenSurface<SC> var0, SC var1) { | |
this.a = new WorldGenSurfaceComposite(var0, var1); | |
return this; | |
} | |
public BiomeBase.a a(WorldGenSurfaceComposite<?> var0) { | |
this.a = var0; | |
return this; | |
} | |
public BiomeBase.a a(BiomeBase.Precipitation var0) { | |
this.b = var0; | |
return this; | |
} | |
public BiomeBase.a a(BiomeBase.Geography var0) { | |
this.c = var0; | |
return this; | |
} | |
public BiomeBase.a a(float var0) { | |
this.d = var0; | |
return this; | |
} | |
public BiomeBase.a b(float var0) { | |
this.e = var0; | |
return this; | |
} | |
public BiomeBase.a c(float var0) { | |
this.f = var0; | |
return this; | |
} | |
public BiomeBase.a d(float var0) { | |
this.g = var0; | |
return this; | |
} | |
public BiomeBase.a a(@Nullable String var0) { | |
this.h = var0; | |
return this; | |
} | |
public BiomeBase.a a(List<BiomeBase.d> var0) { | |
this.i = var0; | |
return this; | |
} | |
public BiomeBase.a a(BiomeFog var0) { | |
this.j = var0; | |
return this; | |
} | |
public String toString() { | |
return "BiomeBuilder{\nsurfaceBuilder=" + this.a + ",\nprecipitation=" + this.b + ",\nbiomeCategory=" + this.c + ",\ndepth=" + this.d + ",\nscale=" + this.e + ",\ntemperature=" + this.f + ",\ndownfall=" + this.g + ",\nspecialEffects=" + this.j + ",\nparent='" + this.h + '\'' + "\n" + '}'; | |
} | |
} | |
public static class d { | |
public static final Codec<BiomeBase.d> a = RecordCodecBuilder.<BiomeBase.d>create((var0) -> { | |
// $FF: Couldn't be decompiled | |
}); | |
private final float b; | |
private final float c; | |
private final float d; | |
private final float e; | |
private final float f; | |
public d(float var0, float var1, float var2, float var3, float var4) { | |
this.b = var0; | |
this.c = var1; | |
this.d = var2; | |
this.e = var3; | |
this.f = var4; | |
} | |
public boolean equals(Object var0) { | |
if (this == var0) { | |
return true; | |
} else if (var0 != null && this.getClass() == var0.getClass()) { | |
BiomeBase.d var1 = (BiomeBase.d)var0; | |
if (Float.compare(var1.b, this.b) != 0) { | |
return false; | |
} else if (Float.compare(var1.c, this.c) != 0) { | |
return false; | |
} else if (Float.compare(var1.d, this.d) != 0) { | |
return false; | |
} else { | |
return Float.compare(var1.e, this.e) == 0; | |
} | |
} else { | |
return false; | |
} | |
} | |
public int hashCode() { | |
int var0 = this.b != 0.0F ? Float.floatToIntBits(this.b) : 0; | |
var0 = 31 * var0 + (this.c != 0.0F ? Float.floatToIntBits(this.c) : 0); | |
var0 = 31 * var0 + (this.d != 0.0F ? Float.floatToIntBits(this.d) : 0); | |
var0 = 31 * var0 + (this.e != 0.0F ? Float.floatToIntBits(this.e) : 0); | |
return var0; | |
} | |
public float a(BiomeBase.d var0) { | |
return (this.b - var0.b) * (this.b - var0.b) + (this.c - var0.c) * (this.c - var0.c) + (this.d - var0.d) * (this.d - var0.d) + (this.e - var0.e) * (this.e - var0.e) + (this.f - var0.f) * (this.f - var0.f); | |
} | |
} | |
public static class e { | |
private final double a; | |
private final double b; | |
public e(double var0, double var2) { | |
this.a = var0; | |
this.b = var2; | |
} | |
public double a() { | |
return this.a; | |
} | |
public double b() { | |
return this.b; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment