Skip to content

Commit

Permalink
add datagen
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyeling123 committed Nov 15, 2024
1 parent 6c4caf8 commit 8b9b1c9
Show file tree
Hide file tree
Showing 12 changed files with 91 additions and 66 deletions.
4 changes: 3 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Sets default memory used for gradle commands. Can be overridden by user or command line properties.
org.gradle.jvmargs=-Xmx1G
#org.gradle.jvmargs=-Xmx1G
org.gradle.jvmargs=-Xmx2048m

org.gradle.daemon=true
org.gradle.parallel=true
org.gradle.caching=true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.herat.GemCraft.common.datagen.GCBlockStatesProvider;
package com.github.herat.GemCraft.common.datagen;

import net.minecraft.data.PackOutput;
import net.neoforged.neoforge.client.model.generators.BlockStateProvider;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package com.github.herat.GemCraft.common.datagen;

import com.github.herat.GemCraft.GemCraft;
import com.github.herat.GemCraft.common.datagen.GCBlockStatesProvider.GCBlockStatesProvider;
import com.github.herat.GemCraft.common.datagen.GCModelProvider.GCItemModelProvider;
import com.github.herat.GemCraft.common.datagen.LanguageProvider.GCLanguageProvider;
import com.github.herat.GemCraft.common.datagen.LanguageProvider.GCLanguageProviderCN;
import net.minecraft.data.DataProvider;
Expand All @@ -19,6 +17,13 @@ public class GCDataGeneratorHandler {
@SubscribeEvent
public static void gatherData(GatherDataEvent event) {
ExistingFileHelper efh = event.getExistingFileHelper();
var lp = event.getLookupProvider();

// recipe
event.getGenerator().addProvider(
event.includeServer(),
(DataProvider.Factory<GCRecipeProvider>) pOutput -> new GCRecipeProvider(pOutput,lp)
);

//blockstates

Expand Down Expand Up @@ -47,7 +52,5 @@ public static void gatherData(GatherDataEvent event) {
event.includeClient(),
(DataProvider.Factory<GCLanguageProviderCN>) pOutput -> new GCLanguageProviderCN(pOutput,GemCraft.MODID,"zh_cn")
);


}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.github.herat.GemCraft.common.datagen;

import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.data.PackOutput;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item;
import net.neoforged.neoforge.client.model.generators.ItemModelProvider;
import net.neoforged.neoforge.common.data.ExistingFileHelper;

import java.util.Objects;

/**
* @author herat
*/
public class GCItemModelProvider extends ItemModelProvider {
public GCItemModelProvider(PackOutput output, String modid , ExistingFileHelper existingFileHelper) {
super(output,modid,existingFileHelper);
}

@Override
protected void registerModels() {
this.withExistingParent("ruby",mcLoc("item/generated")).texture("layer0","gemcraft:item/ruby");
this.withExistingParent("ruby_sword",mcLoc("item/handheld")).texture("layer0","gemcraft:item/ruby_sword");
// this.withExistingParent("ruby_sword",mcLoc("item/generated")).texture("layer0","gemcraft:item/ruby_sword");
// this.withExistingParent("ruby_pickaxe",mcLoc("item/generated")).texture("layer0","gemcraft:item/ruby_pickaxe");
// this.withExistingParent("ruby_shovel",mcLoc("item/generated")).texture("layer0","gemcraft:item/ruby_shovel");
// this.withExistingParent("ruby_axe",mcLoc("item/generated")).texture("layer0","gemcraft:item/ruby_axe");
// this.withExistingParent("ruby_hoe",mcLoc("item/generated")).texture("layer0","gemcraft:item/ruby_hoe");
// this.withExistingParent("sapphire",mcLoc("item/generated")).texture("layer0","gemcraft:item/sapphire");
// this.withExistingParent("sapphire_sword",mcLoc("item/generated")).texture("layer0","gemcraft:item/sapphire_sword");
// this.withExistingParent("sapphire_pickaxe",mcLoc("item/generated")).texture("layer0","gemcraft:item/sapphire_pickaxe");
// this.withExistingParent("ruby_shovel",mcLoc("item/generated")).texture("layer0","gemcraft:item/ruby_shovel");
// this.withExistingParent("sapphire_axe",mcLoc("item/generated")).texture("layer0","gemcraft:item/sapphire_axe");
// this.withExistingParent("sapphire_hoe",mcLoc("item/generated")).texture("layer0","gemcraft:item/sapphire_hoe");
}

public ResourceLocation getResourceLocation(Item item) {
return Objects.requireNonNull(BuiltInRegistries.ITEM.getKey(item));
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.github.herat.GemCraft.common.datagen;

import com.github.herat.GemCraft.common.register.GemCraftItem;
import net.minecraft.core.HolderLookup;
import net.minecraft.data.PackOutput;
import net.minecraft.data.recipes.RecipeCategory;
import net.minecraft.data.recipes.RecipeOutput;
import net.minecraft.data.recipes.RecipeProvider;
import net.minecraft.data.recipes.ShapedRecipeBuilder;
import net.minecraft.world.item.Items;
import org.jetbrains.annotations.NotNull;

import java.util.concurrent.CompletableFuture;

/**
* @author herat
*/
public class GCRecipeProvider extends RecipeProvider {
public GCRecipeProvider(PackOutput pPackOutput, CompletableFuture<HolderLookup.Provider> lookupProvider) {
super(pPackOutput, lookupProvider);
}

@Override
protected void buildRecipes(@NotNull RecipeOutput pRecipeOutput) {
ShapedRecipeBuilder.shaped(RecipeCategory.COMBAT, GemCraftItem.RUBY_SWORD.get())
.pattern(" a ")
.pattern(" a ")
.pattern(" b ")
.define('a', GemCraftItem.RUBY.get())
.define('b', Items.STICK)
.save(pRecipeOutput);
// ShapedRecipeBuilder.shaped(RecipeCategory.MISC, GemCraftItem.RUBY_SWORD.get())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ protected void addTranslations() {
this.add(GemCraftItem.RUBY_SHOVEL.get(),"Ruby Shovel");
this.add(GemCraftItem.RUBY_AXE.get(),"Ruby Axe");
this.add(GemCraftItem.RUBY_HOE.get(),"Ruby Hoe");
this.add(GemCraftItem.SAPPHIRE_HOE.get(),"Sapphire Hoe");
this.add(GemCraftItem.SAPPHIRE.get(),"Sapphire");
this.add(GemCraftItem.SAPPHIRE_SWORD.get(),"Sapphire Sword");
this.add(GemCraftItem.SAPPHIRE_PICKAXE.get(),"Sapphire Pickaxe");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@ protected void addTranslations() {
this.add(GemCraftItem.RUBY.get(),"红宝石");
this.add(GemCraftItem.RUBY_SWORD.get(),"红宝石剑");
this.add(GemCraftItem.RUBY_PICKAXE.get(),"红宝石镐");
this.add(GemCraftItem.RUBY_SHOVEL.get(),"红宝石铲子");
this.add(GemCraftItem.RUBY_AXE.get(),"红宝石斧头");
this.add(GemCraftItem.RUBY_HOE.get(),"红宝石锄头");
this.add(GemCraftItem.SAPPHIRE_HOE.get(),"蓝宝石锄头");
this.add(GemCraftItem.RUBY_SHOVEL.get(),"红宝石铲");
this.add(GemCraftItem.RUBY_AXE.get(),"红宝石斧");
this.add(GemCraftItem.RUBY_HOE.get(),"红宝石锄");
this.add(GemCraftItem.SAPPHIRE.get(),"蓝宝石");
this.add(GemCraftItem.SAPPHIRE_SWORD.get(),"蓝宝石剑");
this.add(GemCraftItem.SAPPHIRE_PICKAXE.get(),"蓝宝石镐");
this.add(GemCraftItem.SAPPHIRE_SHOVEL.get(),"蓝宝石铲子");
this.add(GemCraftItem.SAPPHIRE_AXE.get(),"蓝宝石斧头");
this.add(GemCraftItem.SAPPHIRE_HOE.get(),"蓝宝石锄头");
this.add(GemCraftItem.SAPPHIRE_SHOVEL.get(),"蓝宝石铲");
this.add(GemCraftItem.SAPPHIRE_AXE.get(),"蓝宝石斧");
this.add(GemCraftItem.SAPPHIRE_HOE.get(),"蓝宝石锄");
}
}
6 changes: 0 additions & 6 deletions src/main/resources/assets/gemcraft/models/item/ruby.json

This file was deleted.

6 changes: 0 additions & 6 deletions src/main/resources/assets/gemcraft/models/item/sapphire.json

This file was deleted.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 8b9b1c9

Please sign in to comment.