Skip to content

Commit

Permalink
Committing fixes in the dark, seriously, who killed my power!?
Browse files Browse the repository at this point in the history
  • Loading branch information
Yoghurt4C committed Mar 13, 2022
1 parent c3c6715 commit faf493a
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 80 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ dependencies {


//modImplementation "io.github.prospector:modmenu:${project.mod_menu_version}"
modImplementation ("me.shedaniel:RoughlyEnoughItems-fabric:${project.rei_version}") { exclude(module: "ModMenu") }
//modImplementation ("me.shedaniel:RoughlyEnoughItems-fabric:${project.rei_version}") { exclude(module: "ModMenu") }

implementation 'org.jetbrains:annotations:15.0'
compileOnly "com.google.code.findbugs:jsr305:3.0.2"
Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
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
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public ActionResult useOnBlock(ItemUsageContext context) {
BlockPos pos = context.getBlockPos();
final int range = 3;
Block block = world.getBlockState(pos).getBlock();
if (BlockTags.BAMBOO_PLANTABLE_ON.contains(block)) {
if (block.getRegistryEntry().isIn(BlockTags.BAMBOO_PLANTABLE_ON)) {
if (!world.isClient) {
List<BlockPos> validPosList = new ArrayList<>();

Expand Down
11 changes: 11 additions & 0 deletions src/main/java/mods/flonters/mixins/BiomeCategoryAccessor.java
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 src/main/java/mods/flonters/registry/FlontersGenerator.java
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));
}*/
}
3 changes: 2 additions & 1 deletion src/main/resources/mixins.flonters.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"package": "mods.flonters.mixins",
"compatibilityLevel": "JAVA_8",
"mixins": [
"FlowerPotMixin"
"FlowerPotMixin",
"BiomeCategoryAccessor"
],
"injectors": {
"defaultRequire": 1
Expand Down

0 comments on commit faf493a

Please sign in to comment.