From f8b86de04c51bd0b98b6bb3840dac5b766e48580 Mon Sep 17 00:00:00 2001 From: DarkGuardsman Date: Mon, 2 Sep 2013 18:01:17 -0400 Subject: [PATCH] Worked on compost list config Allows users to add other items to the config list to be turned into compost --- src/dark/api/farm/DecayMatterList.java | 21 ++++++++++++++++++++- src/dark/farmtech/FarmTech.java | 3 +++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/dark/api/farm/DecayMatterList.java b/src/dark/api/farm/DecayMatterList.java index 55b5f5fe..62b461b0 100644 --- a/src/dark/api/farm/DecayMatterList.java +++ b/src/dark/api/farm/DecayMatterList.java @@ -20,7 +20,7 @@ public class DecayMatterList * @param stack - itemID and meta to check against * @param output - how many buckets of compost are created. Accepts part buckets * @param time - time in which to decay the matter */ - public void addDecayMatter(ItemStack stack, float output, int time) + public static void addDecayMatter(ItemStack stack, float output, int time) { if (stack != null) { @@ -71,6 +71,7 @@ public class DecayMatterList //TODO parse the list of blocks and auto add all crop blocks. } + /** Loads user settings for items that validate for decay matter */ public static void parseConfigString(String string) { if (string != null && !string.isEmpty()) @@ -85,6 +86,24 @@ public class DecayMatterList String[] split = str.split(":"); String ID = split[0]; String meta = split[1]; + String decayT = split[2]; + String decayO = split[3]; + try + { + int blockID = Integer.parseInt(ID); + int metaID = Integer.parseInt(meta); + int decayTime = Integer.parseInt(decayT); + int decayV = Integer.parseInt(decayO); + DecayMatterList.addDecayMatter(new ItemStack(blockID, 1, metaID), decayV, decayTime); + } + catch (Exception e) + { + //TODO add a string based system that will allow for full item or block names + //eg tile.stone:0, tile.wood:2, + System.out.println("[FarmTech] Entries for compost list must be Integers"); + e.printStackTrace(); + } + } catch (Exception e) { diff --git a/src/dark/farmtech/FarmTech.java b/src/dark/farmtech/FarmTech.java index dd46d5a3..593acea2 100644 --- a/src/dark/farmtech/FarmTech.java +++ b/src/dark/farmtech/FarmTech.java @@ -105,6 +105,9 @@ public class FarmTech extends ModPrefab blockFarmSoil = new BlockFarmSoil(this.getNextID()); BlockRegistry.addBlockToRegister(new BlockData(blockFarmSoil, ItemBlockHolder.class, "FTFarmSoil")); + String compostList = CONFIGURATION.get("DecayMatter", "List", "5::8000:1","Items or blocks beyond the built in ones that can be turned into compost. Entries go BlockID:Meta:Time:Amount").getString(); + DecayMatterList.parseConfigString(compostList); + CONFIGURATION.save(); return dataList; }