Skip to content

Commit

Permalink
Fix #132 : Json file with food config doesn't take effect, Fix #136 :…
Browse files Browse the repository at this point in the history
… Crash with Tinkers Construct.
  • Loading branch information
alexbegt committed Mar 19, 2017
1 parent a512de6 commit cfcb2ab
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 56 deletions.
14 changes: 8 additions & 6 deletions src/main/java/iguanaman/hungeroverhaul/module/json/Food.java
Expand Up @@ -15,7 +15,7 @@
public class Food
{
//Registry Name
public ResourceLocation name;
public String name;

public String oreName;

Expand All @@ -36,19 +36,21 @@ public boolean hasOredictEntry()
@SuppressWarnings("deprecation")
public ItemStack toItemStack()
{
Item item = GameData.getItemRegistry().getObject(this.name);
ResourceLocation loc = new ResourceLocation(this.name);

Item item = GameData.getItemRegistry().getObject(loc);

if (item == null)
{
Block block = GameData.getBlockRegistry().getObject(this.name);
Block block = GameData.getBlockRegistry().getObject(loc);

if (block != null)
{
item = Item.getItemFromBlock(block);
}
}

return item == null ? null : new ItemStack(GameData.getItemRegistry().getObject(this.name), this.count, this.meta);
return item == null ? null : new ItemStack(GameData.getItemRegistry().getObject(loc), this.count, this.meta);
}

public FoodValues toFoodValues()
Expand All @@ -66,11 +68,11 @@ public static Food fromItemStack(ItemStack is, Float saturationModifier, int hun
{
Food fd = new Food();

fd.name = GameData.getItemRegistry().getNameForObject(is.getItem());
fd.name = GameData.getItemRegistry().getNameForObject(is.getItem()).toString();

if (fd.name == null || fd.name.toString().isEmpty())
{
fd.name = GameData.getBlockRegistry().getNameForObject(Block.getBlockFromItem(is.getItem()));
fd.name = GameData.getBlockRegistry().getNameForObject(Block.getBlockFromItem(is.getItem())).toString();
}

if (fd.name == null || fd.name.toString().isEmpty())
Expand Down
Expand Up @@ -5,6 +5,8 @@
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.fml.common.event.FMLInterModComms;
import slimeknights.tconstruct.TConstruct;
import slimeknights.tconstruct.gadgets.TinkerGadgets;
import slimeknights.tconstruct.shared.TinkerCommons;

public class TinkersConstructModule
Expand All @@ -15,65 +17,68 @@ public static void init()
{
int dryingTime = 20 * 60 * 20; //in minutes

NBTTagCompound rottonFleshTag = new NBTTagCompound();
rottonFleshTag.setTag("input", new ItemStack(Items.ROTTEN_FLESH).writeToNBT(new NBTTagCompound()));
rottonFleshTag.setTag("output", TinkerCommons.jerkyMonster.writeToNBT(new NBTTagCompound()));
rottonFleshTag.setInteger("time", dryingTime);
FMLInterModComms.sendMessage("tconstruct", "addDryingRecipe", rottonFleshTag);
if (TConstruct.pulseManager.isPulseLoaded(TinkerGadgets.PulseId))
{
NBTTagCompound rottonFleshTag = new NBTTagCompound();
rottonFleshTag.setTag("input", new ItemStack(Items.ROTTEN_FLESH).writeToNBT(new NBTTagCompound()));
rottonFleshTag.setTag("output", TinkerCommons.jerkyMonster.writeToNBT(new NBTTagCompound()));
rottonFleshTag.setInteger("time", dryingTime);
FMLInterModComms.sendMessage("tconstruct", "addDryingRecipe", rottonFleshTag);

NBTTagCompound beefTag = new NBTTagCompound();
beefTag.setTag("input", new ItemStack(Items.BEEF).writeToNBT(new NBTTagCompound()));
beefTag.setTag("output", TinkerCommons.jerkyBeef.writeToNBT(new NBTTagCompound()));
beefTag.setInteger("time", dryingTime);
FMLInterModComms.sendMessage("tconstruct", "addDryingRecipe", beefTag);
NBTTagCompound beefTag = new NBTTagCompound();
beefTag.setTag("input", new ItemStack(Items.BEEF).writeToNBT(new NBTTagCompound()));
beefTag.setTag("output", TinkerCommons.jerkyBeef.writeToNBT(new NBTTagCompound()));
beefTag.setInteger("time", dryingTime);
FMLInterModComms.sendMessage("tconstruct", "addDryingRecipe", beefTag);

NBTTagCompound chickenTag = new NBTTagCompound();
chickenTag.setTag("input", new ItemStack(Items.CHICKEN).writeToNBT(new NBTTagCompound()));
chickenTag.setTag("output", TinkerCommons.jerkyChicken.writeToNBT(new NBTTagCompound()));
chickenTag.setInteger("time", dryingTime);
FMLInterModComms.sendMessage("tconstruct", "addDryingRecipe", chickenTag);
NBTTagCompound chickenTag = new NBTTagCompound();
chickenTag.setTag("input", new ItemStack(Items.CHICKEN).writeToNBT(new NBTTagCompound()));
chickenTag.setTag("output", TinkerCommons.jerkyChicken.writeToNBT(new NBTTagCompound()));
chickenTag.setInteger("time", dryingTime);
FMLInterModComms.sendMessage("tconstruct", "addDryingRecipe", chickenTag);

NBTTagCompound porkchopTag = new NBTTagCompound();
porkchopTag.setTag("input", new ItemStack(Items.PORKCHOP).writeToNBT(new NBTTagCompound()));
porkchopTag.setTag("output", TinkerCommons.jerkyPork.writeToNBT(new NBTTagCompound()));
porkchopTag.setInteger("time", dryingTime);
FMLInterModComms.sendMessage("tconstruct", "addDryingRecipe", porkchopTag);
NBTTagCompound porkchopTag = new NBTTagCompound();
porkchopTag.setTag("input", new ItemStack(Items.PORKCHOP).writeToNBT(new NBTTagCompound()));
porkchopTag.setTag("output", TinkerCommons.jerkyPork.writeToNBT(new NBTTagCompound()));
porkchopTag.setInteger("time", dryingTime);
FMLInterModComms.sendMessage("tconstruct", "addDryingRecipe", porkchopTag);

NBTTagCompound muttonTag = new NBTTagCompound();
muttonTag.setTag("input", new ItemStack(Items.MUTTON).writeToNBT(new NBTTagCompound()));
muttonTag.setTag("output", TinkerCommons.jerkyMutton.writeToNBT(new NBTTagCompound()));
muttonTag.setInteger("time", dryingTime);
FMLInterModComms.sendMessage("tconstruct", "addDryingRecipe", muttonTag);
NBTTagCompound muttonTag = new NBTTagCompound();
muttonTag.setTag("input", new ItemStack(Items.MUTTON).writeToNBT(new NBTTagCompound()));
muttonTag.setTag("output", TinkerCommons.jerkyMutton.writeToNBT(new NBTTagCompound()));
muttonTag.setInteger("time", dryingTime);
FMLInterModComms.sendMessage("tconstruct", "addDryingRecipe", muttonTag);

NBTTagCompound rabbitTag = new NBTTagCompound();
rabbitTag.setTag("input", new ItemStack(Items.RABBIT).writeToNBT(new NBTTagCompound()));
rabbitTag.setTag("output", TinkerCommons.jerkyRabbit.writeToNBT(new NBTTagCompound()));
rabbitTag.setInteger("time", dryingTime);
FMLInterModComms.sendMessage("tconstruct", "addDryingRecipe", rabbitTag);
NBTTagCompound rabbitTag = new NBTTagCompound();
rabbitTag.setTag("input", new ItemStack(Items.RABBIT).writeToNBT(new NBTTagCompound()));
rabbitTag.setTag("output", TinkerCommons.jerkyRabbit.writeToNBT(new NBTTagCompound()));
rabbitTag.setInteger("time", dryingTime);
FMLInterModComms.sendMessage("tconstruct", "addDryingRecipe", rabbitTag);

NBTTagCompound fishTag = new NBTTagCompound();
fishTag.setTag("input", new ItemStack(Items.FISH, 1, 0).writeToNBT(new NBTTagCompound()));
fishTag.setTag("output", TinkerCommons.jerkyFish.writeToNBT(new NBTTagCompound()));
fishTag.setInteger("time", dryingTime);
FMLInterModComms.sendMessage("tconstruct", "addDryingRecipe", fishTag);
NBTTagCompound fishTag = new NBTTagCompound();
fishTag.setTag("input", new ItemStack(Items.FISH, 1, 0).writeToNBT(new NBTTagCompound()));
fishTag.setTag("output", TinkerCommons.jerkyFish.writeToNBT(new NBTTagCompound()));
fishTag.setInteger("time", dryingTime);
FMLInterModComms.sendMessage("tconstruct", "addDryingRecipe", fishTag);

NBTTagCompound salmonTag = new NBTTagCompound();
salmonTag.setTag("input", new ItemStack(Items.FISH, 1, 1).writeToNBT(new NBTTagCompound()));
salmonTag.setTag("output", TinkerCommons.jerkySalmon.writeToNBT(new NBTTagCompound()));
salmonTag.setInteger("time", dryingTime);
FMLInterModComms.sendMessage("tconstruct", "addDryingRecipe", salmonTag);
NBTTagCompound salmonTag = new NBTTagCompound();
salmonTag.setTag("input", new ItemStack(Items.FISH, 1, 1).writeToNBT(new NBTTagCompound()));
salmonTag.setTag("output", TinkerCommons.jerkySalmon.writeToNBT(new NBTTagCompound()));
salmonTag.setInteger("time", dryingTime);
FMLInterModComms.sendMessage("tconstruct", "addDryingRecipe", salmonTag);

NBTTagCompound clownfishTag = new NBTTagCompound();
clownfishTag.setTag("input", new ItemStack(Items.FISH, 1, 1).writeToNBT(new NBTTagCompound()));
clownfishTag.setTag("output", TinkerCommons.jerkyClownfish.writeToNBT(new NBTTagCompound()));
clownfishTag.setInteger("time", dryingTime);
FMLInterModComms.sendMessage("tconstruct", "addDryingRecipe", clownfishTag);
NBTTagCompound clownfishTag = new NBTTagCompound();
clownfishTag.setTag("input", new ItemStack(Items.FISH, 1, 1).writeToNBT(new NBTTagCompound()));
clownfishTag.setTag("output", TinkerCommons.jerkyClownfish.writeToNBT(new NBTTagCompound()));
clownfishTag.setInteger("time", dryingTime);
FMLInterModComms.sendMessage("tconstruct", "addDryingRecipe", clownfishTag);

NBTTagCompound pufferTag = new NBTTagCompound();
pufferTag.setTag("input", new ItemStack(Items.FISH, 1, 1).writeToNBT(new NBTTagCompound()));
pufferTag.setTag("output", TinkerCommons.jerkyClownfish.writeToNBT(new NBTTagCompound()));
pufferTag.setInteger("time", dryingTime);
FMLInterModComms.sendMessage("tconstruct", "addDryingRecipe", pufferTag);
NBTTagCompound pufferTag = new NBTTagCompound();
pufferTag.setTag("input", new ItemStack(Items.FISH, 1, 1).writeToNBT(new NBTTagCompound()));
pufferTag.setTag("output", TinkerCommons.jerkyClownfish.writeToNBT(new NBTTagCompound()));
pufferTag.setInteger("time", dryingTime);
FMLInterModComms.sendMessage("tconstruct", "addDryingRecipe", pufferTag);
}
}
}
}

0 comments on commit cfcb2ab

Please sign in to comment.