Skip to content

Commit

Permalink
- backport shining diamond block #9
Browse files Browse the repository at this point in the history
- backport campfire_cooking configuration
  • Loading branch information
cech12 committed Feb 1, 2021
1 parent b0a45b4 commit 961e2da
Show file tree
Hide file tree
Showing 21 changed files with 237 additions and 8 deletions.
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ public class SolarCookerBlocks {

public static Block SOLAR_COOKER;
public static Block REFLECTOR;
public static Block SHINING_DIAMOND_BLOCK;

}
27 changes: 27 additions & 0 deletions src/main/java/cech12/solarcooker/block/ShiningDiamondBlock.java
Original file line number Diff line number Diff line change
@@ -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<ITextComponent> 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
}

}
4 changes: 3 additions & 1 deletion src/main/java/cech12/solarcooker/config/ServerConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)")
Expand Down Expand Up @@ -54,6 +54,8 @@ public static IRecipeType<? extends AbstractCookingRecipe> getRecipeType() {
return IRecipeType.SMOKING;
case "smelting":
return IRecipeType.SMELTING;
case "campfire_cooking":
return IRecipeType.CAMPFIRE_COOKING;
case "blasting":
return IRecipeType.BLASTING;
}
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/cech12/solarcooker/init/ModBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -22,6 +26,7 @@ public final class ModBlocks {
public static void registerBlocks(RegistryEvent.Register<Block> 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) {
Expand Down
22 changes: 22 additions & 0 deletions src/main/java/cech12/solarcooker/init/ModTags.java
Original file line number Diff line number Diff line change
@@ -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<Block> SOLAR_COOKER_SHINING = tag("solar_cooker_shining"); //1.15

private static Tag<Block> tag(@Nonnull String name) { //1.15
return new BlockTags.Wrapper(new ResourceLocation(SolarCookerMod.MOD_ID + ":" + name)); //1.15
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "solarcooker:block/shining_diamond_block"
}
}
}
4 changes: 3 additions & 1 deletion src/main/resources/assets/solarcooker/lang/de_de.json
Original file line number Diff line number Diff line change
@@ -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."
}
4 changes: 3 additions & 1 deletion src/main/resources/assets/solarcooker/lang/en_us.json
Original file line number Diff line number Diff line change
@@ -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."
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:block/cube_all",
"textures": {
"all": "solarcooker:block/shining_diamond_block"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"parent": "solarcooker:block/shining_diamond_block"
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"animation": {
"frametime": 5
}
}
Original file line number Diff line number Diff line change
@@ -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"
]
]
}
Original file line number Diff line number Diff line change
@@ -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"
]
]
}
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
]
}
11 changes: 11 additions & 0 deletions src/main/resources/data/solarcooker/recipes/diamond_block.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"type": "minecraft:crafting_shapeless",
"ingredients": [
{
"item": "solarcooker:shining_diamond_block"
}
],
"result": {
"item": "minecraft:diamond_block"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"type": "solarcooker:solarcooking",
"ingredient": {
"item": "minecraft:diamond_block"
},
"result": "solarcooker:shining_diamond_block",
"experience": 0.3,
"cookingtime": 3000
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"solarcooker:shining_diamond_block"
]
}

0 comments on commit 961e2da

Please sign in to comment.