diff --git a/README.md b/README.md index f97515b..1c154af 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,13 @@ -# SolarCooker -Minecraft Forge Mod adding a Solar Cooker +# Solar Cooker [![Curseforge](http://cf.way2muchnoise.eu/full_solar-cooker_downloads.svg)](https://www.curseforge.com/minecraft/mc-mods/solar-cooker) [![Curseforge](http://cf.way2muchnoise.eu/versions/For%20MC_solar-cooker_all.svg)](https://www.curseforge.com/minecraft/mc-mods/solar-cooker/files) [![](https://img.shields.io/discord/752506676719910963.svg?style=flat&color=informational&logo=discord&label=Discord)](https://discord.gg/gRUFH5t) [![License](https://img.shields.io/github/license/cech12/SolarCooker)](http://opensource.org/licenses/MIT) + +This is a **Minecraft Forge** mod and adds a **Solar Cooker** to the game. + +![All Furnaces](https://raw.githubusercontent.com/cech12/SolarCooker/master/material/logo.png) + +It acts like a furnace but needs sunlight instead of fuel. + +In default configuration all smoking recipes are working in the Solar Cooker, and they need 4 times more time than in a vanilla Smoker. + +The mod is configurable, and you can change the recipes to "smelting" or "blasting". You can configure the cook time factor and blacklist recipes as well as add recipes via datapacks. + +For more information check out the **Wiki**: https://github.com/cech12/SolarCooker/wiki \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 533e4a5..255bb28 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,7 @@ org.gradle.jvmargs=-Xmx3G org.gradle.daemon=false -mod_version=0.3.0 +mod_version=0.4.0 minecraft_version=1.15.2 forge_version=1.15.2-31.2.47 diff --git a/src/main/java/cech12/solarcooker/api/block/SolarCookerBlocks.java b/src/main/java/cech12/solarcooker/api/block/SolarCookerBlocks.java index 489ab35..24df6d3 100644 --- a/src/main/java/cech12/solarcooker/api/block/SolarCookerBlocks.java +++ b/src/main/java/cech12/solarcooker/api/block/SolarCookerBlocks.java @@ -6,5 +6,6 @@ public class SolarCookerBlocks { public static Block SOLAR_COOKER; public static Block REFLECTOR; + public static Block SHINING_DIAMOND_BLOCK; } diff --git a/src/main/java/cech12/solarcooker/block/ShiningDiamondBlock.java b/src/main/java/cech12/solarcooker/block/ShiningDiamondBlock.java new file mode 100644 index 0000000..6308eca --- /dev/null +++ b/src/main/java/cech12/solarcooker/block/ShiningDiamondBlock.java @@ -0,0 +1,27 @@ +package cech12.solarcooker.block; + +import net.minecraft.block.Block; +import net.minecraft.client.util.ITooltipFlag; +import net.minecraft.item.ItemStack; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.TextFormatting; +import net.minecraft.util.text.TranslationTextComponent; +import net.minecraft.world.IBlockReader; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import java.util.List; + +public class ShiningDiamondBlock extends Block { + + public ShiningDiamondBlock(Properties properties) { + super(properties); + } + + @Override + public void addInformation(@Nonnull ItemStack stack, @Nullable IBlockReader worldIn, @Nonnull List tooltip, @Nonnull ITooltipFlag flagIn) { + super.addInformation(stack, worldIn, tooltip, flagIn); + tooltip.add(new TranslationTextComponent("item.solarcooker.shining_diamond_block.description").applyTextStyle(TextFormatting.BLUE)); //1.15 + } + +} diff --git a/src/main/java/cech12/solarcooker/config/ServerConfig.java b/src/main/java/cech12/solarcooker/config/ServerConfig.java index 6dfb01a..af41d8c 100644 --- a/src/main/java/cech12/solarcooker/config/ServerConfig.java +++ b/src/main/java/cech12/solarcooker/config/ServerConfig.java @@ -26,7 +26,7 @@ public class ServerConfig { .comment("If enabled, the vanilla blasting, smelting, or smoking recipes are used by the solar cooker.") .define("vanillaRecipesEnabled", true); VANILLA_RECIPE_TYPE = builder - .comment("Defines which vanilla recipes (blasting, smelting, smoking) the solar cooker can use. Possible values: \"smoking\" (default), \"smelting\", \"blasting\"") + .comment("Defines which vanilla recipes the solar cooker can use. Possible values: \"smoking\" (default), \"smelting\", \"blasting\", \"campfire_cooking\"") .define("vanillaRecipeType", "smoking"); COOK_TIME_FACTOR = builder .comment("Cook time factor of the solar cooker in relation to corresponding vanilla furnace. (i. e. 0.5 - half the time, 1.0 same time, 2.0 twice the time)") @@ -54,6 +54,8 @@ public static IRecipeType getRecipeType() { return IRecipeType.SMOKING; case "smelting": return IRecipeType.SMELTING; + case "campfire_cooking": + return IRecipeType.CAMPFIRE_COOKING; case "blasting": return IRecipeType.BLASTING; } diff --git a/src/main/java/cech12/solarcooker/init/ModBlocks.java b/src/main/java/cech12/solarcooker/init/ModBlocks.java index 33de2e7..a641854 100644 --- a/src/main/java/cech12/solarcooker/init/ModBlocks.java +++ b/src/main/java/cech12/solarcooker/init/ModBlocks.java @@ -3,13 +3,17 @@ import cech12.solarcooker.SolarCookerMod; import cech12.solarcooker.api.block.SolarCookerBlocks; import cech12.solarcooker.block.ReflectorBlock; +import cech12.solarcooker.block.ShiningDiamondBlock; import cech12.solarcooker.block.SolarCookerBlock; +//import net.minecraft.block.AbstractBlock; //1.16 import net.minecraft.block.Block; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; +import net.minecraft.block.material.MaterialColor; import net.minecraft.item.BlockItem; import net.minecraft.item.Item; import net.minecraft.item.ItemGroup; +import net.minecraftforge.common.ToolType; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; @@ -22,6 +26,7 @@ public final class ModBlocks { public static void registerBlocks(RegistryEvent.Register event) { SolarCookerBlocks.SOLAR_COOKER = registerBlock("solar_cooker", ItemGroup.DECORATIONS, new SolarCookerBlock(Block.Properties.create(Material.WOOD).hardnessAndResistance(2.5F, 3.5F).sound(SoundType.WOOD))); SolarCookerBlocks.REFLECTOR = registerBlock("reflector", ItemGroup.DECORATIONS, new ReflectorBlock(Block.Properties.create(Material.WOOD).hardnessAndResistance(2.0F).sound(SoundType.WOOD))); + SolarCookerBlocks.SHINING_DIAMOND_BLOCK = registerBlock("shining_diamond_block", ItemGroup.BUILDING_BLOCKS, new ShiningDiamondBlock(Block.Properties.create(Material.IRON, MaterialColor.DIAMOND).harvestTool(ToolType.PICKAXE).hardnessAndResistance(5.0F, 6.0F).sound(SoundType.METAL).lightValue(15))); //1.15 } public static Block registerBlock(String name, ItemGroup itemGroup, Block block) { diff --git a/src/main/java/cech12/solarcooker/init/ModTags.java b/src/main/java/cech12/solarcooker/init/ModTags.java new file mode 100644 index 0000000..7ae3de5 --- /dev/null +++ b/src/main/java/cech12/solarcooker/init/ModTags.java @@ -0,0 +1,22 @@ +package cech12.solarcooker.init; + +import cech12.solarcooker.SolarCookerMod; +import net.minecraft.block.Block; +import net.minecraft.tags.BlockTags; +//import net.minecraft.tags.ITag; //1.16 +import net.minecraft.tags.Tag; //1.15 +import net.minecraft.util.ResourceLocation; //1.15 + +import javax.annotation.Nonnull; + +public class ModTags { + + public static class Blocks { + + public static final Tag SOLAR_COOKER_SHINING = tag("solar_cooker_shining"); //1.15 + + private static Tag tag(@Nonnull String name) { //1.15 + return new BlockTags.Wrapper(new ResourceLocation(SolarCookerMod.MOD_ID + ":" + name)); //1.15 + } + } +} diff --git a/src/main/java/cech12/solarcooker/tileentity/AbstractSolarCookerTileEntity.java b/src/main/java/cech12/solarcooker/tileentity/AbstractSolarCookerTileEntity.java index b53c6d6..4758db9 100644 --- a/src/main/java/cech12/solarcooker/tileentity/AbstractSolarCookerTileEntity.java +++ b/src/main/java/cech12/solarcooker/tileentity/AbstractSolarCookerTileEntity.java @@ -4,6 +4,7 @@ import cech12.solarcooker.block.ReflectorBlock; import cech12.solarcooker.block.SolarCookerBlock; import cech12.solarcooker.config.ServerConfig; +import cech12.solarcooker.init.ModTags; import com.google.common.collect.Lists; import it.unimi.dsi.fastutil.objects.Object2IntMap; import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; @@ -81,13 +82,33 @@ public AbstractSolarCookerTileEntity(TileEntityType tileTypeIn, protected AbstractCookingRecipe curRecipe; protected ItemStack failedMatch = ItemStack.EMPTY; + private boolean hasShiningBlockAbove() { + if (this.world != null && !this.world.isRemote) { + BlockPos checkPos = this.pos.up(); + if (this.world.getBlockState(checkPos).propagatesSkylightDown(this.world, checkPos)) { + for (int i = 0; i < 5; i++) { + checkPos = checkPos.up(); + BlockState state = this.world.getBlockState(checkPos); + if (state.isIn(ModTags.Blocks.SOLAR_COOKER_SHINING)) { + return true; + } + if (!state.propagatesSkylightDown(this.world, checkPos)) { + return false; + } + } + } + } + return false; + } + public boolean isSunlit() { if (this.world != null) { if (!this.world.isRemote) { - return this.world.getDimension().hasSkyLight() //1.15 + return this.hasShiningBlockAbove() || ( + this.world.getDimension().hasSkyLight() //1.15 && this.world.isDaytime() && !this.world.isRaining() - && this.world.canSeeSky(this.pos.up()); + && this.world.canSeeSky(this.pos.up())); } else { //world.isDaytime() returns always true on client side return AbstractSolarCookerTileEntity.this.getBlockState().get(SolarCookerBlock.SUNLIT); diff --git a/src/main/resources/assets/solarcooker/blockstates/shining_diamond_block.json b/src/main/resources/assets/solarcooker/blockstates/shining_diamond_block.json new file mode 100644 index 0000000..df79b46 --- /dev/null +++ b/src/main/resources/assets/solarcooker/blockstates/shining_diamond_block.json @@ -0,0 +1,7 @@ +{ + "variants": { + "": { + "model": "solarcooker:block/shining_diamond_block" + } + } +} diff --git a/src/main/resources/assets/solarcooker/lang/de_de.json b/src/main/resources/assets/solarcooker/lang/de_de.json index dd1afe3..2957194 100644 --- a/src/main/resources/assets/solarcooker/lang/de_de.json +++ b/src/main/resources/assets/solarcooker/lang/de_de.json @@ -1,6 +1,8 @@ { "block.solarcooker.solar_cooker": "Solarkocher", "block.solarcooker.reflector": "Reflektor", + "block.solarcooker.shining_diamond_block": "Strahlender Diamantblock", - "item.solarcooker.reflector.description": "Links und rechts neben einem Solarkocher können bis zu vier Reflektoren platziert werden, um den Lichteinfall zu verbessern und die Kochzeit zu reduzieren." + "item.solarcooker.reflector.description": "Links und rechts neben einem Solarkocher können bis zu vier Reflektoren platziert werden, um den Lichteinfall zu verbessern und die Kochzeit zu reduzieren.", + "item.solarcooker.shining_diamond_block.description": "Shine bright! Kann über einem Solarkocher platziert werden, um ihn unabhängig von der Sonne zu nutzen." } \ No newline at end of file diff --git a/src/main/resources/assets/solarcooker/lang/en_us.json b/src/main/resources/assets/solarcooker/lang/en_us.json index eced7ea..98890d0 100644 --- a/src/main/resources/assets/solarcooker/lang/en_us.json +++ b/src/main/resources/assets/solarcooker/lang/en_us.json @@ -1,6 +1,8 @@ { "block.solarcooker.solar_cooker": "Solar Cooker", "block.solarcooker.reflector": "Reflector", + "block.solarcooker.shining_diamond_block": "Shining Block of Diamond", - "item.solarcooker.reflector.description": "Up to four Reflectors can be placed to the left and right side of a Solar Cooker to improve the incidence of light and reduce cooking time." + "item.solarcooker.reflector.description": "Up to four Reflectors can be placed to the left and right side of a Solar Cooker to improve the incidence of light and reduce cooking time.", + "item.solarcooker.shining_diamond_block.description": "Shine bright! Can be placed above a Solar Cooker to use it independently of the sun." } \ No newline at end of file diff --git a/src/main/resources/assets/solarcooker/models/block/shining_diamond_block.json b/src/main/resources/assets/solarcooker/models/block/shining_diamond_block.json new file mode 100644 index 0000000..92ddec2 --- /dev/null +++ b/src/main/resources/assets/solarcooker/models/block/shining_diamond_block.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:block/cube_all", + "textures": { + "all": "solarcooker:block/shining_diamond_block" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/solarcooker/models/item/shining_diamond_block.json b/src/main/resources/assets/solarcooker/models/item/shining_diamond_block.json new file mode 100644 index 0000000..7e17545 --- /dev/null +++ b/src/main/resources/assets/solarcooker/models/item/shining_diamond_block.json @@ -0,0 +1,3 @@ +{ + "parent": "solarcooker:block/shining_diamond_block" +} \ No newline at end of file diff --git a/src/main/resources/assets/solarcooker/textures/block/shining_diamond_block.png b/src/main/resources/assets/solarcooker/textures/block/shining_diamond_block.png new file mode 100644 index 0000000..27f663f Binary files /dev/null and b/src/main/resources/assets/solarcooker/textures/block/shining_diamond_block.png differ diff --git a/src/main/resources/assets/solarcooker/textures/block/shining_diamond_block.png.mcmeta b/src/main/resources/assets/solarcooker/textures/block/shining_diamond_block.png.mcmeta new file mode 100644 index 0000000..e8ac9bc --- /dev/null +++ b/src/main/resources/assets/solarcooker/textures/block/shining_diamond_block.png.mcmeta @@ -0,0 +1,5 @@ +{ + "animation": { + "frametime": 5 + } +} diff --git a/src/main/resources/data/solarcooker/advancements/recipes/building_blocks/diamond_block.json b/src/main/resources/data/solarcooker/advancements/recipes/building_blocks/diamond_block.json new file mode 100644 index 0000000..03164d6 --- /dev/null +++ b/src/main/resources/data/solarcooker/advancements/recipes/building_blocks/diamond_block.json @@ -0,0 +1,32 @@ +{ + "parent": "minecraft:recipes/root", + "rewards": { + "recipes": [ + "solarcooker:diamond_block" + ] + }, + "criteria": { + "has_diamond_block": { + "trigger": "minecraft:inventory_changed", + "conditions": { + "items": [ + { + "item": "solarcooker:shining_diamond_block" + } + ] + } + }, + "has_the_recipe": { + "trigger": "minecraft:recipe_unlocked", + "conditions": { + "recipe": "solarcooker:diamond_block" + } + } + }, + "requirements": [ + [ + "has_diamond_block", + "has_the_recipe" + ] + ] +} \ No newline at end of file diff --git a/src/main/resources/data/solarcooker/advancements/recipes/building_blocks/shining_diamond_block.json b/src/main/resources/data/solarcooker/advancements/recipes/building_blocks/shining_diamond_block.json new file mode 100644 index 0000000..831b85c --- /dev/null +++ b/src/main/resources/data/solarcooker/advancements/recipes/building_blocks/shining_diamond_block.json @@ -0,0 +1,32 @@ +{ + "parent": "minecraft:recipes/root", + "rewards": { + "recipes": [ + "solarcooker:shining_diamond_block" + ] + }, + "criteria": { + "has_diamond_block": { + "trigger": "minecraft:inventory_changed", + "conditions": { + "items": [ + { + "item": "minecraft:diamond_block" + } + ] + } + }, + "has_the_recipe": { + "trigger": "minecraft:recipe_unlocked", + "conditions": { + "recipe": "solarcooker:shining_diamond_block" + } + } + }, + "requirements": [ + [ + "has_diamond_block", + "has_the_recipe" + ] + ] +} \ No newline at end of file diff --git a/src/main/resources/data/solarcooker/loot_tables/blocks/shining_diamond_block.json b/src/main/resources/data/solarcooker/loot_tables/blocks/shining_diamond_block.json new file mode 100644 index 0000000..200df68 --- /dev/null +++ b/src/main/resources/data/solarcooker/loot_tables/blocks/shining_diamond_block.json @@ -0,0 +1,25 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "functions": [ + { + "function": "minecraft:copy_name", + "source": "block_entity" + } + ], + "name": "solarcooker:shining_diamond_block" + } + ], + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ] + } + ] +} \ No newline at end of file diff --git a/src/main/resources/data/solarcooker/recipes/diamond_block.json b/src/main/resources/data/solarcooker/recipes/diamond_block.json new file mode 100644 index 0000000..5a92386 --- /dev/null +++ b/src/main/resources/data/solarcooker/recipes/diamond_block.json @@ -0,0 +1,11 @@ +{ + "type": "minecraft:crafting_shapeless", + "ingredients": [ + { + "item": "solarcooker:shining_diamond_block" + } + ], + "result": { + "item": "minecraft:diamond_block" + } +} \ No newline at end of file diff --git a/src/main/resources/data/solarcooker/recipes/shining_diamond_block.json b/src/main/resources/data/solarcooker/recipes/shining_diamond_block.json new file mode 100644 index 0000000..5b6a565 --- /dev/null +++ b/src/main/resources/data/solarcooker/recipes/shining_diamond_block.json @@ -0,0 +1,9 @@ +{ + "type": "solarcooker:solarcooking", + "ingredient": { + "item": "minecraft:diamond_block" + }, + "result": "solarcooker:shining_diamond_block", + "experience": 0.3, + "cookingtime": 3000 +} \ No newline at end of file diff --git a/src/main/resources/data/solarcooker/tags/blocks/solar_cooker_shining.json b/src/main/resources/data/solarcooker/tags/blocks/solar_cooker_shining.json new file mode 100644 index 0000000..d9658ce --- /dev/null +++ b/src/main/resources/data/solarcooker/tags/blocks/solar_cooker_shining.json @@ -0,0 +1,6 @@ +{ + "replace": false, + "values": [ + "solarcooker:shining_diamond_block" + ] +} \ No newline at end of file