Skip to content

Commit

Permalink
宝石胡萝卜的种植
Browse files Browse the repository at this point in the history
  • Loading branch information
skyinr committed Oct 30, 2022
1 parent 7011136 commit 89023a5
Show file tree
Hide file tree
Showing 10 changed files with 96 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,8 @@
@Mod(Kitchenkarrot.MOD_ID)
public class Kitchenkarrot {
public static final String MOD_ID = "kitchenkarrot";
public static boolean farmersdelightLoaded;
public static boolean neapolitanLoaded;

public Kitchenkarrot() {
farmersdelightLoaded = ModList.get().isLoaded("farmersdelight");
neapolitanLoaded = ModList.get().isLoaded("neapolitan");


IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus();
ModBlocks.BLOCKS.register(bus);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package io.github.tt432.kitchenkarrot.block;

import io.github.tt432.kitchenkarrot.item.ModBlockItems;
import net.minecraft.world.level.ItemLike;
import net.minecraft.world.level.block.CropBlock;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.material.Material;
import org.jetbrains.annotations.NotNull;

public class GemCarrotCrop extends CropBlock {
public GemCarrotCrop() {
super(BlockBehaviour.Properties
.of(Material.PLANT)
.sound(SoundType.CROP)
.randomTicks()
.noCollission()
.instabreak());
}

@Override
@NotNull
protected ItemLike getBaseSeedId() {
return ModBlockItems.GEM_CARROT.get();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material;
Expand All @@ -13,6 +14,7 @@
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;
import org.jetbrains.annotations.NotNull;

import javax.annotation.ParametersAreNonnullByDefault;

Expand Down Expand Up @@ -41,12 +43,14 @@ public class ModBlocks {
public static final RegistryObject<Block> COASTER = BLOCKS.register("coaster", () -> new CoasterBlock(BlockBehaviour.Properties.of(Material.STONE).strength(2.0F, 2.0F)));

public static final RegistryObject<Block> PLATE = BLOCKS.register("plate", () -> new PlateBlock(BlockBehaviour.Properties.of(Material.STONE).strength(2.0F, 2.0F)));
public static final RegistryObject<Block> GEM_CARROT = BLOCKS.register("gem_carrot", GemCarrotCrop::new);

private static RegistryObject<Block> oil(String name) {
return BLOCKS.register(name, () -> new Block(BlockBehaviour.Properties.of(Material.STONE)
.noOcclusion()
.strength(2.0f, 2.0f)) {
@Override
@NotNull
@SuppressWarnings("deprecation")
public VoxelShape getShape(BlockState pState, BlockGetter pLevel, BlockPos pPos, CollisionContext pContext) {
return OIL;
Expand All @@ -59,6 +63,7 @@ private static RegistryObject<Block> salt(String name) {
.noOcclusion()
.strength(2.0f, 2.0f)) {
@Override
@NotNull
@SuppressWarnings("deprecation")
public VoxelShape getShape(BlockState pState, BlockGetter pLevel, BlockPos pPos, CollisionContext pContext) {
return SALT;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.github.tt432.kitchenkarrot.datagen;

import io.github.tt432.kitchenkarrot.Kitchenkarrot;
import io.github.tt432.kitchenkarrot.datagen.loottable.ModLootTableProvider;
import net.minecraft.data.DataGenerator;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
Expand All @@ -23,6 +24,7 @@ public static void gatherData(GatherDataEvent event) {
}

if (event.includeServer()) {
event.getGenerator().addProvider(new ModLootTableProvider(event.getGenerator()));
var blockTag = new TutBlockTags(generator, file);
generator.addProvider(blockTag);
generator.addProvider(new TutItemTags(generator, blockTag, event.getExistingFileHelper()));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package io.github.tt432.kitchenkarrot.datagen.loottable;

import io.github.tt432.kitchenkarrot.block.ModBlocks;
import io.github.tt432.kitchenkarrot.item.ModBlockItems;
import net.minecraft.advancements.critereon.StatePropertiesPredicate;
import net.minecraft.data.loot.BlockLoot;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.CropBlock;
import net.minecraft.world.level.storage.loot.predicates.LootItemBlockStatePropertyCondition;

public class ModBlockLootProvider extends BlockLoot {

@Override
protected void addTables() {
createCropDrops(ModBlocks.GEM_CARROT.get(), ModBlockItems.GEM_CARROT.get(), ModBlockItems.GEM_CARROT.get(),
LootItemBlockStatePropertyCondition
.hasBlockStateProperties(Blocks.WHEAT)
.setProperties(StatePropertiesPredicate.Builder.properties()
.hasProperty(CropBlock.AGE, 7)));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package io.github.tt432.kitchenkarrot.datagen.loottable;

import com.google.common.collect.ImmutableList;
import com.mojang.datafixers.util.Pair;
import io.github.tt432.kitchenkarrot.Kitchenkarrot;
import net.minecraft.data.DataGenerator;
import net.minecraft.data.loot.LootTableProvider;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.storage.loot.LootTable;
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSet;
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets;
import org.jetbrains.annotations.NotNull;

import java.util.List;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Supplier;

public class ModLootTableProvider extends LootTableProvider {
public ModLootTableProvider(DataGenerator pGenerator) {
super(pGenerator);
}

@Override
@NotNull
public String getName() {
return super.getName() + ":" + Kitchenkarrot.MOD_ID;
}

@Override
@NotNull
protected List<Pair<Supplier<Consumer<BiConsumer<ResourceLocation, LootTable.Builder>>>, LootContextParamSet>> getTables() {
ImmutableList.Builder<Pair<Supplier<Consumer<BiConsumer<ResourceLocation, LootTable.Builder>>>, LootContextParamSet>> builder = new ImmutableList.Builder<>();
builder.add(Pair.of(ModBlockLootProvider::new, LootContextParamSets.BLOCK));
return builder.build();
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.github.tt432.kitchenkarrot.item;

import io.github.tt432.kitchenkarrot.block.ModBlocks;
import io.github.tt432.kitchenkarrot.item.food.FoodUtil;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.Item;
import net.minecraftforge.registries.DeferredRegister;
Expand All @@ -23,4 +24,5 @@ public class ModBlockItems {
public static final RegistryObject<BlockItem> ROCK_SALT = BLOCK_ITEMS.register("rock_salt", () -> new BlockItem(ModBlocks.ROCK_SALT.get(), defaultProperties()));
public static final RegistryObject<BlockItem> FINE_SALT = BLOCK_ITEMS.register("fine_salt", () -> new BlockItem(ModBlocks.FINE_SALT.get(), defaultProperties()));
public static final RegistryObject<BlockItem> SEA_SALT = BLOCK_ITEMS.register("sea_salt", () -> new BlockItem(ModBlocks.SEA_SALT.get(), defaultProperties()));
public static final RegistryObject<BlockItem> GEM_CARROT = BLOCK_ITEMS.register("gem_carrot", () -> new BlockItem(ModBlocks.GEM_CARROT.get(),FoodUtil.food(defaultProperties(), 6, 8)));
}
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ public int getUseDuration(ItemStack pStack) {
public static final RegistryObject<Item> ICE_CUBES = ITEMS.register("ice_cubes", () -> new Item(defaultProperties()));
public static final RegistryObject<Item> CARROT_SPICES = ITEMS.register("carrot_spices", () -> new Item(defaultProperties()));
public static final RegistryObject<Item> ACORN = ITEMS.register("acorn", () -> new Item(FoodUtil.food(defaultProperties(), 2, 1F)));
public static final RegistryObject<Item> GEM_CARROT = ITEMS.register("gem_carrot", () -> new Item(FoodUtil.food(defaultProperties(), 6, 8)));
public static final RegistryObject<Item> RAW_BEEF_IN_DRIPLEAF = ITEMS.register("raw_beef_in_dripleaf", () -> new Item(defaultProperties()));
public static final RegistryObject<Item> DUNGEON_PIZZA = ITEMS.register("dungeon_pizza", () -> new Item(defaultProperties()));
public static final RegistryObject<Item> FEAST_PIZZA = ITEMS.register("feast_pizza", () -> new Item(defaultProperties()));
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/assets/kitchenkarrot/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"item.kitchenkarrot.sweet_loaf":"Sweet Loaf",
"item.kitchenkarrot.acorn":"Acorn",
"item.kitchenkarrot.birch_sap":"Birch Sap",
"item.kitchenkarrot.gem_carrot":"Gem Carrot",
"item.kitchenkarrot.bamboo_potato":"Bamboo Potato",
"item.kitchenkarrot.sweet_loaf_slice":"Sweet Loaf Slice",
"item.kitchenkarrot.pickled_sea_pickles":"Pickled Sea Pickles",
Expand Down Expand Up @@ -102,6 +101,7 @@
"item.kitchenkarrot.lava_brulee":"Lava Brulee",
"item.kitchenkarrot.hi_nrg_brulee":"High Energy Brulee",

"block.kitchenkarrot.gem_carrot":"Gem Carrot",
"block.kitchenkarrot.sunflower_oil":"Sunflower Oil",
"block.kitchenkarrot.chorus_oil":"Chorus Oil",
"block.kitchenkarrot.acorn_oil":"Acorn Oil",
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/assets/kitchenkarrot/lang/zh_cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"item.kitchenkarrot.sweet_loaf":"糖霜面包",
"item.kitchenkarrot.acorn":"橡果",
"item.kitchenkarrot.birch_sap":"桦树汁",
"item.kitchenkarrot.gem_carrot":"宝石胡萝卜",
"item.kitchenkarrot.bamboo_potato":"竹片土豆",
"item.kitchenkarrot.sweet_loaf_slice":"糖霜面包",
"item.kitchenkarrot.pickled_sea_pickles":"腌制海泡菜",
Expand Down Expand Up @@ -101,7 +100,8 @@
"item.kitchenkarrot.honey_brulee":"蜂蜜布蕾",
"item.kitchenkarrot.lava_brulee":"熔岩布蕾",
"item.kitchenkarrot.hi_nrg_brulee":"高能布蕾",


"block.kitchenkarrot.gem_carrot":"宝石胡萝卜",
"block.kitchenkarrot.sunflower_oil":"瓜子油",
"block.kitchenkarrot.chorus_oil":"紫颂油",
"block.kitchenkarrot.acorn_oil":"橡子油",
Expand Down

0 comments on commit 89023a5

Please sign in to comment.