Skip to content
This repository has been archived by the owner on Aug 3, 2024. It is now read-only.

Commit

Permalink
Merge branch 'release/1.3.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
ScottKillen committed Apr 17, 2015
2 parents e6b5980 + 2186405 commit 515974c
Show file tree
Hide file tree
Showing 11 changed files with 126 additions and 107 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## Ancient Trees
**LATEST OFFICIAL VERSION**: [Ancient Trees 1.3.0 for MC 1.7.10][latest] ([changelog][changelog.md]) ([all
**LATEST OFFICIAL VERSION**: [Ancient Trees 1.3.1 for MC 1.7.10][latest] ([changelog][changelog.md]) ([all
releases][releases])<br />
*DEPENDS ON*: [Kore Sample 1.2.5 (or later) for MC 1.7.10][koresample]
[latest]: https://github.com/MinecraftModArchive/Dendrology/releases/latest
Expand Down
3 changes: 2 additions & 1 deletion api/ForestryAPI/forestry/api/arboriculture/ITree.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@

import forestry.api.genetics.IEffectData;
import forestry.api.genetics.IIndividual;
import forestry.api.world.ITreeGenData;

public interface ITree extends IIndividual {
public interface ITree extends IIndividual, ITreeGenData {

void mate(ITree other);

Expand Down
14 changes: 14 additions & 0 deletions api/ForestryAPI/forestry/api/arboriculture/ITreeRoot.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ public interface ITreeRoot extends ISpeciesRoot {
@Override
ITree getMember(NBTTagCompound compound);

@Override
ITree templateAsIndividual(IAllele[] template);

@Override
ITree templateAsIndividual(IAllele[] templateActive, IAllele[] templateInactive);

@Override
ITreeGenome templateAsGenome(IAllele[] template);

Expand Down Expand Up @@ -63,9 +69,17 @@ public interface ITreeRoot extends ISpeciesRoot {

boolean plantSapling(World world, ITree tree, GameProfile owner, int x, int y, int z);

/**
* @deprecated since Forestry 3.5.0. Use ITreeGenData setLeavesDecorative.
*/
@Deprecated
// decorative=true for creative and player-placed leaves. No decay, pollination, or drops.
boolean setLeaves(World world, IIndividual tree, GameProfile owner, int x, int y, int z, boolean decorative);

/**
* @deprecated since Forestry 3.5.0. Use ITreeGenData setLeaves.
*/
@Deprecated
// set normal leaves created as worldgen
boolean setLeaves(World world, IIndividual tree, GameProfile owner, int x, int y, int z);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
@API(apiVersion="2.2.1", owner="ForestryAPI|core", provides="ForestryAPI|arboriculture")
@API(apiVersion="2.3.0", owner="ForestryAPI|core", provides="ForestryAPI|arboriculture")
package forestry.api.arboriculture;
import cpw.mods.fml.common.API;
1 change: 1 addition & 0 deletions api/ForestryAPI/forestry/api/world/ITreeGenData.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public interface ITreeGenData {
boolean canGrow(World world, int x, int y, int z, int expectedGirth, int expectedHeight);

void setLeaves(World world, GameProfile owner, int x, int y, int z);
void setLeavesDecorative(World world, GameProfile owner, int x, int y, int z);

boolean allowsFruitBlocks();

Expand Down
2 changes: 1 addition & 1 deletion api/ForestryAPI/forestry/api/world/package-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
@API(apiVersion="1.0", owner="ForestryAPI|core", provides="ForestryAPI|world")
@API(apiVersion="1.1.0", owner="ForestryAPI|core", provides="ForestryAPI|world")
package forestry.api.world;
import cpw.mods.fml.common.API;
13 changes: 2 additions & 11 deletions src/main/java/com/scottkillen/mod/dendrology/TheMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,15 @@
import com.scottkillen.mod.dendrology.compat.gardencollection.GardenTreesMod;
import com.scottkillen.mod.dendrology.compat.minechem.MinechemMod;
import com.scottkillen.mod.dendrology.config.Settings;
import com.scottkillen.mod.dendrology.content.crafting.OreDictHandler;
import com.scottkillen.mod.dendrology.content.crafting.Crafter;
import com.scottkillen.mod.dendrology.content.crafting.OreDictHandler;
import com.scottkillen.mod.dendrology.content.crafting.Smelter;
import com.scottkillen.mod.dendrology.content.fuel.FuelHandler;
import com.scottkillen.mod.dendrology.content.overworld.OverworldTreeGenerator;
import com.scottkillen.mod.dendrology.content.overworld.OverworldTreeSpecies;
import com.scottkillen.mod.dendrology.proxy.Proxy;
import com.scottkillen.mod.koresample.common.util.log.Logger;
import com.scottkillen.mod.koresample.compat.Integrates;
import com.scottkillen.mod.koresample.compat.versionchecker.Versioned;
import com.scottkillen.mod.koresample.config.ConfigEventHandler;
import cpw.mods.fml.common.LoaderState.ModState;
import cpw.mods.fml.common.Mod;
Expand All @@ -44,7 +43,7 @@
"NonConstantFieldWithUpperCaseName"
})
@Mod(modid = TheMod.MOD_ID, name = TheMod.MOD_NAME, version = TheMod.MOD_VERSION, useMetadata = true, guiFactory = TheMod.MOD_GUI_FACTORY)
public final class TheMod implements Versioned
public final class TheMod
{
static final String MOD_ID = "dendrology";
static final String MOD_NAME = "Ancient Trees";
Expand Down Expand Up @@ -113,7 +112,6 @@ public void onFMLPreInitialization(FMLPreInitializationEvent event)
new ModBlocks().loadContent();
initIntegrators();
integrateMods(event.getModState());
com.scottkillen.mod.koresample.TheMod.INSTANCE.addVersionCheck(this);
}

@EventHandler
Expand All @@ -137,18 +135,11 @@ public void onFMLPostInitialization(FMLPostInitializationEvent event)
new OverworldTreeGenerator().install();
}

@Override
public String modID()
{
return MOD_ID;
}

@Override
public String versionInfoURL()
{
return "https://github.com/ScottKillen/glowing-ninja/master/AncientTrees.json";
}

@Override
public String toString()
{
Expand Down
43 changes: 15 additions & 28 deletions src/main/java/com/scottkillen/mod/dendrology/block/ModBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.scottkillen.mod.koresample.common.block.StairsBlock;
import com.scottkillen.mod.koresample.common.util.log.Logger;
import com.scottkillen.mod.koresample.tree.DefinesLog;
import com.scottkillen.mod.koresample.tree.DefinesSapling;
import com.scottkillen.mod.koresample.tree.DefinesSlab;
import com.scottkillen.mod.koresample.tree.DefinesStairs;
import com.scottkillen.mod.koresample.tree.block.LeavesBlock;
Expand All @@ -30,17 +31,6 @@
import net.minecraftforge.common.ChestGenHooks;
import java.util.List;

import static net.minecraftforge.common.ChestGenHooks.BONUS_CHEST;
import static net.minecraftforge.common.ChestGenHooks.DUNGEON_CHEST;
import static net.minecraftforge.common.ChestGenHooks.MINESHAFT_CORRIDOR;
import static net.minecraftforge.common.ChestGenHooks.PYRAMID_DESERT_CHEST;
import static net.minecraftforge.common.ChestGenHooks.PYRAMID_JUNGLE_CHEST;
import static net.minecraftforge.common.ChestGenHooks.PYRAMID_JUNGLE_DISPENSER;
import static net.minecraftforge.common.ChestGenHooks.STRONGHOLD_CORRIDOR;
import static net.minecraftforge.common.ChestGenHooks.STRONGHOLD_CROSSING;
import static net.minecraftforge.common.ChestGenHooks.STRONGHOLD_LIBRARY;
import static net.minecraftforge.common.ChestGenHooks.VILLAGE_BLACKSMITH;

public final class ModBlocks
{
private static final int DEFAULT_LEAVES_FIRE_ENCOURAGEMENT = 30;
Expand All @@ -62,27 +52,24 @@ public final class ModBlocks

private static void addAllSaplingsToChests()
{
Logger.forMod(TheMod.INSTANCE.modID()).info("Hiding species in chests.");
Logger.forMod(TheMod.INSTANCE.modID()).info("Hiding saplings in chests.");
final Settings settings = Settings.INSTANCE;
for (final SaplingBlock sapling : saplingBlocks)
{
addSaplingToChest(sapling, VILLAGE_BLACKSMITH, settings.blacksmithRarity());
addSaplingToChest(sapling, BONUS_CHEST, settings.bonusChestRarity());
addSaplingToChest(sapling, PYRAMID_DESERT_CHEST, settings.desertTempleRarity());
addSaplingToChest(sapling, DUNGEON_CHEST, settings.dungeonRarity());
addSaplingToChest(sapling, PYRAMID_JUNGLE_CHEST, settings.jungleTempleRarity());
addSaplingToChest(sapling, PYRAMID_JUNGLE_DISPENSER, settings.jungleTempleDispenserRarity());
addSaplingToChest(sapling, MINESHAFT_CORRIDOR, settings.mineshaftCorridorRarity());
addSaplingToChest(sapling, STRONGHOLD_CORRIDOR, settings.strongholdCorridorRarity());
addSaplingToChest(sapling, STRONGHOLD_CROSSING, settings.strongholdCrossingRarity());
addSaplingToChest(sapling, STRONGHOLD_LIBRARY, settings.strongholdLibraryRarity());
}

for (final DefinesSapling saplingDefinition : overworldTaxonomy.saplingDefinitions())
for (final String chestType : Settings.chestTypes())
addSaplingToChest(saplingDefinition, chestType, settings.chestRarity(chestType));
}

private static void addSaplingToChest(SaplingBlock sapling, String chestType, int rarity)
private static void addSaplingToChest(DefinesSapling saplingDefinition, String chestType, int rarity)
{
if (rarity > 0) ChestGenHooks.getInfo(chestType)
.addItem(new WeightedRandomChestContent(new ItemStack(sapling), 1, 2, rarity));
if (rarity <= 0) return;

final ItemStack sapling =
new ItemStack(saplingDefinition.saplingBlock(), 1, saplingDefinition.saplingSubBlockIndex());
final WeightedRandomChestContent chestContent = new WeightedRandomChestContent(sapling, 1, 2, rarity);

final ChestGenHooks chestGenInfo = ChestGenHooks.getInfo(chestType);
chestGenInfo.addItem(chestContent);
}

public static Iterable<? extends Block> leavesBlocks() { return ImmutableList.copyOf(leavesBlocks); }
Expand Down
146 changes: 84 additions & 62 deletions src/main/java/com/scottkillen/mod/dendrology/config/Settings.java
Original file line number Diff line number Diff line change
@@ -1,27 +1,68 @@
package com.scottkillen.mod.dendrology.config;

import com.google.common.base.Objects;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import com.scottkillen.mod.dendrology.TheMod;
import com.scottkillen.mod.koresample.config.ConfigSyncable;
import net.minecraft.util.StatCollector;
import net.minecraftforge.common.config.Configuration;
import java.util.Map;

import static net.minecraftforge.common.ChestGenHooks.BONUS_CHEST;
import static net.minecraftforge.common.ChestGenHooks.DUNGEON_CHEST;
import static net.minecraftforge.common.ChestGenHooks.MINESHAFT_CORRIDOR;
import static net.minecraftforge.common.ChestGenHooks.PYRAMID_DESERT_CHEST;
import static net.minecraftforge.common.ChestGenHooks.PYRAMID_JUNGLE_CHEST;
import static net.minecraftforge.common.ChestGenHooks.PYRAMID_JUNGLE_DISPENSER;
import static net.minecraftforge.common.ChestGenHooks.STRONGHOLD_CORRIDOR;
import static net.minecraftforge.common.ChestGenHooks.STRONGHOLD_CROSSING;
import static net.minecraftforge.common.ChestGenHooks.STRONGHOLD_LIBRARY;
import static net.minecraftforge.common.ChestGenHooks.VILLAGE_BLACKSMITH;

public enum Settings implements ConfigSyncable
{
INSTANCE;
public static final String CONFIG_VERSION = "2";
private static final int MAX_OVERWORLD_TREE_GEN_RARITY = 10000;
private int blacksmithRarity = 0;
private int bonusChestRarity = 0;
private int desertTempleRarity = 1;
private int dungeonRarity = 1;
private int jungleTempleRarity = 1;
private int jungleTempleDispenserRarity = 0;
private int mineshaftCorridorRarity = 1;
private int overworldTreeGenRarity = 1;
private int strongholdCorridorRarity = 1;
private int strongholdCrossingRarity = 1;
private int strongholdLibraryRarity = 1;
private static final int DEFAULT_OVER_WORLD_TREE_GEN_RARITY = 1;
private static final ImmutableMap<String, Integer> DEFAULT_CHEST_RARITIES =
ImmutableMap.copyOf(defaultChestRarities());
private static final ImmutableMap<String, String> CHEST_CONFIG_NAMES = chestConfigNames();
private final Map<String, Integer> chestRarities = defaultChestRarities();
private int overworldTreeGenRarity = DEFAULT_OVER_WORLD_TREE_GEN_RARITY;

private static ImmutableMap<String, String> chestConfigNames()
{
final Map<String, String> map = Maps.newHashMap();
map.put(VILLAGE_BLACKSMITH, "blacksmithRarity");
map.put(BONUS_CHEST, "bonusChestRarity");
map.put(PYRAMID_DESERT_CHEST, "desertTempleRarity");
map.put(DUNGEON_CHEST, "dungeonRarity");
map.put(PYRAMID_JUNGLE_CHEST, "jungleTempleRarity");
map.put(PYRAMID_JUNGLE_DISPENSER, "jungleTempleDispenserRarity");
map.put(MINESHAFT_CORRIDOR, "mineshaftCorridorRarity");
map.put(STRONGHOLD_CORRIDOR, "strongholdCorridorRarity");
map.put(STRONGHOLD_CROSSING, "strongholdCrossingRarity");
map.put(STRONGHOLD_LIBRARY, "strongholdLibraryRarity");
return ImmutableMap.copyOf(map);
}

private static Map<String, Integer> defaultChestRarities()
{
Map<String, Integer> map = Maps.newHashMap();
map.put(VILLAGE_BLACKSMITH, 0);
map.put(BONUS_CHEST, 0);
map.put(PYRAMID_DESERT_CHEST, 1);
map.put(DUNGEON_CHEST, 1);
map.put(PYRAMID_JUNGLE_CHEST, 1);
map.put(PYRAMID_JUNGLE_DISPENSER, 0);
map.put(MINESHAFT_CORRIDOR, 1);
map.put(STRONGHOLD_CORRIDOR, 1);
map.put(STRONGHOLD_CROSSING, 1);
map.put(STRONGHOLD_LIBRARY, 1);
return map;
}

private static int get(Configuration config, String settingName, int defaultValue)
{
Expand Down Expand Up @@ -51,47 +92,41 @@ private static String getLocalizedComment(String settingName)
return StatCollector.translateToLocal("config." + TheMod.INSTANCE.modID() + ':' + settingName);
}

public int blacksmithRarity() { return blacksmithRarity; }

public int bonusChestRarity() { return bonusChestRarity; }

public int desertTempleRarity() { return desertTempleRarity; }

public int dungeonRarity() { return dungeonRarity; }

public int jungleTempleRarity() { return jungleTempleRarity; }
public static Iterable<String> chestTypes()
{
return DEFAULT_CHEST_RARITIES.keySet();
}

public int jungleTempleDispenserRarity() { return jungleTempleDispenserRarity; }
private void loadChestRarity(Configuration config, String category, String chestType)
{
final int defaultRarity = DEFAULT_CHEST_RARITIES.get(chestType);
final String settingName = CHEST_CONFIG_NAMES.get(chestType);
final int rarity = get(config, settingName, category, defaultRarity);
chestRarities.put(chestType, rarity);
}

public int mineshaftCorridorRarity() { return mineshaftCorridorRarity; }
public int chestRarity(String chestType)
{
final Integer rarity = chestRarities.get(chestType);
return rarity == null ? 0 : rarity;
}

public boolean isOverworldTreeGenEnabled() { return overworldTreeGenRarity != 0; }

public int overworldTreeGenRarity() { return MAX_OVERWORLD_TREE_GEN_RARITY - overworldTreeGenRarity + 1; }

public int strongholdCorridorRarity() { return strongholdCorridorRarity; }

public int strongholdCrossingRarity() { return strongholdCrossingRarity; }

public int strongholdLibraryRarity() { return strongholdLibraryRarity; }

@Override
public void convertOldConfig(Configuration oldConfig)
{
if ("1".equals(oldConfig.getLoadedConfigVersion()))
{
blacksmithRarity = get(oldConfig, "blacksmithRarity", blacksmithRarity);
bonusChestRarity = get(oldConfig, "bonusChestRarity", bonusChestRarity);
desertTempleRarity = get(oldConfig, "desertTempleRarity", desertTempleRarity);
dungeonRarity = get(oldConfig, "dungeonRarity", dungeonRarity);
jungleTempleRarity = get(oldConfig, "jungleTempleRarity", jungleTempleRarity);
jungleTempleDispenserRarity = get(oldConfig, "jungleTempleDispenserRarity", jungleTempleDispenserRarity);
mineshaftCorridorRarity = get(oldConfig, "mineshaftCorridorRarity", mineshaftCorridorRarity);
overworldTreeGenRarity =
get(oldConfig, "overworldTreeGenRarity", overworldTreeGenRarity, 0, MAX_OVERWORLD_TREE_GEN_RARITY);
strongholdCorridorRarity = get(oldConfig, "strongholdCorridorRarity", strongholdCorridorRarity);
strongholdCrossingRarity = get(oldConfig, "strongholdCrossingRarity", strongholdCrossingRarity);
strongholdLibraryRarity = get(oldConfig, "strongholdLibraryRarity", strongholdLibraryRarity);
for (final String chestType : DEFAULT_CHEST_RARITIES.keySet())
{
loadChestRarity(oldConfig, Configuration.CATEGORY_GENERAL, chestType);
}

overworldTreeGenRarity = get(oldConfig, "overworldTreeGenRarity", DEFAULT_OVER_WORLD_TREE_GEN_RARITY, 0,
MAX_OVERWORLD_TREE_GEN_RARITY);
}

syncConfig(TheMod.INSTANCE.configuration());
Expand All @@ -101,34 +136,21 @@ public void convertOldConfig(Configuration oldConfig)
public void syncConfig(Configuration config)
{
final String chestsCategory = Configuration.CATEGORY_GENERAL + ".chests";
blacksmithRarity = get(config, "blacksmithRarity", chestsCategory, blacksmithRarity);
bonusChestRarity = get(config, "bonusChestRarity", chestsCategory, bonusChestRarity);
desertTempleRarity = get(config, "desertTempleRarity", chestsCategory, desertTempleRarity);
dungeonRarity = get(config, "dungeonRarity", chestsCategory, dungeonRarity);
jungleTempleRarity = get(config, "jungleTempleRarity", chestsCategory, jungleTempleRarity);
jungleTempleDispenserRarity =
get(config, "jungleTempleDispenserRarity", chestsCategory, jungleTempleDispenserRarity);
mineshaftCorridorRarity = get(config, "mineshaftCorridorRarity", chestsCategory, mineshaftCorridorRarity);
strongholdCorridorRarity = get(config, "strongholdCorridorRarity", chestsCategory, strongholdCorridorRarity);
strongholdCrossingRarity = get(config, "strongholdCrossingRarity", chestsCategory, strongholdCrossingRarity);
strongholdLibraryRarity = get(config, "strongholdLibraryRarity", chestsCategory, strongholdLibraryRarity);
for (final String chestType : chestRarities.keySet())
{
loadChestRarity(config, chestsCategory, chestType);
}

final String worldGenCategory = Configuration.CATEGORY_GENERAL + ".worldgen";
overworldTreeGenRarity = get(config, "overworldTreeGenRarity", worldGenCategory, overworldTreeGenRarity, 0,
MAX_OVERWORLD_TREE_GEN_RARITY);
overworldTreeGenRarity =
get(config, "overworldTreeGenRarity", worldGenCategory, DEFAULT_OVER_WORLD_TREE_GEN_RARITY, 0,
MAX_OVERWORLD_TREE_GEN_RARITY);
}

@Override
public String toString()
{
return Objects.toStringHelper(this).add("blacksmithRarity", blacksmithRarity)
.add("bonusChestRarity", bonusChestRarity).add("desertTempleRarity", desertTempleRarity)
.add("dungeonRarity", dungeonRarity).add("jungleTempleRarity", jungleTempleRarity)
.add("jungleTempleDispenserRarity", jungleTempleDispenserRarity)
.add("mineshaftCorridorRarity", mineshaftCorridorRarity)
.add("overworldTreeGenRarity", overworldTreeGenRarity)
.add("strongholdCorridorRarity", strongholdCorridorRarity)
.add("strongholdCrossingRarity", strongholdCrossingRarity)
.add("strongholdLibraryRarity", strongholdLibraryRarity).toString();
return Objects.toStringHelper(this).add("chestRarities", chestRarities)
.add("overworldTreeGenRarity", overworldTreeGenRarity).toString();
}
}
3 changes: 3 additions & 0 deletions src/main/resources/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Ancient Trees Changelog

## 1.3.1
- All saplings are now added to chests. ([#29](/MinecraftModArchive/Dendrology/issues/29))

## 1.3.0
- Improved Forestry integration.
- Removed compile time dependency on The Chisel jar.
Expand Down
Loading

0 comments on commit 515974c

Please sign in to comment.