mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-12-22 19:39:24 +01:00
Add crops to villages
This commit is contained in:
parent
3f356896b7
commit
e6c8af19af
4 changed files with 63 additions and 4 deletions
|
@ -26,6 +26,7 @@ import de.ellpeck.actuallyadditions.mod.entity.EntityWorm;
|
|||
import de.ellpeck.actuallyadditions.mod.entity.InitEntities;
|
||||
import de.ellpeck.actuallyadditions.mod.event.CommonEvents;
|
||||
import de.ellpeck.actuallyadditions.mod.fluids.InitFluids;
|
||||
import de.ellpeck.actuallyadditions.mod.gen.ActuallyVillageCrops;
|
||||
import de.ellpeck.actuallyadditions.mod.gen.modifier.BoolConfigFeatureBiomeModifier;
|
||||
import de.ellpeck.actuallyadditions.mod.inventory.ActuallyContainers;
|
||||
import de.ellpeck.actuallyadditions.mod.items.ActuallyItems;
|
||||
|
@ -124,6 +125,7 @@ public class ActuallyAdditions {
|
|||
// NeoForge.EVENT_BUS.register(new DungeonLoot());
|
||||
NeoForge.EVENT_BUS.addListener(ActuallyAdditions::reloadEvent);
|
||||
NeoForge.EVENT_BUS.addListener(Worm::onHoe);
|
||||
NeoForge.EVENT_BUS.addListener(ActuallyVillageCrops::addNewVillageCrop);
|
||||
InitFluids.init(eventBus);
|
||||
|
||||
eventBus.addListener(PacketHandler::register);
|
||||
|
|
|
@ -313,10 +313,10 @@ public final class ActuallyBlocks {
|
|||
(b) -> new AABlockItem(b, defaultBlockItemProperties));
|
||||
|
||||
|
||||
public static Supplier<Block> CANOLA = BLOCKS.register("canola", () -> new AACrops(defaultCropProps(), ActuallyItems.CANOLA_SEEDS));
|
||||
public static Supplier<Block> RICE = BLOCKS.register("rice", () -> new AACrops(defaultCropProps(), ActuallyItems.RICE_SEEDS));
|
||||
public static Supplier<Block> FLAX = BLOCKS.register("flax", () -> new AACrops(defaultCropProps(), ActuallyItems.FLAX_SEEDS));
|
||||
public static Supplier<Block> COFFEE = BLOCKS.register("coffee", () -> new AACrops(defaultCropProps(), ActuallyItems.COFFEE_BEANS));
|
||||
public static Supplier<AACrops> CANOLA = BLOCKS.register("canola", () -> new AACrops(defaultCropProps(), ActuallyItems.CANOLA_SEEDS));
|
||||
public static Supplier<AACrops> RICE = BLOCKS.register("rice", () -> new AACrops(defaultCropProps(), ActuallyItems.RICE_SEEDS));
|
||||
public static Supplier<AACrops> FLAX = BLOCKS.register("flax", () -> new AACrops(defaultCropProps(), ActuallyItems.FLAX_SEEDS));
|
||||
public static Supplier<AACrops> COFFEE = BLOCKS.register("coffee", () -> new AACrops(defaultCropProps(), ActuallyItems.COFFEE_BEANS));
|
||||
|
||||
public static final AABlockReg<BlockGreenhouseGlass, AABlockItem, ?> GREENHOUSE_GLASS = new AABlockReg<>("greenhouse_glass", BlockGreenhouseGlass::new,
|
||||
(b) -> new AABlockItem(b, defaultBlockItemProperties));
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
package de.ellpeck.actuallyadditions.mod.gen;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.AlwaysTrueTest;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.ProcessorRule;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.RandomBlockMatchTest;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.RuleProcessor;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessor;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessorList;
|
||||
import net.neoforged.neoforge.event.server.ServerAboutToStartEvent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ActuallyVillageCrops {
|
||||
|
||||
public static void addNewVillageCrop(final ServerAboutToStartEvent event) {
|
||||
Registry<StructureProcessorList> processorListRegistry = event.getServer().registryAccess().registry(Registries.PROCESSOR_LIST).orElseThrow();
|
||||
|
||||
StructureProcessor cropProcessor = new RuleProcessor(List.of(
|
||||
new ProcessorRule(new RandomBlockMatchTest(Blocks.WHEAT, 0.30F), AlwaysTrueTest.INSTANCE, ActuallyBlocks.RICE.get().defaultBlockState()),
|
||||
new ProcessorRule(new RandomBlockMatchTest(Blocks.WHEAT, 0.25F), AlwaysTrueTest.INSTANCE, ActuallyBlocks.COFFEE.get().defaultBlockState()),
|
||||
new ProcessorRule(new RandomBlockMatchTest(Blocks.WHEAT, 0.10F), AlwaysTrueTest.INSTANCE, ActuallyBlocks.CANOLA.get().defaultBlockState()),
|
||||
new ProcessorRule(new RandomBlockMatchTest(Blocks.WHEAT, 0.05F), AlwaysTrueTest.INSTANCE, ActuallyBlocks.FLAX.get().defaultBlockState())
|
||||
));
|
||||
|
||||
addNewRuleToProcessorList(new ResourceLocation("minecraft:farm_plains"), cropProcessor, processorListRegistry);
|
||||
addNewRuleToProcessorList(new ResourceLocation("minecraft:farm_savanna"), cropProcessor, processorListRegistry);
|
||||
addNewRuleToProcessorList(new ResourceLocation("minecraft:farm_snowy"), cropProcessor, processorListRegistry);
|
||||
addNewRuleToProcessorList(new ResourceLocation("minecraft:farm_taiga"), cropProcessor, processorListRegistry);
|
||||
addNewRuleToProcessorList(new ResourceLocation("minecraft:farm_desert"), cropProcessor, processorListRegistry);
|
||||
|
||||
// Can target other mod's processor lists
|
||||
addNewRuleToProcessorList(new ResourceLocation("repurposed_structures:villages/badlands/crop_replacement"), cropProcessor, processorListRegistry);
|
||||
addNewRuleToProcessorList(new ResourceLocation("repurposed_structures:villages/birch/crop_randomizer"), cropProcessor, processorListRegistry);
|
||||
addNewRuleToProcessorList(new ResourceLocation("repurposed_structures:villages/dark_forest/crop_randomizer"), cropProcessor, processorListRegistry);
|
||||
addNewRuleToProcessorList(new ResourceLocation("repurposed_structures:villages/giant_taiga/crop_randomizer"), cropProcessor, processorListRegistry);
|
||||
addNewRuleToProcessorList(new ResourceLocation("repurposed_structures:villages/jungle/crop_randomizer"), cropProcessor, processorListRegistry);
|
||||
addNewRuleToProcessorList(new ResourceLocation("repurposed_structures:villages/mountains/crop_randomizer"), cropProcessor, processorListRegistry);
|
||||
addNewRuleToProcessorList(new ResourceLocation("repurposed_structures:villages/oak/crop_randomizer"), cropProcessor, processorListRegistry);
|
||||
addNewRuleToProcessorList(new ResourceLocation("repurposed_structures:villages/swamp/crop_randomizer"), cropProcessor, processorListRegistry);
|
||||
}
|
||||
|
||||
private static void addNewRuleToProcessorList(ResourceLocation targetProcessorList, StructureProcessor processorToAdd, Registry<StructureProcessorList> processorListRegistry) {
|
||||
processorListRegistry.getOptional(targetProcessorList)
|
||||
.ifPresent(processorList -> {
|
||||
List<StructureProcessor> newSafeList = new ArrayList<>(processorList.list());
|
||||
newSafeList.add(processorToAdd);
|
||||
processorList.list = newSafeList; //Have to use an AT to be able to modify the list (or Accessor Mixin)
|
||||
});
|
||||
}
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
public net.minecraft.world.damagesource.DamageSources *() # DamageSources
|
||||
public net.minecraft.world.damagesource.DamageSources damageTypes
|
||||
public-f net.minecraft.data.recipes.RecipeProvider getName()Ljava/lang/String;
|
||||
public-f net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessorList list
|
||||
public net.minecraft.world.item.crafting.ShapedRecipe pattern # pattern
|
Loading…
Reference in a new issue