generated from NeoForgeMDKs/MDK-1.21-NeoGradle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
MCZME
committed
Aug 13, 2024
1 parent
3804ccf
commit a5c5eb5
Showing
7 changed files
with
112 additions
and
1 deletion.
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
src/generated/resources/.cache/e0d3d0b8d9c807675613821fa865a35f707cd83f
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// 1.21 2024-08-13T22:21:22.8027373 Data Maps | ||
3136fc55269a4deb6ec159d30383e6941c2ee6a1 data/lingshi/data_maps/item/cooking_food.json |
10 changes: 10 additions & 0 deletions
10
src/generated/resources/data/lingshi/data_maps/item/cooking_food.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"values": { | ||
"lingshi:rice": { | ||
"time": 15.0 | ||
}, | ||
"minecraft:apple": { | ||
"time": 5.0 | ||
} | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
src/main/java/mczme/lingshi/common/data/CookingFoodDataGen.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package mczme.lingshi.common.data; | ||
|
||
import mczme.lingshi.common.datamap.ingredient.CookingFoodData; | ||
import mczme.lingshi.common.registry.ModItems; | ||
import net.minecraft.core.HolderLookup; | ||
import net.minecraft.data.PackOutput; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.tags.TagKey; | ||
import net.minecraft.world.item.Item; | ||
import net.minecraft.world.item.Items; | ||
import net.neoforged.neoforge.common.data.DataMapProvider; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
import java.util.function.Supplier; | ||
|
||
import static mczme.lingshi.common.datamap.DataMapTypes.COOKING_FOOD; | ||
|
||
public class CookingFoodDataGen extends DataMapProvider { | ||
|
||
protected CookingFoodDataGen(PackOutput packOutput, CompletableFuture<HolderLookup.Provider> lookupProvider) { | ||
super(packOutput, lookupProvider); | ||
} | ||
|
||
@Override | ||
protected void gather() { | ||
addCookingFood(Items.APPLE,5); | ||
addCookingFood(ModItems.RICE,15); | ||
} | ||
|
||
protected void addCookingFood(Item item , float time){ | ||
builder(COOKING_FOOD).add(ResourceLocation.parse(item.toString()),new CookingFoodData(time),false); | ||
} | ||
|
||
protected void addCookingFood(Supplier<Item> item , float time){ | ||
builder(COOKING_FOOD).add(ResourceLocation.parse(item.get().toString()),new CookingFoodData(time),false); | ||
} | ||
|
||
protected void addCookingFood(TagKey<Item> tag, float time){ | ||
builder(COOKING_FOOD).add(tag,new CookingFoodData(time),false); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/main/java/mczme/lingshi/common/datamap/DataMapTypes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package mczme.lingshi.common.datamap; | ||
|
||
import mczme.lingshi.common.datamap.ingredient.CookingFoodData; | ||
import mczme.lingshi.lingshi; | ||
import net.minecraft.core.registries.Registries; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.item.Item; | ||
import net.neoforged.neoforge.registries.datamaps.DataMapType; | ||
|
||
public class DataMapTypes { | ||
public static final DataMapType<Item, CookingFoodData> COOKING_FOOD = DataMapType.builder( | ||
ResourceLocation.fromNamespaceAndPath(lingshi.MODID, "cooking_food"), | ||
Registries.ITEM, CookingFoodData.CODEC | ||
).build(); | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/mczme/lingshi/common/datamap/ingredient/CookingFoodData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package mczme.lingshi.common.datamap.ingredient; | ||
|
||
import com.mojang.serialization.Codec; | ||
import com.mojang.serialization.codecs.RecordCodecBuilder; | ||
|
||
|
||
public record CookingFoodData(float time) { | ||
static float MAX_TIME = 30; | ||
|
||
public CookingFoodData(float time){ | ||
if(time > MAX_TIME) this.time = MAX_TIME; | ||
else if(time < 0) this.time = 0; | ||
else this.time = time; | ||
} | ||
|
||
public static final Codec<CookingFoodData> CODEC = RecordCodecBuilder.create(instance -> instance.group( | ||
Codec.FLOAT.fieldOf("time").forGetter(CookingFoodData::time) | ||
).apply(instance, CookingFoodData::new)); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package mczme.lingshi.common.event; | ||
|
||
import mczme.lingshi.lingshi; | ||
import net.neoforged.bus.api.SubscribeEvent; | ||
import net.neoforged.fml.common.EventBusSubscriber; | ||
import net.neoforged.neoforge.registries.datamaps.RegisterDataMapTypesEvent; | ||
|
||
import static mczme.lingshi.common.datamap.DataMapTypes.COOKING_FOOD; | ||
|
||
@EventBusSubscriber(modid = lingshi.MODID, bus = EventBusSubscriber.Bus.MOD) | ||
public class Registry { | ||
@SubscribeEvent | ||
private static void registerDataMapTypes(RegisterDataMapTypesEvent event) { | ||
event.register(COOKING_FOOD); | ||
} | ||
} |