-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Committing fixes in the dark, seriously, who killed my power!?
- Loading branch information
Showing
6 changed files
with
34 additions
and
80 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
#Done to increase the memory available to gradle. | ||
org.gradle.jvmargs=-Xmx4G | ||
|
||
version=1.3.0 | ||
version=1.3.1 | ||
modid=flonters | ||
mod_name=Flonters | ||
|
||
minecraft_version=1.18.1 | ||
yarn_mappings=1.18.1+build.18 | ||
loader_version=0.12.12 | ||
minecraft_version=1.18.2 | ||
yarn_mappings=1.18.2+build.2 | ||
loader_version=0.13.3 | ||
|
||
#Fabric api | ||
fabric_version=0.46.0+1.18 | ||
fabric_version=0.47.10+1.18.2 | ||
mod_menu_version=3.0.1 | ||
rei_version=7.1.380 |
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
11 changes: 11 additions & 0 deletions
11
src/main/java/mods/flonters/mixins/BiomeCategoryAccessor.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package mods.flonters.mixins; | ||
|
||
import net.minecraft.world.biome.Biome; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.gen.Accessor; | ||
|
||
@Mixin(Biome.class) | ||
public interface BiomeCategoryAccessor { | ||
@Accessor("category") | ||
Biome.Category getCategory(); | ||
} |
86 changes: 14 additions & 72 deletions
86
src/main/java/mods/flonters/registry/FlontersGenerator.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,96 +1,38 @@ | ||
package mods.flonters.registry; | ||
|
||
import mods.flonters.mixins.BiomeCategoryAccessor; | ||
import mods.flonters.properties.FlontersProperties; | ||
import mods.flonters.world.FlontersFeature; | ||
import mods.flonters.world.FlontersFeatureConfig; | ||
import net.fabricmc.fabric.api.biome.v1.BiomeModifications; | ||
import net.minecraft.util.registry.BuiltinRegistries; | ||
import net.minecraft.util.Identifier; | ||
import net.minecraft.util.registry.Registry; | ||
import net.minecraft.util.registry.RegistryKey; | ||
import net.minecraft.world.biome.Biome; | ||
import net.minecraft.world.gen.GenerationStep; | ||
import net.minecraft.world.gen.feature.ConfiguredFeature; | ||
import net.minecraft.world.gen.feature.Feature; | ||
import net.minecraft.world.gen.feature.ConfiguredFeatures; | ||
import net.minecraft.world.gen.feature.PlacedFeature; | ||
import net.minecraft.world.gen.feature.PlacedFeatures; | ||
|
||
import static mods.flonters.Flonters.getId; | ||
|
||
public class FlontersGenerator { | ||
public static final Feature<FlontersFeatureConfig> PATCH_O_FLONTERS = new FlontersFeature(); | ||
public static final ConfiguredFeature<?, ?> CONFIGURED_PATCH = PATCH_O_FLONTERS.configure(new FlontersFeatureConfig()); | ||
public static final PlacedFeature PLACED_PATCH = CONFIGURED_PATCH.withPlacement(); | ||
public static final RegistryKey<PlacedFeature> PATCH_O_FLONTERS = RegistryKey.of(Registry.PLACED_FEATURE_KEY, getId("patch_o_flonters")); | ||
|
||
public static void init() { | ||
Registry.register(Registry.FEATURE, getId("patch_o_flonters"), PATCH_O_FLONTERS); | ||
Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, getId("patch_o_flonters"), CONFIGURED_PATCH); | ||
Registry.register(BuiltinRegistries.PLACED_FEATURE, getId("patch_o_flonters"), PLACED_PATCH); | ||
Identifier id = getId("patch_o_flonters"); | ||
FlontersFeature feature = Registry.register(Registry.FEATURE, id, new FlontersFeature()); | ||
var cf = ConfiguredFeatures.register(id.toString(), feature, new FlontersFeatureConfig()); | ||
PlacedFeatures.register(id.toString(), cf); | ||
|
||
if (FlontersProperties.flonterPatchQuantity > 0) { | ||
BiomeModifications.addFeature(ctx -> { | ||
Biome.Category category = ctx.getBiome().getCategory(); | ||
Biome biome = ctx.getBiome(); | ||
Biome.Category category = ((BiomeCategoryAccessor) (Object) biome).getCategory(); | ||
return category != Biome.Category.NETHER && category != Biome.Category.THEEND; | ||
}, | ||
GenerationStep.Feature.VEGETAL_DECORATION, | ||
BuiltinRegistries.PLACED_FEATURE.getKey(PLACED_PATCH).orElseThrow()); | ||
} | ||
} | ||
/* | ||
private static final List<Biome> checkedBiomes = new ArrayList<>(); | ||
@Nullable | ||
public static LegallyDistinctWorldGenConfig config; | ||
public static <F extends FeatureConfig, D extends DecoratorConfig> ConfiguredFeature<?, ?> configureFeature(Feature<F> feature, F featureConfig, Decorator<D> decorator, D decoratorConfig) { | ||
Feature<DecoratedFeatureConfig> feature2 = feature instanceof FlowerFeature ? Feature.DECORATED : Feature.DECORATED; | ||
return new ConfiguredFeature<>(feature2, new DecoratedFeatureConfig(() -> feature.configure(featureConfig), decorator.configure(decoratorConfig))); | ||
} | ||
public static final Feature<FlontersFeatureConfig> PATCH_O_FLONTERS = register("patch_o_flonters", new FlontersFeature(FlontersFeatureConfig.CODEC)); | ||
public static <C extends FeatureConfig, F extends Feature<C>> F register(String name, F feature) { | ||
return Registry.register(Registry.FEATURE, Flonters.getId(name), feature); | ||
} | ||
private static void handleBiome(Biome biome, LegallyDistinctWorldGenConfig config) { | ||
if (checkedBiomes.contains(biome)) { | ||
return; | ||
} | ||
checkedBiomes.add(biome); | ||
if (biome.getCategory() != Biome.Category.NETHER && biome.getCategory() != Biome.Category.THEEND) { | ||
addFeature(biome, Flonters.getId("patch_o_flonters"), GenerationStep.Feature.VEGETAL_DECORATION, config.getFlonterPatch()); | ||
} | ||
} | ||
private static void addFeature(Biome biome, Identifier identifier, GenerationStep.Feature feature, ConfiguredFeature<?, ?> configuredFeature) { | ||
List<List<Supplier<PlacedFeature>>> features = biome.getGenerationSettings().getFeatures(); | ||
int stepIndex = feature.ordinal(); | ||
while (features.size() <= stepIndex) { | ||
features.add(Lists.newArrayList()); | ||
} | ||
List<Supplier<PlacedFeature>> stepList = features.get(feature.ordinal()); | ||
if (stepList instanceof ImmutableList) { | ||
features.set(feature.ordinal(), stepList = new ArrayList<>(stepList)); | ||
} | ||
if (BuiltinRegistries.CONFIGURED_FEATURE.getKey(configuredFeature).isEmpty()) { | ||
if (BuiltinRegistries.CONFIGURED_FEATURE.getOrEmpty(identifier).isPresent()) { | ||
throw new RuntimeException("[Flonters] :) : " + identifier.toString()); | ||
} else { | ||
BuiltinRegistries.add(BuiltinRegistries.CONFIGURED_FEATURE, identifier, configuredFeature); | ||
} | ||
PATCH_O_FLONTERS); | ||
} | ||
stepList.add(() -> configuredFeature); | ||
} | ||
public static void init() { | ||
config = new LegallyDistinctWorldGenConfig(configureFeature(PATCH_O_FLONTERS, new FlontersFeatureConfig(), Decorator.NOPE, NopeDecoratorConfig.DEFAULT)); | ||
for (Biome biome : BuiltinRegistries.BIOME) { | ||
handleBiome(biome, config); | ||
} | ||
RegistryEntryAddedCallback.event(BuiltinRegistries.BIOME).register((i, identifier, biome) -> handleBiome(biome, config)); | ||
}*/ | ||
} |
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