Skip to content

Commit

Permalink
Add raw clay, glass, and emeralds to the list of materials used for t…
Browse files Browse the repository at this point in the history
…he crafting registry scan
  • Loading branch information
KnightMiner committed Jun 11, 2019
1 parent 1922710 commit 486e778
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 16 deletions.
10 changes: 6 additions & 4 deletions src/main/java/slimeknights/tconstruct/common/TinkerOredict.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package slimeknights.tconstruct.common;

import com.google.common.collect.ImmutableSet;

import net.minecraft.block.Block;
import net.minecraft.block.BlockStoneBrick;
import net.minecraft.init.Blocks;
Expand All @@ -11,13 +10,12 @@
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.oredict.OreDictionary;

import java.util.Set;

import slimeknights.mantle.pulsar.pulse.Pulse;
import slimeknights.tconstruct.smeltery.TinkerSmeltery;
import slimeknights.tconstruct.tools.common.block.BlockToolTable;

import java.util.Set;

import static slimeknights.tconstruct.gadgets.TinkerGadgets.stoneStick;
import static slimeknights.tconstruct.gadgets.TinkerGadgets.stoneTorch;
import static slimeknights.tconstruct.shared.TinkerCommons.blockAlubrass;
Expand Down Expand Up @@ -140,6 +138,10 @@ private static void ensureOredict() {

oredict(Blocks.TRAPDOOR, "trapdoorWood");

// clay melting
oredict(Items.CLAY_BALL, "clay");
oredict(Blocks.CLAY, "blockClay");

// vanilla cooked meat
// compatibility with pams harvestcraft
for(Item meat : COOKED_MEAT) {
Expand Down
55 changes: 43 additions & 12 deletions src/main/java/slimeknights/tconstruct/smeltery/TinkerSmeltery.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.google.common.collect.Maps;
import com.google.common.eventbus.Subscribe;
import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.monster.EntityEvoker;
import net.minecraft.entity.monster.EntityIllusionIllager;
import net.minecraft.entity.monster.EntityIronGolem;
Expand Down Expand Up @@ -345,6 +346,8 @@ private void registerSmelteryFuel() {
}

private void registerMeltingCasting() {
// used in several places to register fluids for the crafting recipe scan
ImmutableSet.Builder<Pair<String, Integer>> builder;
int bucket = Fluid.BUCKET_VOLUME;

// bucket casting
Expand Down Expand Up @@ -383,7 +386,6 @@ private void registerMeltingCasting() {
registerToolpartMeltingCasting(TinkerMaterials.obsidian);
TinkerRegistry.registerBasinCasting(new ItemStack(Blocks.OBSIDIAN), ItemStack.EMPTY, TinkerFluids.obsidian, Material.VALUE_Ore());

// gold is melt and castable too, but no tools. Remaining materials are done directly in the MaterialIntegration
// gold is integrated via MaterialIntegration in TinkerIntegration now

// special melting
Expand Down Expand Up @@ -442,8 +444,11 @@ private void registerMeltingCasting() {
TinkerRegistry.registerMelting(TinkerCommons.mudBrickBlock, TinkerFluids.dirt, Material.VALUE_BrickBlock);

// hardened clay
TinkerRegistry.registerMelting(Items.CLAY_BALL, TinkerFluids.clay, Material.VALUE_Ingot);
TinkerRegistry.registerMelting(Blocks.CLAY, TinkerFluids.clay, Material.VALUE_BrickBlock);
builder = ImmutableSet.builder();
builder.add(Pair.of("clay", Material.VALUE_Ingot));
builder.add(Pair.of("blockClay", Material.VALUE_BrickBlock));
addKnownOreFluid(TinkerFluids.clay, builder.build());

// decided against support for melting hardened clay. Once it's hardened, it stays hard. Same for bricks.
//TinkerRegistry.registerMelting(Blocks.hardened_clay, TinkerFluids.clay, Material.VALUE_BrickBlock);
//TinkerRegistry.registerMelting(Blocks.stained_hardened_clay, TinkerFluids.clay, Material.VALUE_BrickBlock);
Expand All @@ -462,16 +467,22 @@ private void registerMeltingCasting() {
}

// emerald melting and casting
TinkerRegistry.registerMelting(new MeltingRecipe(RecipeMatch.of("gemEmerald", Material.VALUE_Gem), TinkerFluids.emerald));
TinkerRegistry.registerMelting(new MeltingRecipe(RecipeMatch.of("oreEmerald", (int) (Material.VALUE_Gem * Config.oreToIngotRatio)), TinkerFluids.emerald));
TinkerRegistry.registerMelting(new MeltingRecipe(RecipeMatch.of("blockEmerald", Material.VALUE_Gem * 9), TinkerFluids.emerald));
builder = ImmutableSet.builder();
builder.add(Pair.of("gemEmerald", Material.VALUE_Gem));
builder.add(Pair.of("blockEmerald", Material.VALUE_Gem * 9));
addKnownOreFluid(TinkerFluids.emerald, builder.build());

TinkerRegistry.registerTableCasting(new ItemStack(Items.EMERALD), castGem, TinkerFluids.emerald, Material.VALUE_Gem);
TinkerRegistry.registerBasinCasting(new ItemStack(Blocks.EMERALD_BLOCK), ItemStack.EMPTY, TinkerFluids.emerald, Material.VALUE_Gem * 9);

// glass melting and casting
TinkerRegistry.registerMelting(new MeltingRecipe(RecipeMatch.of("sand", Material.VALUE_Glass), TinkerFluids.glass));
TinkerRegistry.registerMelting(new MeltingRecipe(RecipeMatch.of("blockGlass", Material.VALUE_Glass), TinkerFluids.glass));
TinkerRegistry.registerMelting(new MeltingRecipe(RecipeMatch.of("paneGlass", Material.VALUE_Glass * 6 / 16), TinkerFluids.glass));
builder = ImmutableSet.builder();
builder.add(Pair.of("blockGlass", Material.VALUE_Glass));
builder.add(Pair.of("paneGlass", Material.VALUE_Glass * 6 / 16));
addKnownOreFluid(TinkerFluids.glass, builder.build());

TinkerRegistry.registerTableCasting(new CastingRecipe(new ItemStack(Blocks.GLASS_PANE), null, TinkerFluids.glass, Material.VALUE_Glass * 6 / 16, 50));
TinkerRegistry.registerBasinCasting(new CastingRecipe(new ItemStack(TinkerCommons.blockClearGlass), null, TinkerFluids.glass, Material.VALUE_Glass, 120));

Expand Down Expand Up @@ -674,9 +685,7 @@ public static void registerOredictMeltingCasting(Fluid fluid, String ore) {
Set<Pair<String, Integer>> knownOres = builder.build();

// register oredicts
for(Pair<String, Integer> pair : knownOres) {
TinkerRegistry.registerMelting(new MeltingRecipe(RecipeMatch.of(pair.getLeft(), pair.getRight()), fluid));
}
addKnownOreFluid(fluid, knownOres);

// register oredict castings!
// ingot casting
Expand Down Expand Up @@ -712,8 +721,18 @@ public static void registerOredictMeltingCasting(Fluid fluid, String ore) {
TinkerRegistry.registerTableCasting(new CastingRecipe(castPlate, RecipeMatch.of(plateOre.getLeft()), fs, true, true));
TinkerRegistry.registerTableCasting(new CastingRecipe(castGear, RecipeMatch.of(gearOre.getLeft()), fs, true, true));
}
}

/**
* Adds a fluid to the knownOreFluids list, adding recipes for each combination
* @param fluid Fluid recipes belong to
* @param knownOres Set of pairs of an oredict name to a integer fluid amount
*/
private static void addKnownOreFluid(Fluid fluid, Set<Pair<String, Integer>> knownOres) {
for(Pair<String, Integer> pair : knownOres) {
TinkerRegistry.registerMelting(new MeltingRecipe(RecipeMatch.of(pair.getLeft(), pair.getRight()), fluid));
}

// used for recipe detection
knownOreFluids.put(fluid, knownOres);
}

Expand Down Expand Up @@ -816,7 +835,7 @@ public static void registerRecipeOredictMelting() {
// OR if it's an itemstack contained in one of our oredicts
for(Pair<String, Integer> pair : entry.getValue()) {
for(ItemStack itemStack : OreDictionary.getOres(pair.getLeft(), false)) {
if(ingredient.apply(itemStack)) {
if(ingredientMatches(ingredient, itemStack)) {
// matches! Update fluid amount known
Integer amount = known.get(entry.getKey()); // what we found for the liquid so far
if(amount == null) {
Expand Down Expand Up @@ -853,6 +872,18 @@ public static void registerRecipeOredictMelting() {
log.info("Oredict melting recipes finished in {} ms", (System.nanoTime() - start) / 1000000D);
}

/**
* Ingredients do not handle the passed in item stack having wildcard metadata, so handle using getSubItems
*/
private static boolean ingredientMatches(Ingredient ingredient, ItemStack stack) {
if (stack.getMetadata() != OreDictionary.WILDCARD_VALUE) {
return ingredient.apply(stack);
}
NonNullList<ItemStack> stacks = NonNullList.create();
stack.getItem().getSubItems(CreativeTabs.SEARCH, stacks);
return stacks.stream().anyMatch(ingredient::apply);
}

protected static <E extends Enum<E> & EnumBlock.IEnumMeta & IStringSerializable> BlockSearedStairs registerBlockSearedStairsFrom(IForgeRegistry<Block> registry, EnumBlock<E> block, E value, String name) {
return registerBlock(registry, new BlockSearedStairs(block.getDefaultState().withProperty(block.prop, value)), name);
}
Expand Down

0 comments on commit 486e778

Please sign in to comment.