Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Add tag support for hammer
- Loading branch information
1 parent
f2b534c
commit 5a8964d
Showing
2 changed files
with
31 additions
and
18 deletions.
There are no files selected for viewing
47 changes: 30 additions & 17 deletions
47
src/main/java/com/novamachina/exnihilosequentia/common/item/tools/hammer/HammerDrops.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,47 @@ | ||
package com.novamachina.exnihilosequentia.common.item.tools.hammer; | ||
|
||
import com.novamachina.exnihilosequentia.common.setup.ModBlocks; | ||
|
||
import java.util.Collection; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import net.minecraft.block.Block; | ||
import net.minecraft.block.Blocks; | ||
import net.minecraft.util.ResourceLocation; | ||
import net.minecraftforge.registries.ForgeRegistries; | ||
|
||
public class HammerDrops { | ||
|
||
private static final Map<String, Block> hammerDrops = new HashMap<>(); | ||
private static final Map<ResourceLocation, ResourceLocation> hammerDrops = new HashMap<>(); | ||
|
||
public static void addRecipe(Block input, Block output) { | ||
addRecipe(input.getRegistryName(), output.getRegistryName()); | ||
} | ||
|
||
private static void addRecipe(ResourceLocation input, ResourceLocation output) { | ||
hammerDrops.put(input, output); | ||
} | ||
|
||
public static void initialize() { | ||
|
||
hammerDrops.put(Blocks.STONE.getRegistryName().toString(), Blocks.COBBLESTONE); | ||
hammerDrops.put(Blocks.COBBLESTONE.getRegistryName().toString(), Blocks.GRAVEL); | ||
hammerDrops.put(Blocks.GRAVEL.getRegistryName().toString(), Blocks.SAND); | ||
hammerDrops.put(Blocks.SAND.getRegistryName().toString(), ModBlocks.DUST.get()); | ||
hammerDrops.put(Blocks.ANDESITE.getRegistryName().toString(), | ||
ModBlocks.CRUSHED_ANDESITE.get()); | ||
hammerDrops.put(Blocks.DIORITE.getRegistryName().toString(), | ||
ModBlocks.CRUSHED_DIORITE.get()); | ||
hammerDrops.put(Blocks.GRANITE.getRegistryName().toString(), | ||
ModBlocks.CRUSHED_GRANITE.get()); | ||
hammerDrops.put(Blocks.END_STONE.getRegistryName().toString(), | ||
ModBlocks.CRUSHED_END_STONE.get()); | ||
hammerDrops.put(Blocks.NETHERRACK.getRegistryName().toString(), | ||
ModBlocks.CRUSHED_NETHERRACK.get()); | ||
addRecipe(Blocks.STONE, Blocks.COBBLESTONE); | ||
addRecipe(Blocks.COBBLESTONE, Blocks.GRAVEL); | ||
addRecipe(Blocks.GRAVEL, Blocks.SAND); | ||
addRecipe(Blocks.SAND, ModBlocks.DUST.get()); | ||
addRecipe(Blocks.ANDESITE, ModBlocks.CRUSHED_ANDESITE.get()); | ||
addRecipe(Blocks.DIORITE, ModBlocks.CRUSHED_DIORITE.get()); | ||
addRecipe(Blocks.GRANITE, ModBlocks.CRUSHED_GRANITE.get()); | ||
addRecipe(Blocks.END_STONE, ModBlocks.CRUSHED_END_STONE.get()); | ||
addRecipe(Blocks.NETHERRACK, ModBlocks.CRUSHED_NETHERRACK.get()); | ||
} | ||
|
||
public static Block getResult(String input) { | ||
return hammerDrops.get(input); | ||
public static Block getResult(ResourceLocation input) { | ||
if(hammerDrops.containsKey(input)) { | ||
ResourceLocation output = hammerDrops.get(input); | ||
if(ForgeRegistries.BLOCKS.containsKey(output)) { | ||
return ForgeRegistries.BLOCKS.getValue(output); | ||
} | ||
} | ||
return ForgeRegistries.BLOCKS.getValue(input); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters