Skip to content

Commit

Permalink
First commit of chocolate
Browse files Browse the repository at this point in the history
Because it just makes sense, right?
  • Loading branch information
KnightMiner committed Aug 11, 2019
1 parent 6f66723 commit f1f9221
Show file tree
Hide file tree
Showing 15 changed files with 201 additions and 46 deletions.
5 changes: 5 additions & 0 deletions src/main/java/knightminer/tcomplement/common/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ public static class General {
@Comment("Enables the bucket cast: allows casting buckets using a casting table.")
@LangKey("tcomplement.config.general.bucketCast")
public boolean bucketCast = true;

@RequiresMcRestart
@Comment("Enables chocolate: made using a smeltery. Its a secret, so don't tell anyone.")
@LangKey("tcomplement.config.general.chocolate")
public boolean chocolate = true;
}

public static class Melter {
Expand Down
27 changes: 27 additions & 0 deletions src/main/java/knightminer/tcomplement/plugin/jei/JEIPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,21 @@
import knightminer.tcomplement.plugin.jei.highoven.mix.HighOvenMixWrapper;
import knightminer.tcomplement.plugin.jei.melter.MeltingRecipeCategory;
import knightminer.tcomplement.plugin.jei.melter.MeltingRecipeWrapper;
import knightminer.tcomplement.shared.CommonsModule;
import knightminer.tcomplement.steelworks.SteelworksModule;
import knightminer.tcomplement.steelworks.client.GuiHighOven;
import mezz.jei.api.IGuiHelper;
import mezz.jei.api.IModPlugin;
import mezz.jei.api.IModRegistry;
import mezz.jei.api.gui.IAdvancedGuiHandler;
import mezz.jei.api.ingredients.IIngredientBlacklist;
import mezz.jei.api.recipe.IRecipeCategoryRegistration;
import mezz.jei.api.recipe.VanillaRecipeCategoryUid;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidUtil;
import slimeknights.tconstruct.library.smeltery.MeltingRecipe;
import slimeknights.tconstruct.plugin.jei.casting.CastingRecipeCategory;
import slimeknights.tconstruct.plugin.jei.smelting.SmeltingRecipeChecker;
Expand Down Expand Up @@ -179,6 +184,28 @@ public void register(IModRegistry registry) {
)),
EXNIHILO_HAMMER);
}

// chocolate is a secret, don't tell anyone
if(Config.general.chocolate) {
IIngredientBlacklist blacklist = registry.getJeiHelpers().getIngredientBlacklist();
blacklistFluid(blacklist, CommonsModule.chocolateLiquor);
blacklistFluid(blacklist, CommonsModule.milkChocolate);
blacklist.addIngredientToBlacklist(CommonsModule.milkChocolateIngot);
blacklist.addIngredientToBlacklist(CommonsModule.milkChocolateNugget);
blacklist.addIngredientToBlacklist(CommonsModule.cocoaButter);
if(PulseBase.isSteelworksLoaded()) {
blacklistFluid(blacklist, CommonsModule.darkChocolate);
blacklist.addIngredientToBlacklist(CommonsModule.cocoaButter);
blacklist.addIngredientToBlacklist(CommonsModule.darkChocolateIngot);
blacklist.addIngredientToBlacklist(CommonsModule.darkChocolateNugget);
}
}
}

private static void blacklistFluid(IIngredientBlacklist blacklist, Fluid fluid) {
FluidStack stack = new FluidStack(fluid, Fluid.BUCKET_VOLUME);
blacklist.addIngredientToBlacklist(stack);
blacklist.addIngredientToBlacklist(FluidUtil.getFilledBucket(stack));
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,16 @@ public void preInit() {
@SubscribeEvent
public void registerModels(ModelRegistryEvent event) {
CommonsModule.materials.registerItemModels();
if(CommonsModule.edibles != null) {
CommonsModule.edibles.registerItemModels();
}
registerItemModelDynamic(CommonsModule.cast);
registerItemModelDynamic(CommonsModule.castClay);

// fluids
registerFluidModels(CommonsModule.chocolateLiquor);
registerFluidModels(CommonsModule.milkChocolate);
registerFluidModels(CommonsModule.darkChocolate);
}

@SubscribeEvent
Expand Down
108 changes: 97 additions & 11 deletions src/main/java/knightminer/tcomplement/shared/CommonsModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,32 @@
import knightminer.tcomplement.common.Config;
import knightminer.tcomplement.common.PulseBase;
import knightminer.tcomplement.library.TCompRegistry;
import net.minecraft.block.Block;
import net.minecraft.init.Items;
import net.minecraft.init.MobEffects;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect;
import net.minecraftforge.event.RegistryEvent.Register;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.registries.IForgeRegistry;
import slimeknights.mantle.item.ItemEdible;
import slimeknights.mantle.item.ItemMetaDynamic;
import slimeknights.mantle.pulsar.pulse.Pulse;
import slimeknights.mantle.util.RecipeMatch;
import slimeknights.tconstruct.library.TinkerRegistry;
import slimeknights.tconstruct.library.fluid.FluidColored;
import slimeknights.tconstruct.library.materials.Material;
import slimeknights.tconstruct.library.smeltery.CastingRecipe;
import slimeknights.tconstruct.library.smeltery.MeltingRecipe;
import slimeknights.tconstruct.shared.TinkerFluids;
import slimeknights.tconstruct.smeltery.TinkerSmeltery;
import slimeknights.tconstruct.smeltery.item.CastCustom;
Expand All @@ -34,17 +43,41 @@ public class CommonsModule extends PulseBase {
public static CommonProxy proxy;

public static ItemMetaDynamic materials;
public static ItemEdible edibles;

public static CastCustom cast, castClay;
public static ItemStack stoneBucket;
public static ItemStack castBucket, castBucketClay;
public static ItemStack scorchedBrick, steelIngot, steelNugget;

public static ItemStack iModifier;
public static ItemStack milkChocolateIngot, milkChocolateNugget, darkChocolateIngot, darkChocolateNugget, cocoaButter;

public static Fluid chocolateLiquor, milkChocolate, darkChocolate;

@Subscribe
public void preInit(FMLPreInitializationEvent event) {
proxy.preInit();

if(Config.general.chocolate && isSmelteryLoaded()) {
chocolateLiquor = registerFluid(new Fluid("chocolate_liquor", FluidColored.ICON_StoneStill, FluidColored.ICON_StoneFlowing, 0xFF41220D).setTemperature(500));
milkChocolate = registerFluid(new Fluid("milk_chocolate", FluidColored.ICON_StoneStill, FluidColored.ICON_StoneFlowing, 0xFF724428).setTemperature(400));
if(isSteelworksLoaded()) {
darkChocolate = registerFluid(new Fluid("dark_chocolate", FluidColored.ICON_StoneStill, FluidColored.ICON_StoneFlowing, 0xFF1E0A00).setTemperature(450));
}
}
}

@SubscribeEvent
public void registerBlocks(Register<Block> event) {
IForgeRegistry<Block> r = event.getRegistry();
if(Config.general.chocolate && isSmelteryLoaded()) {
registerFluidBlock(r, chocolateLiquor);
registerFluidBlock(r, milkChocolate);
if(isSteelworksLoaded()) {
registerFluidBlock(r, darkChocolate);
}
}
}

@SubscribeEvent
Expand All @@ -68,6 +101,25 @@ public void registerItems(Register<Item> event) {
castBucket = cast.addMeta(0, "bucket", Material.VALUE_Ingot);
castBucketClay = castClay.addMeta(0, "bucket", Material.VALUE_Ingot);
}

if(Config.general.chocolate) {
edibles = registerItem(r, new ItemEdible(), "edibles");
edibles.setCreativeTab(TCompRegistry.tabGeneral);

milkChocolateIngot = edibles.addFood(10, 3, 0.3f, "milk_chocolate_ingot");
milkChocolateNugget = edibles.addFood(20, 1, 0.05f, "milk_chocolate_nugget");
cocoaButter = edibles.addFood(30, 2, 0.2f, "cocoa_butter", new PotionEffect(MobEffects.HUNGER, 20 * 10));
if(isSteelworksLoaded()) {
darkChocolateIngot = edibles.addFood(11, 4, 0.4f, "dark_chocolate_ingot");
darkChocolateNugget = edibles.addFood(21, 1, 0.1f, "dark_chocolate_nugget");
}

FluidRegistry.addBucketForFluid(chocolateLiquor);
FluidRegistry.addBucketForFluid(milkChocolate);
if(isSteelworksLoaded()) {
FluidRegistry.addBucketForFluid(darkChocolate);
}
}
}

if(isSteelworksLoaded()) {
Expand Down Expand Up @@ -95,19 +147,53 @@ public void postInit(FMLPostInitializationEvent event) {
}

private void registerMeltingCasting() {
if (Config.general.bucketCast && isSmelteryLoaded()) {
// cast iron buckets, because it sounds cool and opens an option for bucket gating with Ceramics
TinkerRegistry.registerTableCasting(new ItemStack(Items.BUCKET), castBucket, TinkerFluids.iron, Material.VALUE_Ingot * 3);
// add cast recipes for bucket cast
for(FluidStack fs : TinkerSmeltery.castCreationFluids) {
TinkerRegistry.registerTableCasting(new CastingRecipe(castBucket, new RecipeMatch.Item(stoneBucket, 1), fs, true, true));
if(isSmelteryLoaded()) {
if(Config.general.bucketCast) {
// cast iron buckets, because it sounds cool and opens an option for bucket gating with Ceramics
TinkerRegistry.registerTableCasting(new ItemStack(Items.BUCKET), castBucket, TinkerFluids.iron, Material.VALUE_Ingot * 3);
// add cast recipes for bucket cast
for(FluidStack fs : TinkerSmeltery.castCreationFluids) {
TinkerRegistry.registerTableCasting(new CastingRecipe(castBucket, new RecipeMatch.Item(stoneBucket, 1), fs, true, true));
}

// use clay cast to make iron buckets, so you don't need gold
TinkerRegistry.registerTableCasting(new CastingRecipe(new ItemStack(Items.BUCKET), RecipeMatch.of(castBucketClay), TinkerFluids.iron, Material.VALUE_Ingot * 3, true, false));
// add cast recipes for bucket cast
for(FluidStack fs : TinkerSmeltery.clayCreationFluids) {
TinkerRegistry.registerTableCasting(new CastingRecipe(castBucketClay, new RecipeMatch.Item(stoneBucket, 1), fs, true, true));
}
}

// use clay cast to make iron buckets, so you don't need gold
TinkerRegistry.registerTableCasting(new CastingRecipe(new ItemStack(Items.BUCKET), RecipeMatch.of(castBucketClay), TinkerFluids.iron, Material.VALUE_Ingot * 3, true, false));
// add cast recipes for bucket cast
for(FluidStack fs : TinkerSmeltery.clayCreationFluids) {
TinkerRegistry.registerTableCasting(new CastingRecipe(castBucketClay, new RecipeMatch.Item(stoneBucket, 1), fs, true, true));
// chocolate
if(Config.general.chocolate) {
// cast chocolate and melt it back
TinkerRegistry.registerTableCasting(new CastingRecipe(milkChocolateIngot.copy(), RecipeMatch.of(TinkerSmeltery.castIngot), milkChocolate, Material.VALUE_Ingot, 60));
TinkerRegistry.registerTableCasting(new CastingRecipe(milkChocolateNugget.copy(), RecipeMatch.of(TinkerSmeltery.castNugget), milkChocolate, Material.VALUE_Nugget, 20));
TinkerRegistry.registerMelting(milkChocolateIngot, milkChocolate, Material.VALUE_Ingot);
TinkerRegistry.registerMelting(milkChocolateNugget, milkChocolate, Material.VALUE_Nugget);
if(isSteelworksLoaded()) {
TinkerRegistry.registerTableCasting(new CastingRecipe(darkChocolateIngot.copy(), RecipeMatch.of(TinkerSmeltery.castIngot), darkChocolate, Material.VALUE_Ingot, 80));
TinkerRegistry.registerTableCasting(new CastingRecipe(darkChocolateNugget.copy(), RecipeMatch.of(TinkerSmeltery.castNugget), darkChocolate, Material.VALUE_Nugget, 30));
TinkerRegistry.registerMelting(darkChocolateIngot, darkChocolate, Material.VALUE_Ingot);
TinkerRegistry.registerMelting(darkChocolateNugget, darkChocolate, Material.VALUE_Nugget);
}
// cocoa butter for making dark chocolate
TinkerRegistry.registerTableCasting(new CastingRecipe(cocoaButter.copy(), RecipeMatch.of(TinkerSmeltery.castIngot), chocolateLiquor, Material.VALUE_Ingot, 80));

// make chocolate liquor
ItemStack cocoaBeans = new ItemStack(Items.DYE, 1, EnumDyeColor.BROWN.getDyeDamage());
TinkerRegistry.registerMelting(cocoaBeans, chocolateLiquor, Material.VALUE_Ore() / 3);
if(isMelterLoaded()) {
TCompRegistry.registerMelterOverride(new MeltingRecipe(RecipeMatch.of(cocoaBeans, (int)(Material.VALUE_Ingot * Config.melter.oreToIngotRatio / 3)), chocolateLiquor));
}
if(isMelterLoaded()) {
TCompRegistry.registerHighOvenOverride(new MeltingRecipe(RecipeMatch.of(cocoaBeans, (int)(Material.VALUE_Ingot * Config.highOven.oreToIngotRatio / 3)), chocolateLiquor));
}

// milk chocolate
TinkerRegistry.registerAlloy(new FluidStack(milkChocolate, Material.VALUE_Nugget), new FluidStack(chocolateLiquor, Material.VALUE_Nugget / 2), new FluidStack(TinkerFluids.milk, 20));

// dark chocolate recipe handled in steelworks module
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
package knightminer.tcomplement.steelworks;

import java.util.Set;

import org.apache.commons.lang3.tuple.Pair;

import com.google.common.collect.ImmutableSet;
import com.google.common.eventbus.Subscribe;

import knightminer.tcomplement.common.CommonProxy;
import knightminer.tcomplement.common.Config;
import knightminer.tcomplement.common.ModIds;
Expand Down Expand Up @@ -44,6 +39,7 @@
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.registries.IForgeRegistry;
import org.apache.commons.lang3.tuple.Pair;
import slimeknights.mantle.item.ItemBlockMeta;
import slimeknights.mantle.pulsar.pulse.Pulse;
import slimeknights.mantle.util.RecipeMatch;
Expand All @@ -63,6 +59,8 @@
import slimeknights.tconstruct.smeltery.block.BlockSearedSlab2;
import slimeknights.tconstruct.smeltery.item.ItemChannel;

import java.util.Set;

@Pulse(
id = SteelworksModule.pulseID,
description = "Adds the high oven: a new multiblock for making steel",
Expand Down Expand Up @@ -230,46 +228,52 @@ private void registerMixes() {
TCompRegistry.registerHeatRecipe(new FluidStack(FluidRegistry.WATER, Config.highOven.steamRate), new FluidStack(steam, Config.highOven.steamRate), 1300);
}

IMixRecipe mix; // because Eclipse formatter is dumb

// steel
mix = TCompRegistry.registerMix(
new FluidStack(TinkerFluids.iron, (int)(Material.VALUE_Ingot*Config.highOven.oreToIngotRatio)),
new FluidStack(TinkerFluids.steel, (int)(Material.VALUE_Ingot*Config.highOven.oreToIngotRatio)))
// oxidizers
.addOxidizer("gunpowder", 33)
.addOxidizer("dustSulfur", 29)
.addOxidizer("dustSulphur", 29)
.addOxidizer("dustSaltpeter", 30)
// reducers
.addReducer("dustRedstone", 65)
.addReducer("dustManganese", 47)
.addReducer("dustAluminum", 60)
.addReducer("dustAluminium", 60)
// purifiers
.addPurifier("sand", 100);
int amount = (int)(Material.VALUE_Ingot * Config.highOven.oreToIngotRatio);
TCompRegistry.registerMix(
new FluidStack(TinkerFluids.iron, amount),
new FluidStack(TinkerFluids.steel, amount))
// oxidizers
.addOxidizer("gunpowder", 33)
.addOxidizer("dustSulfur", 29)
.addOxidizer("dustSulphur", 29)
.addOxidizer("dustSaltpeter", 30)
// reducers
.addReducer("dustRedstone", 65)
.addReducer("dustManganese", 47)
.addReducer("dustAluminum", 60)
.addReducer("dustAluminium", 60)
// purifiers
.addPurifier("sand", 100);

// pig iron
mix = TCompRegistry.registerMix(
IMixRecipe mix = TCompRegistry.registerMix(
new FluidStack(TinkerFluids.iron, Material.VALUE_Ingot),
new FluidStack(TinkerFluids.pigIron, Material.VALUE_Ingot))
// additives
.addOxidizer(new ItemStack(Items.SUGAR), 60)
.addReducer(new ItemStack(Items.DYE, 1, EnumDyeColor.WHITE.getDyeDamage()), 20)
.addPurifier(new ItemStack(Items.PORKCHOP), 80);

// additives
.addOxidizer(new ItemStack(Items.SUGAR), 60)
.addReducer(new ItemStack(Items.DYE, 1, EnumDyeColor.WHITE.getDyeDamage()), 20)
.addPurifier(new ItemStack(Items.PORKCHOP), 80);
ItemStack bacon = GameRegistry.makeItemStack(ModIds.TConstruct.edibles, ModIds.TConstruct.baconMeta, 1, null);
if(!bacon.isEmpty()) {
mix.addPurifier(bacon, 70);
}

// knightslime
mix = TCompRegistry.registerMix(
TCompRegistry.registerMix(
new FluidStack(TinkerFluids.iron, Material.VALUE_Ingot/2),
new FluidStack(TinkerFluids.knightslime, Material.VALUE_Ingot/2))
// additives, no oxidizer for this recipe
.addReducer("slimeballPurple", 75)
.addPurifier("gravel", 80);
// additives, no oxidizer for this recipe
.addReducer("slimeballPurple", 75)
.addPurifier("gravel", 80);

// dark chocolate
if(Config.general.chocolate) {
amount = (int)(Material.VALUE_Ingot * Config.highOven.oreToIngotRatio / 3);
TCompRegistry.registerMix(new FluidStack(CommonsModule.chocolateLiquor, amount), new FluidStack(CommonsModule.darkChocolate, amount))
.addOxidizer(new ItemStack(Items.SUGAR), 40)
.addReducer(CommonsModule.cocoaButter.copy(), 60);
}
}

private void registerFuels() {
Expand Down
14 changes: 14 additions & 0 deletions src/main/resources/assets/tcomplement/blockstates/edibles.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"forge_marker": 1,
"defaults": {
"transform": "forge:default-item",
"model": "forge:item-layer"
},
"variants": {
"milk_chocolate_ingot": [{ "textures": { "layer0": "tcomplement:items/materials/milk_chocolate_ingot" }}],
"milk_chocolate_nugget": [{ "textures": { "layer0": "tcomplement:items/materials/milk_chocolate_nugget" }}],
"dark_chocolate_ingot": [{ "textures": { "layer0": "tcomplement:items/materials/dark_chocolate_ingot" }}],
"dark_chocolate_nugget": [{ "textures": { "layer0": "tcomplement:items/materials/dark_chocolate_nugget" }}],
"cocoa_butter": [{ "textures": { "layer0": "tcomplement:items/materials/cocoa_butter" }}]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
"model": "forge:fluid"
},
"variants": {
"steam": [{
"custom": { "fluid": "steam" }
}]
"steam": [{"custom": { "fluid": "steam" }}],
"chocolate_liquor": [{"custom": { "fluid": "chocolate_liquor" }}],
"milk_chocolate": [{"custom": { "fluid": "milk_chocolate" }}],
"dark_chocolate": [{"custom": { "fluid": "dark_chocolate" }}]
}
}
Loading

0 comments on commit f1f9221

Please sign in to comment.