Move seasons data to datagen and add growth speeds for bananas, palm trees, and golden oak trees

This commit is contained in:
Sollace 2024-03-20 19:40:31 +00:00
parent 2dffb92e54
commit 3b4639d5da
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB
17 changed files with 95 additions and 90 deletions

View file

@ -3,6 +3,7 @@ package com.minelittlepony.unicopia.datagen;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import com.minelittlepony.unicopia.datagen.providers.SeasonsGrowthRatesProvider;
import com.minelittlepony.unicopia.datagen.providers.UBlockTagProvider; import com.minelittlepony.unicopia.datagen.providers.UBlockTagProvider;
import com.minelittlepony.unicopia.datagen.providers.UItemTagProvider; import com.minelittlepony.unicopia.datagen.providers.UItemTagProvider;
import com.minelittlepony.unicopia.datagen.providers.UModelProvider; import com.minelittlepony.unicopia.datagen.providers.UModelProvider;
@ -36,6 +37,7 @@ public class Datagen implements DataGeneratorEntrypoint {
pack.addProvider(UBlockLootTableProvider::new); pack.addProvider(UBlockLootTableProvider::new);
pack.addProvider(UBlockAdditionsLootTableProvider::new); pack.addProvider(UBlockAdditionsLootTableProvider::new);
pack.addProvider(UChestAdditionsLootTableProvider::new); pack.addProvider(UChestAdditionsLootTableProvider::new);
pack.addProvider(SeasonsGrowthRatesProvider::new);
} }
@Override @Override

View file

@ -0,0 +1,93 @@
package com.minelittlepony.unicopia.datagen.providers;
import java.util.concurrent.CompletableFuture;
import java.util.function.BiConsumer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.minelittlepony.unicopia.block.UBlocks;
import com.minelittlepony.unicopia.datagen.DataCollector;
import com.minelittlepony.unicopia.server.world.UTreeGen;
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.minecraft.block.Block;
import net.minecraft.data.DataOutput;
import net.minecraft.data.DataOutput.PathResolver;
import net.minecraft.registry.Registries;
import net.minecraft.data.DataProvider;
import net.minecraft.data.DataWriter;
public class SeasonsGrowthRatesProvider implements DataProvider {
private final PathResolver pathResolver;
public SeasonsGrowthRatesProvider(FabricDataOutput output) {
this.pathResolver = output.getResolver(DataOutput.OutputType.DATA_PACK, "seasons/crop");
}
@Override
public String getName() {
return "Seasons Growth Rates";
}
@Override
public CompletableFuture<?> run(DataWriter writer) {
DataCollector collectedData = new DataCollector(pathResolver);
var exporter = collectedData.prime();
generate((block, crop) -> {
exporter.accept(Registries.BLOCK.getId(block), crop::toJson);
});
return collectedData.upload(writer);
}
private void generate(BiConsumer<Block, Crop> exporter) {
Crop greenApple = new Crop(0.5F, 0.6F, 1, 0);
exporter.accept(UBlocks.GREEN_APPLE_LEAVES, greenApple);
exporter.accept(UBlocks.GREEN_APPLE_SPROUT, greenApple);
exporter.accept(UTreeGen.GREEN_APPLE_TREE.sapling().get(), greenApple);
Crop sourApple = new Crop(0.25F, 0.5F, 1, 0.5F);
exporter.accept(UBlocks.SOUR_APPLE_LEAVES, sourApple);
exporter.accept(UBlocks.SOUR_APPLE_SPROUT, sourApple);
exporter.accept(UTreeGen.SOUR_APPLE_TREE.sapling().get(), sourApple);
Crop sweetApple = new Crop(1, 1, 0.6F, 0);
exporter.accept(UBlocks.SWEET_APPLE_LEAVES, sweetApple);
exporter.accept(UBlocks.SWEET_APPLE_SPROUT, sweetApple);
exporter.accept(UTreeGen.SWEET_APPLE_TREE.sapling().get(), sweetApple);
Crop goldenOak = new Crop(1.5F, 1.4F, 0.6F, 0);
exporter.accept(UBlocks.GOLDEN_OAK_LEAVES, goldenOak);
exporter.accept(UBlocks.GOLDEN_OAK_SPROUT, goldenOak);
exporter.accept(UTreeGen.GOLDEN_APPLE_TREE.sapling().get(), goldenOak);
Crop palm = new Crop(1.1F, 0.9F, 0.2F, 0);
exporter.accept(UBlocks.PALM_LEAVES, palm);
exporter.accept(UBlocks.BANANAS, palm);
exporter.accept(UTreeGen.BANANA_TREE.sapling().get(), palm);
Crop mango = new Crop(1, 1.6F, 0.5F, 0);
exporter.accept(UBlocks.MANGO_LEAVES, mango);
exporter.accept(UTreeGen.MANGO_TREE.sapling().get(), mango);
Crop oats = new Crop(0.6F, 1, 1, 0);
exporter.accept(UBlocks.OATS_CROWN, oats);
exporter.accept(UBlocks.OATS_STEM, oats);
exporter.accept(UBlocks.OATS, oats);
exporter.accept(UBlocks.ROCKS, new Crop(1, 1, 1, 1));
exporter.accept(UBlocks.PINEAPPLE, palm);
}
record Crop(float spring, float summer, float fall, float winter) {
JsonElement toJson() {
JsonObject json = new JsonObject();
json.addProperty("spring", spring);
json.addProperty("summer", summer);
json.addProperty("winter", winter);
json.addProperty("fall", fall);
return json;
}
}
}

View file

@ -1,6 +0,0 @@
{
"spring": 0.5,
"summer": 0.6,
"fall": 1.0,
"winter": 0
}

View file

@ -1,6 +0,0 @@
{
"spring": 0.5,
"summer": 0.6,
"fall": 1.0,
"winter": 0
}

View file

@ -1,6 +0,0 @@
{
"spring": 0.5,
"summer": 0.6,
"fall": 1.0,
"winter": 0
}

View file

@ -1,6 +0,0 @@
{
"spring": 1.0,
"summer": 1.6,
"fall": 0.5,
"winter": 0
}

View file

@ -1,6 +0,0 @@
{
"spring": 1.0,
"summer": 1.6,
"fall": 0.5,
"winter": 0
}

View file

@ -1,6 +0,0 @@
{
"spring": 0.6,
"summer": 1.0,
"fall": 1.0,
"winter": 0
}

View file

@ -1,6 +0,0 @@
{
"spring": 0.6,
"summer": 1.0,
"fall": 1.0,
"winter": 0
}

View file

@ -1,6 +0,0 @@
{
"spring": 0.6,
"summer": 1.0,
"fall": 1.0,
"winter": 0
}

View file

@ -1,6 +0,0 @@
{
"spring": 1.0,
"summer": 1.0,
"fall": 1.0,
"winter": 1.0
}

View file

@ -1,6 +0,0 @@
{
"spring": 0.25,
"summer": 0.5,
"fall": 1.0,
"winter": 0.5
}

View file

@ -1,6 +0,0 @@
{
"spring": 0.25,
"summer": 0.5,
"fall": 1.0,
"winter": 0.5
}

View file

@ -1,6 +0,0 @@
{
"spring": 0.25,
"summer": 0.5,
"fall": 1.0,
"winter": 0.5
}

View file

@ -1,6 +0,0 @@
{
"spring": 1.0,
"summer": 1.0,
"fall": 0.6,
"winter": 0
}

View file

@ -1,6 +0,0 @@
{
"spring": 1.0,
"summer": 1.0,
"fall": 0.6,
"winter": 0
}

View file

@ -1,6 +0,0 @@
{
"spring": 1.0,
"summer": 1.0,
"fall": 0.6,
"winter": 0
}