Skip to content

Commit

Permalink
Data Generators
Browse files Browse the repository at this point in the history
  • Loading branch information
ktpatient committed May 3, 2024
1 parent 23c6fe3 commit 6680bd7
Show file tree
Hide file tree
Showing 17 changed files with 321 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ run

# Files from Forge MDK
forge*changelog.txt

run-data
25 changes: 25 additions & 0 deletions run-data/config/fml.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#Early window height
earlyWindowHeight = 480
#Early window framebuffer scale
earlyWindowFBScale = 1
#Enable forge global version checking
versionCheck = true
#Early window provider
earlyWindowProvider = "fmlearlywindow"
#Early window width
earlyWindowWidth = 854
#Early window starts maximized
earlyWindowMaximized = false
#Default config path for servers
defaultConfigPath = "defaultconfigs"
#Disables Optimized DFU client-side - already disabled on servers
disableOptimizedDFU = true
#Skip specific GL versions, may help with buggy graphics card drivers
earlyWindowSkipGLVersions = []
#Should we control the window. Disabling this disables new GL features and can be bad for mods that rely on them.
earlyWindowControl = true
#Max threads for early initialization parallelism, -1 is based on processor count
maxThreads = -1
#Squir?
earlyWindowSquir = false

9 changes: 9 additions & 0 deletions src/generated/resources/assets/hon/lang/en_us.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"item.hon.iron_tongs": "Iron Tongs",
"item.hon.mittens": "Mitts",
"item.hon.wooden_tongs": "Wooden Tongs",
"item_group.hon.hon": "Hot Or Not Tab",
"tooltip.hon.cold": "This Item feels Cold to the touch",
"tooltip.hon.hot": "This Item feels Hot to the touch",
"tooltip.hon.protectivegear": "This Item protects from negative effect from hot/cold items, put in offhand to use"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "hon:item/iron_tongs"
}
}
6 changes: 6 additions & 0 deletions src/generated/resources/assets/hon/models/item/mittens.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "hon:item/mittens"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "hon:item/wooden_tongs"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"parent": "minecraft:recipes/root",
"criteria": {
"has_iron_ingot": {
"conditions": {
"items": [
{
"items": [
"minecraft:iron_ingot"
]
}
]
},
"trigger": "minecraft:inventory_changed"
},
"has_the_recipe": {
"conditions": {
"recipe": "hon:iron_tongs"
},
"trigger": "minecraft:recipe_unlocked"
}
},
"requirements": [
[
"has_iron_ingot",
"has_the_recipe"
]
],
"rewards": {
"recipes": [
"hon:iron_tongs"
]
},
"sends_telemetry_event": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"parent": "minecraft:recipes/root",
"criteria": {
"has_leather": {
"conditions": {
"items": [
{
"items": [
"minecraft:leather"
]
}
]
},
"trigger": "minecraft:inventory_changed"
},
"has_the_recipe": {
"conditions": {
"recipe": "hon:mittens"
},
"trigger": "minecraft:recipe_unlocked"
}
},
"requirements": [
[
"has_leather",
"has_the_recipe"
]
],
"rewards": {
"recipes": [
"hon:mittens"
]
},
"sends_telemetry_event": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"parent": "minecraft:recipes/root",
"criteria": {
"has_stick": {
"conditions": {
"items": [
{
"items": [
"minecraft:stick"
]
}
]
},
"trigger": "minecraft:inventory_changed"
},
"has_the_recipe": {
"conditions": {
"recipe": "hon:wooden_tongs"
},
"trigger": "minecraft:recipe_unlocked"
}
},
"requirements": [
[
"has_stick",
"has_the_recipe"
]
],
"rewards": {
"recipes": [
"hon:wooden_tongs"
]
},
"sends_telemetry_event": false
}
18 changes: 18 additions & 0 deletions src/generated/resources/data/hon/recipes/iron_tongs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"type": "minecraft:crafting_shaped",
"category": "equipment",
"key": {
"I": {
"item": "minecraft:iron_ingot"
}
},
"pattern": [
"I I",
"I I",
" I "
],
"result": {
"item": "hon:iron_tongs"
},
"show_notification": true
}
18 changes: 18 additions & 0 deletions src/generated/resources/data/hon/recipes/mittens.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"type": "minecraft:crafting_shaped",
"category": "equipment",
"key": {
"L": {
"item": "minecraft:leather"
}
},
"pattern": [
"LLL",
" LL",
"LLL"
],
"result": {
"item": "hon:mittens"
},
"show_notification": true
}
18 changes: 18 additions & 0 deletions src/generated/resources/data/hon/recipes/wooden_tongs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"type": "minecraft:crafting_shaped",
"category": "equipment",
"key": {
"S": {
"item": "minecraft:stick"
}
},
"pattern": [
"S S",
"S S",
" S "
],
"result": {
"item": "hon:wooden_tongs"
},
"show_notification": true
}
2 changes: 1 addition & 1 deletion src/main/java/com/kitp13/hon/HotOrNot.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class HotOrNot {
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID);
public static final DeferredRegister<CreativeModeTab> TABREGISTER = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, MODID);

public static RegistryObject<Item> MITTS = ITEMS.register("mitttens", () -> new HonItem(1023));
public static RegistryObject<Item> MITTS = ITEMS.register("mittens", () -> new HonItem(1023));
public static final RegistryObject<Item> WOODEN_TONGS = ITEMS.register("wooden_tongs", () -> new HonItem(127));
public static final RegistryObject<Item> IRON_TONGS = ITEMS.register("iron_tongs", () -> new HonItem(511));

Expand Down
18 changes: 18 additions & 0 deletions src/main/java/com/kitp13/hon/datagen/DataGen.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.kitp13.hon.datagen;

import com.kitp13.hon.HotOrNot;
import net.minecraft.data.DataGenerator;
import net.minecraftforge.data.event.GatherDataEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;

@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
public class DataGen {
@SubscribeEvent
public static void gatherData(GatherDataEvent event) {
DataGenerator generator = event.getGenerator();
generator.addProvider(event.includeClient(), new LangEN_US(generator.getPackOutput(), HotOrNot.MODID, "en_us"));
generator.addProvider(event.includeClient(), new ItemModel(generator.getPackOutput(), HotOrNot.MODID, event.getExistingFileHelper()));
generator.addProvider(event.includeServer(), new Recipes(generator.getPackOutput()));
}
}
30 changes: 30 additions & 0 deletions src/main/java/com/kitp13/hon/datagen/ItemModel.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.kitp13.hon.datagen;

import com.kitp13.hon.HotOrNot;
import net.minecraft.data.PackOutput;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item;
import net.minecraftforge.client.model.generators.ItemModelBuilder;
import net.minecraftforge.client.model.generators.ItemModelProvider;
import net.minecraftforge.common.data.ExistingFileHelper;
import net.minecraftforge.registries.RegistryObject;

public class ItemModel extends ItemModelProvider{

public ItemModel(PackOutput output, String modid, ExistingFileHelper existingFileHelper) {
super(output, modid, existingFileHelper);
}

@Override
protected void registerModels() {
this.item(HotOrNot.WOODEN_TONGS);
this.item(HotOrNot.IRON_TONGS);
this.item(HotOrNot.MITTS);
}

private ItemModelBuilder item(RegistryObject<Item> item){
return withExistingParent(item.getId().getPath(),
new ResourceLocation("item/generated")).texture("layer0",
new ResourceLocation(HotOrNot.MODID, "item/" + item.getId().getPath()));
}
}
22 changes: 22 additions & 0 deletions src/main/java/com/kitp13/hon/datagen/LangEN_US.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.kitp13.hon.datagen;

import com.kitp13.hon.HotOrNot;
import net.minecraft.data.PackOutput;
import net.minecraftforge.common.data.LanguageProvider;

public class LangEN_US extends LanguageProvider {
public LangEN_US(PackOutput output, String modid, String locale) {
super(output, modid, locale);
}

@Override
protected void addTranslations() {
add(HotOrNot.WOODEN_TONGS.get(), "Wooden Tongs");
add(HotOrNot.IRON_TONGS.get(), "Iron Tongs");
add(HotOrNot.MITTS.get(), "Mitts");
add("tooltip.hon.cold", "This Item feels Cold to the touch");
add("tooltip.hon.hot", "This Item feels Hot to the touch");
add("tooltip.hon.protectivegear", "This Item protects from negative effect from hot/cold items, put in offhand to use");
add("item_group.hon.hon", "Hot Or Not Tab");
}
}
37 changes: 37 additions & 0 deletions src/main/java/com/kitp13/hon/datagen/Recipes.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.kitp13.hon.datagen;

import com.kitp13.hon.HotOrNot;
import net.minecraft.data.PackOutput;
import net.minecraft.data.recipes.FinishedRecipe;
import net.minecraft.data.recipes.RecipeCategory;
import net.minecraft.data.recipes.RecipeProvider;
import net.minecraft.data.recipes.ShapedRecipeBuilder;
import net.minecraft.world.item.Items;
import net.minecraftforge.common.crafting.conditions.IConditionBuilder;
import org.jetbrains.annotations.NotNull;

import java.util.function.Consumer;

public class Recipes extends RecipeProvider implements IConditionBuilder {
public Recipes(PackOutput p_248933_) {
super(p_248933_);
}

@Override
protected void buildRecipes(@NotNull Consumer<FinishedRecipe> consumer) {
ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, HotOrNot.MITTS.get())
.pattern("LLL")
.pattern(" LL")
.pattern("LLL")
.define('L', Items.LEATHER)
.unlockedBy(getHasName(Items.LEATHER),has(Items.LEATHER)).save(consumer);
ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, HotOrNot.WOODEN_TONGS.get())
.pattern("S S").pattern("S S").pattern(" S ")
.define('S', Items.STICK)
.unlockedBy(getHasName(Items.STICK),has(Items.STICK)).save(consumer);
ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, HotOrNot.IRON_TONGS.get())
.pattern("I I").pattern("I I").pattern(" I ")
.define('I', Items.IRON_INGOT)
.unlockedBy(getHasName(Items.IRON_INGOT),has(Items.IRON_INGOT)).save(consumer);
}
}

0 comments on commit 6680bd7

Please sign in to comment.