diff --git a/build.gradle b/build.gradle index 7119604..c21ec06 100644 --- a/build.gradle +++ b/build.gradle @@ -21,7 +21,7 @@ apply plugin: 'eclipse' apply plugin: 'maven-publish' apply plugin: "org.spongepowered.mixin" -version = '1.18.2-0.10' +version = '1.18.2-0.10.1' group = 'com.ncpbails.culturaldelights' // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = 'culturaldelights' @@ -189,6 +189,7 @@ dependencies { implementation fg.deobf("curse.maven:farmersdelight-398521:3765351") runtimeOnly fg.deobf("curse.maven:appleskin-248787:3686482") + // Real mod deobf dependency examples - these get remapped to your current mappings // compileOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}:api") // Adds JEI API as a compile dependency // runtimeOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}") // Adds the full JEI mod as a runtime dependency @@ -208,7 +209,7 @@ jar { attributes([ "Specification-Title" : "culturaldelights", "Specification-Vendor" : "ncpbails", - "Specification-Version" : "1", // We are version 1 of ourselves + "Specification-Version" : "0.10.1", // We are version 1 of ourselves "Implementation-Title" : project.name, "Implementation-Version" : project.jar.archiveVersion, "Implementation-Vendor" : "ncpbails", diff --git a/src/main/java/com/ncpbails/culturaldelights/CulturalDelights.java b/src/main/java/com/ncpbails/culturaldelights/CulturalDelights.java index f249817..a060d05 100644 --- a/src/main/java/com/ncpbails/culturaldelights/CulturalDelights.java +++ b/src/main/java/com/ncpbails/culturaldelights/CulturalDelights.java @@ -10,8 +10,14 @@ import net.minecraft.client.gui.screens.MenuScreens; import net.minecraft.client.renderer.ItemBlockRenderTypes; import net.minecraft.client.renderer.RenderType; +import net.minecraft.world.entity.animal.Chicken; +import net.minecraft.world.entity.animal.Parrot; +import net.minecraft.world.entity.animal.Pig; +import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.ComposterBlock; import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.common.crafting.CompoundIngredient; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; @@ -19,6 +25,9 @@ import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import org.slf4j.Logger; + +import java.util.Arrays; +import java.util.Collections; import java.util.stream.Collectors; // The value here should match an entry in the META-INF/mods.toml file @@ -70,9 +79,63 @@ private void clientSetup(final FMLClientSetupEvent event) { private void setup(final FMLCommonSetupEvent event) { + event.enqueueWork(() -> { + registerCompostables(); + //registerAnimalFeeds(); + }); + // some preinit code LOGGER.info("HELLO FROM PREINIT"); LOGGER.info("DIRT BLOCK >> {}", Blocks.DIRT.getRegistryName()); } -} + + public static void registerCompostables() { + // 30% chance + ComposterBlock.COMPOSTABLES.put(ModItems.CUCUMBER_SEEDS.get(), 0.3F); + ComposterBlock.COMPOSTABLES.put(ModItems.CORN_KERNELS.get(), 0.3F); + ComposterBlock.COMPOSTABLES.put(ModItems.EGGPLANT_SEEDS.get(), 0.3F); + ComposterBlock.COMPOSTABLES.put(ModItems.WHITE_EGGPLANT_SEEDS.get(), 0.3F); + ComposterBlock.COMPOSTABLES.put(ModBlocks.AVOCADO_PIT.get(), 0.3F); + + // 50% chance + ComposterBlock.COMPOSTABLES.put(ModItems.CUT_CUCUMBER.get(), 0.65F); + ComposterBlock.COMPOSTABLES.put(ModItems.CUT_AVOCADO.get(), 0.65F); + ComposterBlock.COMPOSTABLES.put(ModItems.CUT_EGGPLANT.get(), 0.65F); + + // 65% chance + ComposterBlock.COMPOSTABLES.put(ModItems.AVOCADO.get(), 0.65F); + ComposterBlock.COMPOSTABLES.put(ModItems.CUCUMBER.get(), 0.65F); + ComposterBlock.COMPOSTABLES.put(ModItems.CORN_COB.get(), 0.65F); + ComposterBlock.COMPOSTABLES.put(ModItems.EGGPLANT.get(), 0.65F); + ComposterBlock.COMPOSTABLES.put(ModItems.WHITE_EGGPLANT.get(), 0.65F); + ComposterBlock.COMPOSTABLES.put(ModBlocks.WILD_CUCUMBERS.get(), 0.65F); + ComposterBlock.COMPOSTABLES.put(ModBlocks.WILD_CORN.get(), 0.65F); + ComposterBlock.COMPOSTABLES.put(ModBlocks.WILD_EGGPLANTS.get(), 0.65F); + ComposterBlock.COMPOSTABLES.put(ModBlocks.AVOCADO_LEAVES.get(), 0.65F); + ComposterBlock.COMPOSTABLES.put(ModBlocks.AVOCADO_SAPLING.get(), 0.65F); + + // 85% chance + ComposterBlock.COMPOSTABLES.put(ModItems.POPCORN.get(), 0.85F); + + // 100% chance + ComposterBlock.COMPOSTABLES.put(ModBlocks.AVOCADO_BUNDLE.get(), 0.65F); + } + + //public static void registerAnimalFeeds() { + // Ingredient newChickenFood = Ingredient.of(ModItems.CUCUMBER_SEEDS.get(), ModItems.CORN_KERNELS.get(), + // ModItems.EGGPLANT_SEEDS.get(), ModItems.WHITE_EGGPLANT_SEEDS.get()); + // Chicken.FOOD_ITEMS = new CompoundIngredient(Arrays.asList(Chicken.FOOD_ITEMS, newChickenFood)) + // { + // }; + + // Ingredient newPigFood = Ingredient.of(ModItems.CUCUMBER.get(), ModItems.EGGPLANT.get(), + // ModItems.WHITE_EGGPLANT.get(), ModItems.CORN_COB.get()); + // Pig.FOOD_ITEMS = new CompoundIngredient(Arrays.asList(Pig.FOOD_ITEMS, newPigFood)) + // { + // }; + + // Collections.addAll(Parrot.TAME_FOOD, ModItems.CUCUMBER_SEEDS.get(), ModItems.CORN_KERNELS.get(), + // ModItems.EGGPLANT_SEEDS.get(), ModItems.WHITE_EGGPLANT_SEEDS.get()); + //} +} \ No newline at end of file diff --git a/src/main/java/com/ncpbails/culturaldelights/block/ModBlocks.java b/src/main/java/com/ncpbails/culturaldelights/block/ModBlocks.java index bb1da98..353cf39 100644 --- a/src/main/java/com/ncpbails/culturaldelights/block/ModBlocks.java +++ b/src/main/java/com/ncpbails/culturaldelights/block/ModBlocks.java @@ -7,6 +7,7 @@ import com.ncpbails.culturaldelights.world.feature.tree.AvocadoTreeGrower; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.world.effect.MobEffects; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.*; import net.minecraft.world.item.crafting.RecipeType; @@ -24,6 +25,7 @@ import net.minecraftforge.registries.RegistryObject; import org.jetbrains.annotations.Nullable; import vectorwing.farmersdelight.FarmersDelight; +import vectorwing.farmersdelight.common.block.WildCropBlock; import java.util.function.Supplier; @@ -35,19 +37,19 @@ public class ModBlocks { public static final RegistryObject BAMBOO_MAT = registerBlock("bamboo_mat", () -> new BambooMatBlock(BlockBehaviour.Properties.copy(vectorwing.farmersdelight.common.registry.ModBlocks.CUTTING_BOARD.get()) - .noOcclusion()), FarmersDelight.CREATIVE_TAB, true, 0); + .noOcclusion()), FarmersDelight.CREATIVE_TAB, true, 200); - public static final RegistryObject WILD_CUCUMBERS = registerBlock("wild_cucumbers", - () -> new Block(BlockBehaviour.Properties.copy(vectorwing.farmersdelight.common.registry.ModBlocks.WILD_BEETROOTS.get()) - .noOcclusion()), FarmersDelight.CREATIVE_TAB, false, 0); + public static final RegistryObject WILD_CUCUMBERS = registerBlock("wild_cucumbers", + () -> new WildCropBlock(MobEffects.FIRE_RESISTANCE, 6, BlockBehaviour.Properties.copy(Blocks.TALL_GRASS), false), + FarmersDelight.CREATIVE_TAB, false, 0); public static final RegistryObject WILD_CORN = registerBlock("wild_corn", - () -> new Block(BlockBehaviour.Properties.copy(vectorwing.farmersdelight.common.registry.ModBlocks.WILD_BEETROOTS.get()) - .noOcclusion()), FarmersDelight.CREATIVE_TAB, false, 0); + () -> new WildCropBlock(MobEffects.HUNGER, 6, BlockBehaviour.Properties.copy(Blocks.TALL_GRASS), false), + FarmersDelight.CREATIVE_TAB, false, 0); public static final RegistryObject WILD_EGGPLANTS = registerBlock("wild_eggplants", - () -> new Block(BlockBehaviour.Properties.copy(vectorwing.farmersdelight.common.registry.ModBlocks.WILD_BEETROOTS.get()) - .noOcclusion()), FarmersDelight.CREATIVE_TAB, false, 0); + () -> new WildCropBlock(MobEffects.DAMAGE_BOOST, 6, BlockBehaviour.Properties.copy(Blocks.TALL_GRASS), false), + FarmersDelight.CREATIVE_TAB, false, 0); public static final RegistryObject AVOCADO_LOG = registerBlock("avocado_log", () -> new RotatedPillarBlock(BlockBehaviour.Properties.copy(Blocks.JUNGLE_LOG)) { @@ -57,7 +59,7 @@ public class ModBlocks { @Nullable @Override public BlockState getToolModifiedState(BlockState state, Level world, BlockPos pos, Player player, ItemStack stack, ToolAction toolAction){ if(stack.getItem() instanceof AxeItem) { return Blocks.JUNGLE_LOG.defaultBlockState().setValue(AXIS, state.getValue(AXIS)); } return super.getToolModifiedState(state, world, pos, player, stack, toolAction); } - }, FarmersDelight.CREATIVE_TAB, true, 0); + }, FarmersDelight.CREATIVE_TAB, true, 300); public static final RegistryObject AVOCADO_WOOD = registerBlock("avocado_wood", () -> new RotatedPillarBlock(BlockBehaviour.Properties.copy(Blocks.JUNGLE_WOOD)) { @@ -67,17 +69,18 @@ public class ModBlocks { @Nullable @Override public BlockState getToolModifiedState(BlockState state, Level world, BlockPos pos, Player player, ItemStack stack, ToolAction toolAction){ if(stack.getItem() instanceof AxeItem) { return Blocks.JUNGLE_WOOD.defaultBlockState().setValue(AXIS, state.getValue(AXIS)); } return super.getToolModifiedState(state, world, pos, player, stack, toolAction); } - }, FarmersDelight.CREATIVE_TAB, true, 0); + }, FarmersDelight.CREATIVE_TAB, true, 300); public static final RegistryObject AVOCADO_LEAVES = registerBlock("avocado_leaves", () -> new LeavesBlock(BlockBehaviour.Properties.copy(Blocks.JUNGLE_LEAVES)) { @Override public boolean isFlammable(BlockState state, BlockGetter world, BlockPos pos, Direction face) { return true; } @Override public int getFlammability(BlockState state, BlockGetter world, BlockPos pos, Direction face) { return 60; } @Override public int getFireSpreadSpeed(BlockState state, BlockGetter world, BlockPos pos, Direction face) { return 30; } - }, FarmersDelight.CREATIVE_TAB, true, 0); + }, FarmersDelight.CREATIVE_TAB, false, 0); public static final RegistryObject AVOCADO_SAPLING = registerBlock("avocado_sapling", - () -> new SaplingBlock(new AvocadoTreeGrower(), BlockBehaviour.Properties.copy(Blocks.OAK_SAPLING)), FarmersDelight.CREATIVE_TAB, true, 0); + () -> new SaplingBlock(new AvocadoTreeGrower(), BlockBehaviour.Properties.copy(Blocks.OAK_SAPLING)), + FarmersDelight.CREATIVE_TAB, true, 100); public static final RegistryObject CUCUMBERS = registerBlockWithoutBlockItem("cucumbers", () -> new CucumbersBlock(BlockBehaviour.Properties.copy(Blocks.WHEAT).noOcclusion())); diff --git a/src/main/java/com/ncpbails/culturaldelights/block/entity/custom/BambooMatBlockEntity.java b/src/main/java/com/ncpbails/culturaldelights/block/entity/custom/BambooMatBlockEntity.java index 81401d8..734c875 100644 --- a/src/main/java/com/ncpbails/culturaldelights/block/entity/custom/BambooMatBlockEntity.java +++ b/src/main/java/com/ncpbails/culturaldelights/block/entity/custom/BambooMatBlockEntity.java @@ -3,15 +3,19 @@ import com.ncpbails.culturaldelights.block.entity.ModBlockEntities; import com.ncpbails.culturaldelights.item.ModItems; import com.ncpbails.culturaldelights.recipe.BambooMatRecipe; +import com.ncpbails.culturaldelights.recipe.ModRecipes; import com.ncpbails.culturaldelights.screen.BambooMatMenu; +import com.ncpbails.culturaldelights.util.ModTags; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.TextComponent; +import net.minecraft.tags.ItemTags; import net.minecraft.world.Containers; import net.minecraft.world.MenuProvider; import net.minecraft.world.SimpleContainer; +import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.AbstractContainerMenu; @@ -31,6 +35,7 @@ import net.minecraftforge.items.ItemStackHandler; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import vectorwing.farmersdelight.common.block.entity.CookingPotBlockEntity; import javax.annotation.Nonnull; import java.util.Optional; @@ -170,6 +175,7 @@ private static void craftItem(BambooMatBlockEntity entity) { .getRecipeFor(BambooMatRecipe.Type.INSTANCE, inventory, level); if(match.isPresent()) { + giveBowls(entity); entity.itemHandler.extractItem(0,1, false); entity.itemHandler.extractItem(1,1, false); entity.itemHandler.extractItem(2,1, false); @@ -183,6 +189,21 @@ private static void craftItem(BambooMatBlockEntity entity) { } } + private static void giveBowls(BambooMatBlockEntity entity) { + SimpleContainer inventory = new SimpleContainer(entity.itemHandler.getSlots()); + Optional match = entity.level.getRecipeManager() + .getRecipeFor(BambooMatRecipe.Type.INSTANCE, inventory, entity.level); + for (int i = 0; i < entity.itemHandler.getSlots(); i++) { + + if((entity.itemHandler.getStackInSlot(i)).is(ModTags.Items.BOWL_FOODS)) { + if(!entity.level.isClientSide()) { + ItemEntity entityToSpawn = new ItemEntity((Level) entity.level, entity.worldPosition.getX(), entity.worldPosition.getY(), entity.worldPosition.getZ(), new ItemStack(Items.BOWL)); + entity.level.addFreshEntity(entityToSpawn); + } + } + } + } + private void resetProgress() { this.progress = 0; } diff --git a/src/main/java/com/ncpbails/culturaldelights/event/ModEvents.java b/src/main/java/com/ncpbails/culturaldelights/event/ModEvents.java new file mode 100644 index 0000000..b322866 --- /dev/null +++ b/src/main/java/com/ncpbails/culturaldelights/event/ModEvents.java @@ -0,0 +1,55 @@ +package com.ncpbails.culturaldelights.event; + +import com.ncpbails.culturaldelights.CulturalDelights; +import com.ncpbails.culturaldelights.item.ModItems; +import it.unimi.dsi.fastutil.ints.Int2ObjectMap; +import net.minecraft.world.entity.npc.VillagerProfession; +import net.minecraft.world.entity.npc.VillagerTrades; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.item.trading.MerchantOffer; +import net.minecraftforge.event.village.VillagerTradesEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.common.Mod; + +import java.util.List; + +@Mod.EventBusSubscriber(modid = CulturalDelights.MOD_ID) +public class ModEvents { + + @SubscribeEvent + public static void addCustomTrades(VillagerTradesEvent event) { + + if(event.getType() == VillagerProfession.FARMER) { + Int2ObjectMap> trades = event.getTrades(); + ItemStack stack = new ItemStack(Items.EMERALD, 1); + int villagerLevel = 1; + + trades.get(villagerLevel).add((trader, rand) -> new MerchantOffer( + new ItemStack(ModItems.CUCUMBER.get(), 22), + stack,10,2,0.02F)); + //max uses pXp price multiplier + + trades.get(villagerLevel).add((trader, rand) -> new MerchantOffer( + new ItemStack(ModItems.EGGPLANT.get(), 15), + stack,10,2,0.02F)); + //max uses pXp price multiplier + + trades.get(villagerLevel).add((trader, rand) -> new MerchantOffer( + new ItemStack(ModItems.WHITE_EGGPLANT.get(), 20), + stack,10,2,0.02F)); + //max uses pXp price multiplier + + trades.get(villagerLevel).add((trader, rand) -> new MerchantOffer( + new ItemStack(ModItems.CORN_COB.get(), 15), + stack,10,2,0.02F)); + //max uses pXp price multiplier + + trades.get(villagerLevel).add((trader, rand) -> new MerchantOffer( + new ItemStack(ModItems.AVOCADO.get(), 20), + stack,10,2,0.02F)); + //max uses pXp price multiplier + } + + } +} diff --git a/src/main/java/com/ncpbails/culturaldelights/world/ModWorldEvents.java b/src/main/java/com/ncpbails/culturaldelights/world/ModWorldEvents.java index c580418..8ba679e 100644 --- a/src/main/java/com/ncpbails/culturaldelights/world/ModWorldEvents.java +++ b/src/main/java/com/ncpbails/culturaldelights/world/ModWorldEvents.java @@ -14,8 +14,5 @@ public class ModWorldEvents { public static void biomeLoadingEvent(final BiomeLoadingEvent event) { ModTreeGeneration.generateTrees(event); ModWildCropGeneration.generateFlowers(event); - //ModPlantGeneration.generatePlants(event); - } - - + } } diff --git a/src/main/java/com/ncpbails/culturaldelights/world/feature/ModPlacedFeatures.java b/src/main/java/com/ncpbails/culturaldelights/world/feature/ModPlacedFeatures.java index a37c94c..ab49958 100644 --- a/src/main/java/com/ncpbails/culturaldelights/world/feature/ModPlacedFeatures.java +++ b/src/main/java/com/ncpbails/culturaldelights/world/feature/ModPlacedFeatures.java @@ -13,14 +13,14 @@ public class ModPlacedFeatures { ModConfiguredFeatures.AVOCADO_SPAWN, VegetationPlacements.treePlacement(PlacementUtils.countExtra(1, 0.1f, 1))); public static final Holder WILD_CORN_PLACED = PlacementUtils.register("wild_corn_placed", - ModConfiguredFeatures.WILD_CORN, RarityFilter.onAverageOnceEvery(16), + ModConfiguredFeatures.WILD_CORN, RarityFilter.onAverageOnceEvery(25), InSquarePlacement.spread(), PlacementUtils.HEIGHTMAP, BiomeFilter.biome()); public static final Holder WILD_EGGPLANTS_PLACED = PlacementUtils.register("wild_eggplants_placed", - ModConfiguredFeatures.WILD_EGGPLANTS, RarityFilter.onAverageOnceEvery(16), + ModConfiguredFeatures.WILD_EGGPLANTS, RarityFilter.onAverageOnceEvery(25), InSquarePlacement.spread(), PlacementUtils.HEIGHTMAP, BiomeFilter.biome()); public static final Holder WILD_CUCUMBERS_PLACED = PlacementUtils.register("wild_cucumbers_placed", - ModConfiguredFeatures.WILD_CUCUMBERS, RarityFilter.onAverageOnceEvery(16), + ModConfiguredFeatures.WILD_CUCUMBERS, RarityFilter.onAverageOnceEvery(25), InSquarePlacement.spread(), PlacementUtils.HEIGHTMAP, BiomeFilter.biome()); -} +} \ No newline at end of file diff --git a/src/main/java/com/ncpbails/culturaldelights/world/gen/ModWildCropGeneration.java b/src/main/java/com/ncpbails/culturaldelights/world/gen/ModWildCropGeneration.java index 1f3a885..9f89066 100644 --- a/src/main/java/com/ncpbails/culturaldelights/world/gen/ModWildCropGeneration.java +++ b/src/main/java/com/ncpbails/culturaldelights/world/gen/ModWildCropGeneration.java @@ -25,7 +25,7 @@ public static void generateFlowers(final BiomeLoadingEvent event) { base.add(ModPlacedFeatures.WILD_CORN_PLACED); } - if(types.contains(BiomeDictionary.Type.SWAMP)) { + else if(types.contains(BiomeDictionary.Type.SWAMP)) { List> base = event.getGeneration().getFeatures(GenerationStep.Decoration.VEGETAL_DECORATION); @@ -33,7 +33,7 @@ public static void generateFlowers(final BiomeLoadingEvent event) { base.add(ModPlacedFeatures.WILD_CUCUMBERS_PLACED); } - if(types.contains(BiomeDictionary.Type.JUNGLE)) { + else if(types.contains(BiomeDictionary.Type.JUNGLE)) { List> base = event.getGeneration().getFeatures(GenerationStep.Decoration.VEGETAL_DECORATION); diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg new file mode 100644 index 0000000..ea1fca0 --- /dev/null +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -0,0 +1,3 @@ +public-f net.minecraft.world.entity.animal.Chicken p_28271_ # FOOD_ITEMS +public-f net.minecraft.world.entity.animal.Pig f_29458_ # FOOD_ITEMS +public-f net.minecraft.world.entity.animal.Parrot f_29357_ # TAME_FOOD \ No newline at end of file