Last active
September 10, 2020 20:27
-
-
Save CorgiTaco/3eb2d9128a1ec41bd5d5846d17994851 to your computer and use it in GitHub Desktop.
A few cheat sheets for those porting to 1.16.2 :)
This file contains hidden or 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
accessWidener v1 named | |
#These are the required Access Wideners for all files within this gist | |
mutable field net/minecraft/world/biome/layer/SetBaseBiomesLayer DRY_BIOMES [I | |
accessible field net/minecraft/world/biome/layer/SetBaseBiomesLayer DRY_BIOMES [I | |
mutable field net/minecraft/world/biome/layer/SetBaseBiomesLayer COOL_BIOMES [I | |
accessible field net/minecraft/world/biome/layer/SetBaseBiomesLayer COOL_BIOMES [I | |
mutable field net/minecraft/world/biome/layer/SetBaseBiomesLayer TEMPERATE_BIOMES [I | |
accessible field net/minecraft/world/biome/layer/SetBaseBiomesLayer TEMPERATE_BIOMES [I | |
mutable field net/minecraft/world/biome/layer/SetBaseBiomesLayer SNOWY_BIOMES [I | |
accessible field net/minecraft/world/biome/layer/SetBaseBiomesLayer SNOWY_BIOMES [I | |
accessible class net/minecraft/world/biome/Biome | |
extendable class net/minecraft/world/biome/Biome | |
accessible method net/minecraft/world/biome/Biome <init> (Lnet/minecraft/world/biome/Biome$Weather;Lnet/minecraft/world/biome/Biome$Category;FFLnet/minecraft/world/biome/BiomeEffects;Lnet/minecraft/world/biome/GenerationSettings;Lnet/minecraft/world/biome/SpawnSettings;)V | |
mutable field net/minecraft/world/biome/Biomes BIOMES Lit/unimi/dsi/fastutil/ints/Int2ObjectMap; | |
accessible field net/minecraft/world/biome/Biomes BIOMES Lit/unimi/dsi/fastutil/ints/Int2ObjectMap; | |
accessible class net/minecraft/world/biome/Biome$Weather | |
extendable class net/minecraft/world/biome/Biome$Weather | |
accessible method net/minecraft/world/biome/Biome$Weather <init> (Lnet/minecraft/world/biome/Biome$Precipitation;FLnet/minecraft/world/biome/Biome$TemperatureModifier;F)V | |
mutable field net/minecraft/world/biome/GenerationSettings features Ljava/util/List; | |
accessible field net/minecraft/world/biome/GenerationSettings features Ljava/util/List; |
This file contains hidden or 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
/* | |
MIT License | |
Copyright (c) 2020 Corgi Taco | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is | |
furnished to do so, subject to the following conditions: | |
The above copyright notice and this permission notice shall be included in all | |
copies or substantial portions of the Software. | |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
SOFTWARE. | |
*/ | |
import net.minecraft.entity.EntityType; | |
import net.minecraft.entity.SpawnGroup; | |
import net.minecraft.sound.BiomeMoodSound; | |
import net.minecraft.util.Identifier; | |
import net.minecraft.util.math.MathHelper; | |
import net.minecraft.util.registry.BuiltinRegistries; | |
import net.minecraft.util.registry.Registry; | |
import net.minecraft.world.biome.Biome; | |
import net.minecraft.world.biome.BiomeEffects; | |
import net.minecraft.world.biome.GenerationSettings; | |
import net.minecraft.world.biome.SpawnSettings; | |
import net.minecraft.world.gen.feature.DefaultBiomeFeatures; | |
import net.minecraft.world.gen.surfacebuilder.ConfiguredSurfaceBuilder; | |
import net.minecraft.world.gen.surfacebuilder.SurfaceBuilder; | |
//Making a biome with a class: | |
public class Plains extends Biome { | |
static final ConfiguredSurfaceBuilder<?> SURFACE_BUILDER = newConfiguredSurfaceBuilder("plains", new ConfiguredSurfaceBuilder<>(SurfaceBuilder.DEFAULT, SurfaceBuilder.GRASS_CONFIG)); | |
static final Precipitation PRECIPATATION = Precipitation.RAIN; | |
static final Category CATEGORY = Category.PLAINS; | |
static final float DEPTH = 0.125F; | |
static final float SCALE = 0.05F; | |
static final float TEMPERATURE = 0.8F; | |
static final float DOWNFALL = 0.4F; | |
static final int WATER_COLOR = 4159204; | |
static final int WATER_FOG_COLOR = 329011; | |
static final Weather WEATHER = new Weather(PRECIPATATION, TEMPERATURE, TemperatureModifier.NONE, DOWNFALL); | |
static final SpawnSettings.Builder SPAWN_SETTINGS = new SpawnSettings.Builder(); | |
static final GenerationSettings.Builder GENERATION_SETTINGS = (new GenerationSettings.Builder()).surfaceBuilder(SURFACE_BUILDER); | |
public Plains() { | |
super(WEATHER, CATEGORY, DEPTH, SCALE, (new BiomeEffects.Builder()).waterColor(WATER_COLOR).waterFogColor(WATER_FOG_COLOR).fogColor(12638463).skyColor(calcSkyColor(0.8F)).moodSound(BiomeMoodSound.CAVE).build(), GENERATION_SETTINGS.build(), SPAWN_SETTINGS.build()); | |
} | |
//Reason: We need to call this statically before the class is constructed to add our biomes to the Generation Settings `feature` list on time and mob spawns to the Spawn Settings `spawners` map. | |
//Why: Using the constructor it'd fire too late and never add the features/spawners to these lists. | |
static { | |
DefaultBiomeFeatures.addLandCarvers(GENERATION_SETTINGS); | |
DefaultBiomeFeatures.addDefaultLakes(GENERATION_SETTINGS); | |
DefaultBiomeFeatures.addDungeons(GENERATION_SETTINGS); | |
DefaultBiomeFeatures.addPlainsTallGrass(GENERATION_SETTINGS); | |
DefaultBiomeFeatures.addMineables(GENERATION_SETTINGS); | |
DefaultBiomeFeatures.addDefaultOres(GENERATION_SETTINGS); | |
DefaultBiomeFeatures.addDefaultDisks(GENERATION_SETTINGS); | |
DefaultBiomeFeatures.addPlainsFeatures(GENERATION_SETTINGS); | |
DefaultBiomeFeatures.addDefaultMushrooms(GENERATION_SETTINGS); | |
DefaultBiomeFeatures.addDefaultVegetation(GENERATION_SETTINGS); | |
DefaultBiomeFeatures.addSprings(GENERATION_SETTINGS); | |
DefaultBiomeFeatures.addFrozenTopLayer(GENERATION_SETTINGS); | |
SPAWN_SETTINGS.spawn(SpawnGroup.CREATURE, new SpawnSettings.SpawnEntry(EntityType.SHEEP, 12, 4, 4)); | |
SPAWN_SETTINGS.spawn(SpawnGroup.CREATURE, new SpawnSettings.SpawnEntry(EntityType.PIG, 10, 4, 4)); | |
SPAWN_SETTINGS.spawn(SpawnGroup.CREATURE, new SpawnSettings.SpawnEntry(EntityType.CHICKEN, 10, 4, 4)); | |
SPAWN_SETTINGS.spawn(SpawnGroup.CREATURE, new SpawnSettings.SpawnEntry(EntityType.COW, 8, 4, 4)); | |
SPAWN_SETTINGS.spawn(SpawnGroup.CREATURE, new SpawnSettings.SpawnEntry(EntityType.WOLF, 5, 4, 4)); | |
SPAWN_SETTINGS.spawn(SpawnGroup.AMBIENT, new SpawnSettings.SpawnEntry(EntityType.BAT, 10, 8, 8)); | |
SPAWN_SETTINGS.spawn(SpawnGroup.MONSTER, new SpawnSettings.SpawnEntry(EntityType.SPIDER, 100, 4, 4)); | |
SPAWN_SETTINGS.spawn(SpawnGroup.MONSTER, new SpawnSettings.SpawnEntry(EntityType.ZOMBIE, 95, 4, 4)); | |
SPAWN_SETTINGS.spawn(SpawnGroup.MONSTER, new SpawnSettings.SpawnEntry(EntityType.ZOMBIE_VILLAGER, 5, 1, 1)); | |
SPAWN_SETTINGS.spawn(SpawnGroup.MONSTER, new SpawnSettings.SpawnEntry(EntityType.SKELETON, 100, 4, 4)); | |
SPAWN_SETTINGS.spawn(SpawnGroup.MONSTER, new SpawnSettings.SpawnEntry(EntityType.CREEPER, 100, 4, 4)); | |
SPAWN_SETTINGS.spawn(SpawnGroup.MONSTER, new SpawnSettings.SpawnEntry(EntityType.SLIME, 100, 4, 4)); | |
SPAWN_SETTINGS.spawn(SpawnGroup.MONSTER, new SpawnSettings.SpawnEntry(EntityType.ENDERMAN, 10, 1, 4)); | |
SPAWN_SETTINGS.spawn(SpawnGroup.MONSTER, new SpawnSettings.SpawnEntry(EntityType.WITCH, 5, 1, 1)); | |
} | |
//Vanilla uses this for sky color. | |
public static int calcSkyColor(float f) { | |
float g = f / 3.0F; | |
g = MathHelper.clamp(g, -1.0F, 1.0F); | |
return MathHelper.hsvToRgb(0.62222224F - g * 0.05F, 0.5F + g * 0.1F, 1.0F); | |
} | |
public static ConfiguredSurfaceBuilder<?> newConfiguredSurfaceBuilder(String id, ConfiguredSurfaceBuilder<?> configuredSurfaceBuilder) { | |
Registry.register(BuiltinRegistries.CONFIGURED_SURFACE_BUILDER, new Identifier(MODID, id), configuredSurfaceBuilder); | |
return configuredSurfaceBuilder; | |
} | |
} |
This file contains hidden or 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
/* | |
MIT License | |
Copyright (c) 2020 Corgi Taco | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is | |
furnished to do so, subject to the following conditions: | |
The above copyright notice and this permission notice shall be included in all | |
copies or substantial portions of the Software. | |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
SOFTWARE. | |
*/ | |
import com.google.common.collect.ImmutableList; | |
import com.google.common.collect.Lists; | |
import net.minecraft.util.Identifier; | |
import net.minecraft.util.registry.BuiltinRegistries; | |
import net.minecraft.util.registry.Registry; | |
import net.minecraft.util.registry.RegistryKey; | |
import net.minecraft.world.biome.Biome; | |
import net.minecraft.world.biome.Biomes; | |
import net.minecraft.world.biome.layer.SetBaseBiomesLayer; | |
import net.minecraft.world.gen.GenerationStep; | |
import net.minecraft.world.gen.feature.ConfiguredFeature; | |
import java.util.ArrayList; | |
import java.util.Arrays; | |
import java.util.List; | |
import java.util.Optional; | |
import java.util.function.Supplier; | |
import java.util.stream.Collectors; | |
public class WorldGenCheatSheetFabric1162 { | |
/***************************************Adding Features to vanilla(or any other biomes outside the scope of your mod) - Credit: Linguardium***************************************/ | |
// | |
public static void addFeatureToBiome(Biome biome, GenerationStep.Feature feature, ConfiguredFeature<?, ?> configuredFeature) { | |
convertImmutableFeatures(biome); | |
List<List<Supplier<ConfiguredFeature<?, ?>>>> biomeFeatures = biome.getGenerationSettings().features; | |
while (biomeFeatures.size() <= feature.ordinal()) { | |
biomeFeatures.add(Lists.newArrayList()); | |
} | |
biomeFeatures.get(feature.ordinal()).add(() -> configuredFeature); | |
} | |
//Swap the list to mutable in order for us to add our features with ease. | |
private static void convertImmutableFeatures(Biome biome) { | |
if (biome.getGenerationSettings().features instanceof ImmutableList) { | |
biome.getGenerationSettings().features = biome.getGenerationSettings().features.stream().map(Lists::newArrayList).collect(Collectors.toList()); | |
} | |
} | |
/***************************************Adding Biomes to the vanilla overworld/***************************************/ | |
//Add biomes/Biome keys you register to a list like this or similar. | |
public static List<Biome> biomeList = new ArrayList<>(); | |
//Sorted Lists used for adding biomes to vanilla worldtype's. | |
public static List<Integer> HOT = new ArrayList<>(); | |
public static List<Integer> COOL = new ArrayList<>(); | |
public static List<Integer> WARM = new ArrayList<>(); | |
public static List<Integer> ICY = new ArrayList<>(); | |
//Why? This is how worldtype's using the BiomeLayerSampler get the numerical ID's from the biome's key to sample. | |
//Reason: Biomes available for the Layer sampler only contain vanilla values so we add to this list by mapping the key w/ the numerical ID. | |
public static void addBiomeNumericalIDs() { | |
for (Biome biome : biomeList) { | |
Optional<RegistryKey<Biome>> key = BuiltinRegistries.BIOME.getKey(biome); | |
key.ifPresent(biomeRegistryKey -> Biomes.BIOMES.put(BuiltinRegistries.BIOME.getRawId(biome), biomeRegistryKey)); | |
} | |
} | |
//Enum used for sorting our biomes into their appropriate lists/biome categories. | |
public enum OverworldClimate {SNOWY, COOL, TEMPERATE, DRY} | |
//This registers biomes using the biome's object. | |
private static void registerBiome(Biome biome, String id, boolean spawn, float weight, OverworldClimate type) { | |
Registry.register(BuiltinRegistries.BIOME, new Identifier(MODID, id), biome); | |
biomeList.add(biome); | |
if (weight > 0) { | |
if (type == OverworldClimate.TEMPERATE) | |
WARM.add(BuiltinRegistries.BIOME.getRawId(biome)); | |
if (type == OverworldClimate.COOL) | |
COOL.add(BuiltinRegistries.BIOME.getRawId(biome)); | |
if (type == .OverworldClimate.DRY) | |
HOT.add(BuiltinRegistries.BIOME.getRawId(biome)); | |
if (type == OverworldClimate.SNOWY) | |
ICY.add(BuiltinRegistries.BIOME.getRawId(biome)); | |
} | |
} | |
//Reason: We add our biomes to the public static int arrays for each category and this lets us spawn our biomes in vanilla worldtypes. | |
//Why: This should only ever be used if the mod api you're using is outdated. | |
public static void addBiomesToVanillaOverworld() { | |
for (int dryID : HOT) | |
SetBaseBiomesLayer.DRY_BIOMES = addBiomeElement(SetBaseBiomesLayer.DRY_BIOMES, dryID); | |
for (int temperateID : WARM) | |
SetBaseBiomesLayer.TEMPERATE_BIOMES = addBiomeElement(SetBaseBiomesLayer.TEMPERATE_BIOMES, temperateID); | |
for (int coolID : COOL) | |
SetBaseBiomesLayer.COOL_BIOMES = addBiomeElement(SetBaseBiomesLayer.COOL_BIOMES, coolID); | |
for (int snowyID : ICY) | |
SetBaseBiomesLayer.SNOWY_BIOMES = addBiomeElement(SetBaseBiomesLayer.SNOWY_BIOMES, snowyID); | |
} | |
static int[] addBiomeElement(int[] a, int e) { | |
a = Arrays.copyOf(a, a.length + 1); | |
a[a.length - 1] = e; | |
return a; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment