mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-21 20:42:35 +00:00
Close #1212 Use OreDictionary to choose a type of Copper/Tin/Bronze
This commit is contained in:
1 parent
502160011b
commit
55c32a8280
20 files changed
+268
-159
No files matched your search
@@ -10,6 +10,9 @@
|
||||
******************************************************************************/
|
||||
package forestry.storage;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -21,51 +24,53 @@ import forestry.core.items.ItemCrated;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.ItemStackUtil;
|
||||
import forestry.core.utils.Log;
|
||||
import forestry.core.utils.OreDictUtil;
|
||||
|
||||
public class CrateRegistry implements ICrateRegistry {
|
||||
|
||||
private static void registerCrate(ItemStack stack, boolean useOreDict) {
|
||||
private static void registerCrate(@Nonnull ItemStack stack, @Nullable String oreDictName) {
|
||||
if (stack == null || stack.getItem() == null) {
|
||||
Log.warning("Tried to make a crate without an item");
|
||||
return;
|
||||
}
|
||||
|
||||
String itemName = ItemStackUtil.getStringForItemStack(stack).replace(':', '.');
|
||||
String crateName = "crated." + itemName;
|
||||
ItemCrated crate = new ItemCrated(stack, useOreDict);
|
||||
String crateName;
|
||||
if (oreDictName != null) {
|
||||
crateName = "crated." + oreDictName;
|
||||
} else {
|
||||
String itemName = ItemStackUtil.getStringForItemStack(stack).replace(':', '.');
|
||||
crateName = "crated." + itemName;
|
||||
}
|
||||
|
||||
ItemCrated crate = new ItemCrated(stack, oreDictName);
|
||||
crate.setUnlocalizedName(crateName);
|
||||
GameRegistry.registerItem(crate, crateName);
|
||||
crate.setRegistryName(crateName);
|
||||
|
||||
GameRegistry.register(crate);
|
||||
Proxies.common.registerItem(crate);
|
||||
PluginStorage.registerCrate(crate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerCrate(Item item) {
|
||||
registerCrate(new ItemStack(item), false);
|
||||
public void registerCrate(@Nonnull String oreDictName) {
|
||||
ItemStack stack = OreDictUtil.getFirstSuitableOre(oreDictName);
|
||||
if (stack != null) {
|
||||
registerCrate(stack, oreDictName);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerCrateUsingOreDict(Item item) {
|
||||
registerCrate(new ItemStack(item), true);
|
||||
public void registerCrate(@Nonnull Block block) {
|
||||
registerCrate(new ItemStack(block), null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerCrate(Block block) {
|
||||
registerCrate(new ItemStack(block), false);
|
||||
public void registerCrate(@Nonnull Item item) {
|
||||
registerCrate(new ItemStack(item), null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerCrateUsingOreDict(Block block) {
|
||||
registerCrate(new ItemStack(block), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerCrate(ItemStack stack) {
|
||||
registerCrate(stack, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerCrateUsingOreDict(ItemStack stack) {
|
||||
registerCrate(stack, true);
|
||||
public void registerCrate(@Nonnull ItemStack stack) {
|
||||
registerCrate(stack, null);
|
||||
}
|
||||
}
|
||||
@@ -386,26 +386,24 @@ public class PluginStorage extends BlankForestryPlugin {
|
||||
for (ItemCrated crate : crates) {
|
||||
ItemStack crateStack = new ItemStack(crate);
|
||||
ItemStack uncrated = crate.getContained();
|
||||
if (crate.usesOreDict()) {
|
||||
int[] oreIds = OreDictionary.getOreIDs(uncrated);
|
||||
for (int oreId : oreIds) {
|
||||
String oreName = OreDictionary.getOreName(oreId);
|
||||
addCrating(crateStack, oreName);
|
||||
if (uncrated != null) {
|
||||
if (crate.getOreDictName() != null) {
|
||||
addCrating(crateStack, crate.getOreDictName());
|
||||
} else {
|
||||
addCrating(crateStack, uncrated);
|
||||
}
|
||||
} else {
|
||||
addCrating(crateStack, uncrated);
|
||||
addUncrating(crateStack, uncrated);
|
||||
}
|
||||
addUncrating(crateStack, uncrated);
|
||||
}
|
||||
}
|
||||
|
||||
private static void addCrating(ItemStack crateStack, Object uncrated) {
|
||||
private static void addCrating(@Nonnull ItemStack crateStack, @Nonnull Object uncrated) {
|
||||
FluidStack water = Fluids.WATER.getFluid(Constants.CARPENTER_CRATING_LIQUID_QUANTITY);
|
||||
ItemStack box = items.crate.getItemStack();
|
||||
RecipeManagers.carpenterManager.addRecipe(Constants.CARPENTER_CRATING_CYCLES, water, box, crateStack, "###", "###", "###", '#', uncrated);
|
||||
}
|
||||
|
||||
private static void addUncrating(ItemStack crateStack, ItemStack uncrated) {
|
||||
private static void addUncrating(@Nonnull ItemStack crateStack, @Nonnull ItemStack uncrated) {
|
||||
ItemStack product = new ItemStack(uncrated.getItem(), 9, uncrated.getItemDamage());
|
||||
RecipeManagers.carpenterManager.addRecipe(Constants.CARPENTER_UNCRATING_CYCLES, null, product, "#", '#', crateStack);
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public class ItemRegistryStorage extends ItemRegistry {
|
||||
|
||||
public ItemRegistryStorage() {
|
||||
// CRATE
|
||||
crate = registerItem(new ItemCrated(null, false), "crate");
|
||||
crate = registerItem(new ItemCrated(null, null), "crate");
|
||||
|
||||
// BACKPACKS
|
||||
IBackpackDefinition definition;
|
||||
|
||||
Reference in new issue
Block a user