Skip to content

Commit

Permalink
JEI and Bugs
Browse files Browse the repository at this point in the history
Added JEI compat
Gave blocks correct tools
FIxed Avocado Log -> Jungle Planks recipe
Started Wild Crop generation
Food bug fixes
  • Loading branch information
Nyancatpig committed May 5, 2022
1 parent b6b8a62 commit 238fb4c
Show file tree
Hide file tree
Showing 15 changed files with 254 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,11 @@ public class ModBlocks {
public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, CulturalDelights.MOD_ID);

public static final RegistryObject<Block> AVOCADO_BUNDLE = registerBlock("avocado_bundle",
() -> new Block(BlockBehaviour.Properties.of(Material.WOOD, MaterialColor.COLOR_GREEN)
.strength(0, 1f).noOcclusion()), FarmersDelight.CREATIVE_TAB, false, 0);
() -> new Block(BlockBehaviour.Properties.copy(Blocks.PUMPKIN).noOcclusion()), FarmersDelight.CREATIVE_TAB, false, 0);

public static final RegistryObject<Block> BAMBOO_MAT = registerBlock("bamboo_mat",
() -> new BambooMatBlock(BlockBehaviour.Properties.of(Material.BAMBOO, MaterialColor.COLOR_GREEN)
.strength(0, 1f).noOcclusion()), FarmersDelight.CREATIVE_TAB, true, 0);
() -> new BambooMatBlock(BlockBehaviour.Properties.copy(vectorwing.farmersdelight.common.registry.ModBlocks.CUTTING_BOARD.get())
.noOcclusion()), FarmersDelight.CREATIVE_TAB, true, 0);

public static final RegistryObject<Block> WILD_CUCUMBERS = registerBlock("wild_cucumbers",
() -> new Block(BlockBehaviour.Properties.copy(vectorwing.farmersdelight.common.registry.ModBlocks.WILD_BEETROOTS.get())
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package com.ncpbails.culturaldelights.integration;

import com.ncpbails.culturaldelights.CulturalDelights;
import com.ncpbails.culturaldelights.block.ModBlocks;
import com.ncpbails.culturaldelights.item.ModItems;
import com.ncpbails.culturaldelights.recipe.BambooMatRecipe;
import mezz.jei.api.constants.VanillaTypes;
import mezz.jei.api.gui.builder.IRecipeLayoutBuilder;
import mezz.jei.api.gui.drawable.IDrawable;
import mezz.jei.api.helpers.IGuiHelper;
import mezz.jei.api.recipe.IFocusGroup;
import mezz.jei.api.recipe.RecipeIngredientRole;
import mezz.jei.api.recipe.category.IRecipeCategory;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.crafting.Ingredient;

import javax.annotation.Nonnull;

public class BambooMatRecipeCategory implements IRecipeCategory<BambooMatRecipe> {
public final static ResourceLocation UID = new ResourceLocation(CulturalDelights.MOD_ID, "mat_rolling");
public final static ResourceLocation TEXTURE =
new ResourceLocation(CulturalDelights.MOD_ID, "textures/gui/bamboo_mat_gui.png");

private final IDrawable background;
private final IDrawable icon;

public BambooMatRecipeCategory(IGuiHelper helper) {
this.background = helper.createDrawable(TEXTURE, 0, 0, 176, 85);
this.icon = helper.createDrawableIngredient(VanillaTypes.ITEM, new ItemStack(ModBlocks.BAMBOO_MAT.get()));
}

@Override
public ResourceLocation getUid() {
return UID;
}

@Override
public Class<? extends BambooMatRecipe> getRecipeClass() {
return BambooMatRecipe.class;
}

@Override
public Component getTitle() {
return new TextComponent("Bamboo Mat");
}

@Override
public IDrawable getBackground() {
return this.background;
}

@Override
public IDrawable getIcon() {
return this.icon;
}

@Override
public void setRecipe(@Nonnull IRecipeLayoutBuilder builder, @Nonnull BambooMatRecipe recipe, @Nonnull IFocusGroup focusGroup) {
builder.addSlot(RecipeIngredientRole.INPUT, 39, 46).addIngredients(recipe.getIngredients().get(0));
builder.addSlot(RecipeIngredientRole.INPUT, 57, 46).addIngredients(recipe.getIngredients().get(1));
builder.addSlot(RecipeIngredientRole.INPUT, 30, 22).addIngredients(recipe.getIngredients().get(2));
builder.addSlot(RecipeIngredientRole.INPUT, 48, 22).addIngredients(recipe.getIngredients().get(3));
builder.addSlot(RecipeIngredientRole.INPUT, 66, 22).addIngredients(recipe.getIngredients().get(4));

builder.addSlot(RecipeIngredientRole.OUTPUT, 129, 22).addItemStack(recipe.getResultItem());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.ncpbails.culturaldelights.integration;

import com.ncpbails.culturaldelights.CulturalDelights;
import com.ncpbails.culturaldelights.recipe.BambooMatRecipe;
import mezz.jei.api.IModPlugin;
import mezz.jei.api.JeiPlugin;
import mezz.jei.api.recipe.RecipeType;
import mezz.jei.api.registration.IRecipeCategoryRegistration;
import mezz.jei.api.registration.IRecipeRegistration;
import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.crafting.RecipeManager;

import java.util.List;
import java.util.Objects;

@JeiPlugin
public class JEICulturalDelightsPlugin implements IModPlugin {
@Override
public ResourceLocation getPluginUid() {
return new ResourceLocation(CulturalDelights.MOD_ID, "jei_plugin");
}

@Override
public void registerCategories(IRecipeCategoryRegistration registration) {
registration.addRecipeCategories(new
BambooMatRecipeCategory(registration.getJeiHelpers().getGuiHelper()));
}

@Override
public void registerRecipes(IRecipeRegistration registration) {
RecipeManager rm = Objects.requireNonNull(Minecraft.getInstance().level).getRecipeManager();
List<BambooMatRecipe> recipes = rm.getAllRecipesFor(BambooMatRecipe.Type.INSTANCE);
registration.addRecipes(new RecipeType<>(BambooMatRecipeCategory.UID, BambooMatRecipe.class), recipes);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ public class ModFoods {
//FOODS
public static final FoodProperties AVOCADO = (new FoodProperties.Builder()).nutrition(4).saturationMod(0.6F).build();
public static final FoodProperties CUCUMBER = (new FoodProperties.Builder()).nutrition(2).saturationMod(0.5F).build();
public static final FoodProperties PICKLE = (new FoodProperties.Builder()).nutrition(4).saturationMod(0.9F).build();
public static final FoodProperties PICKLE = (new FoodProperties.Builder()).nutrition(4).saturationMod(0.7F).build();
public static final FoodProperties EGGPLANT = (new FoodProperties.Builder()).nutrition(3).saturationMod(0.2F).build();
public static final FoodProperties SMOKED_EGGPLANT = (new FoodProperties.Builder()).nutrition(8).saturationMod(1.4F).build();
public static final FoodProperties SMOKED_EGGPLANT = (new FoodProperties.Builder()).nutrition(8).saturationMod(0.6F).build();
public static final FoodProperties SMOKED_TOMATO = (new FoodProperties.Builder()).nutrition(4).saturationMod(0.6F).build();
public static final FoodProperties SMOKED_CORN = (new FoodProperties.Builder()).nutrition(5).saturationMod(0.7F).build();
public static final FoodProperties SMOKED_WHITE_EGGPLANT = (new FoodProperties.Builder()).nutrition(3).saturationMod(0.5F).build();
Expand All @@ -30,9 +30,9 @@ public class ModFoods {
//FAST TO EAT
public static final FoodProperties CUT_AVOCADO = (new FoodProperties.Builder()).nutrition(2).saturationMod(0.3F).fast().build();
public static final FoodProperties CUT_CUCUMBER = (new FoodProperties.Builder()).nutrition(1).saturationMod(0.3F).fast().build();
public static final FoodProperties CUT_PICKLE = (new FoodProperties.Builder()).nutrition(2).saturationMod(0.4F).fast().build();
public static final FoodProperties CUT_PICKLE = (new FoodProperties.Builder()).nutrition(2).saturationMod(0.5F).fast().build();
public static final FoodProperties CUT_EGGPLANT = (new FoodProperties.Builder()).nutrition(1).saturationMod(0.1F).fast().build();
public static final FoodProperties SMOKED_CUT_EGGPLANT = (new FoodProperties.Builder()).nutrition(4).saturationMod(0.7F).fast().build();
public static final FoodProperties SMOKED_CUT_EGGPLANT = (new FoodProperties.Builder()).nutrition(4).saturationMod(0.4F).fast().build();
public static final FoodProperties POPCORN = (new FoodProperties.Builder()).nutrition(1).saturationMod(0.2F).fast().build();
public static final FoodProperties TORTILLA_CHIPS = (new FoodProperties.Builder()).nutrition(2).saturationMod(0.3F).fast().build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ public boolean matches(SimpleContainer pContainer, Level pLevel) {
return false;
}

@Override
public NonNullList<Ingredient> getIngredients() {
return recipeItems;
}

@Override
public ItemStack assemble(SimpleContainer p_44001_) {
return output;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.ncpbails.culturaldelights.CulturalDelights;
import com.ncpbails.culturaldelights.world.gen.ModTreeGeneration;
import com.ncpbails.culturaldelights.world.gen.ModWildCropGeneration;
import net.minecraftforge.event.world.BiomeLoadingEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
Expand All @@ -12,6 +13,7 @@ public class ModWorldEvents {
@SubscribeEvent
public static void biomeLoadingEvent(final BiomeLoadingEvent event) {
ModTreeGeneration.generateTrees(event);
ModWildCropGeneration.generateFlowers(event);
//ModPlantGeneration.generatePlants(event);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import com.google.common.collect.ImmutableSet;
import com.ncpbails.culturaldelights.block.ModBlocks;
import com.ncpbails.culturaldelights.world.gen.treedecorator.AvocadoBundleTreeDecorator;
import net.minecraft.world.level.levelgen.feature.configurations.RandomPatchConfiguration;
import net.minecraft.world.level.levelgen.feature.configurations.SimpleBlockConfiguration;
import net.minecraft.world.level.levelgen.feature.foliageplacers.AcaciaFoliagePlacer;
import net.minecraft.core.Holder;
import net.minecraft.data.worldgen.features.FeatureUtils;
Expand Down Expand Up @@ -50,4 +52,22 @@ public class ModConfiguredFeatures {
BlockStateProvider.simple(ModBlocks.AVOCADO_SAPLING.get()),
new AcaciaFoliagePlacer(ConstantInt.of(0), ConstantInt.of(0)),
new TwoLayersFeatureSize(1, 0, 1)).build());



public static final Holder<ConfiguredFeature<RandomPatchConfiguration, ?>> WILD_CORN =
FeatureUtils.register("wild_corn", Feature.FLOWER,
new RandomPatchConfiguration(32, 6, 2, PlacementUtils.onlyWhenEmpty(Feature.SIMPLE_BLOCK,
new SimpleBlockConfiguration(BlockStateProvider.simple(ModBlocks.WILD_CORN.get())))));

public static final Holder<ConfiguredFeature<RandomPatchConfiguration, ?>> WILD_EGGPLANTS =
FeatureUtils.register("wild_eggplants", Feature.FLOWER,
new RandomPatchConfiguration(32, 6, 2, PlacementUtils.onlyWhenEmpty(Feature.SIMPLE_BLOCK,
new SimpleBlockConfiguration(BlockStateProvider.simple(ModBlocks.WILD_EGGPLANTS.get())))));

public static final Holder<ConfiguredFeature<RandomPatchConfiguration, ?>> WILD_CUCUMBERS =
FeatureUtils.register("wild_cucumbers", Feature.FLOWER,
new RandomPatchConfiguration(32, 6, 2, PlacementUtils.onlyWhenEmpty(Feature.SIMPLE_BLOCK,
new SimpleBlockConfiguration(BlockStateProvider.simple(ModBlocks.WILD_CUCUMBERS.get())))));

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,24 @@
import net.minecraft.core.Holder;
import net.minecraft.data.worldgen.placement.PlacementUtils;
import net.minecraft.data.worldgen.placement.VegetationPlacements;
import net.minecraft.world.level.levelgen.placement.BiomeFilter;
import net.minecraft.world.level.levelgen.placement.InSquarePlacement;
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
import net.minecraft.world.level.levelgen.placement.RarityFilter;

public class ModPlacedFeatures {
public static final Holder<PlacedFeature> AVOCADO_PLACED = PlacementUtils.register("avocado_placed",
ModConfiguredFeatures.AVOCADO_SPAWN, VegetationPlacements.treePlacement(PlacementUtils.countExtra(1, 0.1f, 1)));

public static final Holder<PlacedFeature> WILD_CORN_PLACED = PlacementUtils.register("wild_corn_placed",
ModConfiguredFeatures.WILD_CORN, RarityFilter.onAverageOnceEvery(16),
InSquarePlacement.spread(), PlacementUtils.HEIGHTMAP, BiomeFilter.biome());

public static final Holder<PlacedFeature> WILD_EGGPLANTS_PLACED = PlacementUtils.register("wild_eggplants_placed",
ModConfiguredFeatures.WILD_EGGPLANTS, RarityFilter.onAverageOnceEvery(16),
InSquarePlacement.spread(), PlacementUtils.HEIGHTMAP, BiomeFilter.biome());

public static final Holder<PlacedFeature> WILD_CUCUMBERS_PLACED = PlacementUtils.register("wild_cucumbers_placed",
ModConfiguredFeatures.WILD_CUCUMBERS, RarityFilter.onAverageOnceEvery(16),
InSquarePlacement.spread(), PlacementUtils.HEIGHTMAP, BiomeFilter.biome());
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.ncpbails.culturaldelights.world.gen;

import com.ncpbails.culturaldelights.world.feature.ModPlacedFeatures;
import net.minecraft.core.Holder;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.levelgen.GenerationStep;
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
import net.minecraftforge.common.BiomeDictionary;
import net.minecraftforge.event.world.BiomeLoadingEvent;

import java.util.List;
import java.util.Set;

public class ModWildCropGeneration {
public static void generateFlowers(final BiomeLoadingEvent event) {
ResourceKey<Biome> key = ResourceKey.create(Registry.BIOME_REGISTRY, event.getName());
Set<BiomeDictionary.Type> types = BiomeDictionary.getTypes(key);

if(types.contains(BiomeDictionary.Type.PLAINS)) {
List<Holder<PlacedFeature>> base =
event.getGeneration().getFeatures(GenerationStep.Decoration.VEGETAL_DECORATION);

base.add(ModPlacedFeatures.WILD_CORN_PLACED);
}

if(types.contains(BiomeDictionary.Type.SWAMP)) {
List<Holder<PlacedFeature>> base =
event.getGeneration().getFeatures(GenerationStep.Decoration.VEGETAL_DECORATION);

base.add(ModPlacedFeatures.WILD_EGGPLANTS_PLACED);
base.add(ModPlacedFeatures.WILD_CUCUMBERS_PLACED);
}

if(types.contains(BiomeDictionary.Type.JUNGLE)) {
List<Holder<PlacedFeature>> base =
event.getGeneration().getFeatures(GenerationStep.Decoration.VEGETAL_DECORATION);

base.add(ModPlacedFeatures.WILD_EGGPLANTS_PLACED);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"rolls": 1.0,
"bonus_rolls": 0.0,
"entries": [
{
"type": "minecraft:alternatives",
Expand All @@ -16,7 +17,9 @@
{
"condition": "minecraft:match_tool",
"predicate": {
"item": "minecraft:shears"
"items": [
"minecraft:shears"
]
}
},
{
Expand Down Expand Up @@ -61,7 +64,8 @@
]
},
{
"rolls": 1,
"rolls": 1.0,
"bonus_rolls": 0.0,
"entries": [
{
"type": "minecraft:item",
Expand All @@ -82,10 +86,11 @@
{
"function": "minecraft:set_count",
"count": {
"type": "minecraft:uniform",
"min": 1.0,
"max": 2.0,
"type": "minecraft:uniform"
}
"max": 2.0
},
"add": false
},
{
"function": "minecraft:explosion_decay"
Expand All @@ -103,7 +108,9 @@
{
"condition": "minecraft:match_tool",
"predicate": {
"item": "minecraft:shears"
"items": [
"minecraft:shears"
]
}
},
{
Expand All @@ -125,7 +132,8 @@
]
},
{
"rolls": 1,
"rolls": 1.0,
"bonus_rolls": 0.0,
"entries": [
{
"type": "minecraft:item",
Expand Down Expand Up @@ -157,7 +165,9 @@
{
"condition": "minecraft:match_tool",
"predicate": {
"item": "minecraft:shears"
"items": [
"minecraft:shears"
]
}
},
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"type": "minecraft:crafting_shapeless",
"group": "planks",
"ingredients": [
{
"tag": "culturaldelights:avocado_logs"
}
],
"result": {
"item": "minecraft:jungle_planks",
"count": 4
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
}
],
"output": {
"item": "farmersdelight:mutton_sandwich",
"item": "culturaldelights:mutton_sandwich",
"count": 2
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"replace": false,
"values": [
"culturaldelights:avocado_log",
"culturaldelights:avocado_wood"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"replace": false,
"values": [
"culturaldelights:avocado_wood",
"culturaldelights:avocado_log",
"culturaldelights:bamboo_mat"
]
}
Loading

0 comments on commit 238fb4c

Please sign in to comment.