Skip to content

Commit

Permalink
Fix textures of leaves and remove redundant enum (replace LeafType to…
Browse files Browse the repository at this point in the history
… EnumLeafType from Forestry)
  • Loading branch information
marcin212 committed Oct 27, 2016
1 parent d7b5954 commit c91a0c6
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 97 deletions.
15 changes: 8 additions & 7 deletions src/main/java/binnie/extratrees/block/decor/BlockHedge.java
Expand Up @@ -126,9 +126,9 @@ public BlockHedge() {
// public void registerBlockIcons(final IIconRegister p_149651_1_) {
// }

private ExtraTreeSpecies.LeafType getType(final int meta) {
return ExtraTreeSpecies.LeafType.values()[meta % 8];
}
// private ExtraTreeSpecies.LeafType getType(final int meta) {
// return ExtraTreeSpecies.LeafType.values()[meta % 8];
// }

private boolean isFull(final int meta) {
return meta / 8 > 0;
Expand Down Expand Up @@ -158,10 +158,11 @@ public void getSubBlocks(final Item item, final CreativeTabs tab, final List lis
// }

public static int getColor(final int meta) {
final ExtraTreeSpecies.LeafType type = ExtraTreeSpecies.LeafType.values()[meta % 6];
if (type == ExtraTreeSpecies.LeafType.Conifer) {
return ColorizerFoliage.getFoliageColorPine();
}
//TODO fix color
// final ExtraTreeSpecies.LeafType type = ExtraTreeSpecies.LeafType.values()[meta % 6];
// if (type == ExtraTreeSpecies.LeafType.Conifer) {
// return ColorizerFoliage.getFoliageColorPine();
// }
final double d0 = 0.5;
final double d2 = 1.0;
return ColorizerFoliage.getFoliageColor(d0, d2);
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/binnie/extratrees/block/decor/ItemHedge.java
Expand Up @@ -13,6 +13,7 @@ public ItemHedge(final Block block) {
@Override
public String getItemStackDisplayName(final ItemStack item) {
final int meta = item.getItemDamage();
return ExtraTreeSpecies.LeafType.values()[meta % 6].descript + ((meta >= 8) ? " Full" : "") + " Hedge";
//TODO Fix to proper name
return "" ;//ExtraTreeSpecies.LeafType.values()[meta % 6].descript + ((meta >= 8) ? " Full" : "") + " Hedge";
}
}
161 changes: 72 additions & 89 deletions src/main/java/binnie/extratrees/genetics/ExtraTreeSpecies.java
Expand Up @@ -7,6 +7,8 @@
import binnie.extratrees.ExtraTrees;
import binnie.extratrees.block.EnumExtraTreeLog;
import binnie.extratrees.gen.*;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import com.mojang.authlib.GameProfile;
import forestry.api.apiculture.EnumBeeChromosome;
import forestry.api.arboriculture.*;
Expand Down Expand Up @@ -39,6 +41,8 @@
import java.lang.reflect.Method;
import java.util.*;
import java.util.List;
import java.util.function.BiFunction;
import java.util.stream.Collectors;

public class ExtraTreeSpecies implements IAlleleTreeSpecies//, IIconProvider, IGermlingIconProvider
{
Expand Down Expand Up @@ -140,7 +144,7 @@ public class ExtraTreeSpecies implements IAlleleTreeSpecies//, IIconProvider, IG
public static final ExtraTreeSpecies Candlenut = new ExtraTreeSpecies("aleurites", "moluccana", 9085804, 9085804, 5456154, EnumVanillaWoodType.JUNGLE, ExtraTreeFruitGene.Candlenut, SaplingType.Default, WorldGenLazy.Tree.class);
public static final ExtraTreeSpecies DwarfHazel = new ExtraTreeSpecies("Corylus", "americana", 10204498, 10215762, 11180143, EnumExtraTreeLog.Hazel, ExtraTreeFruitGene.Hazelnut, SaplingType.Shrub, WorldGenShrub.Shrub.class);

private LeafType leafType;
private EnumLeafType leafType;
private SaplingType saplingType;
ArrayList<IFruitFamily> families;
int girth;
Expand All @@ -156,7 +160,8 @@ public class ExtraTreeSpecies implements IAlleleTreeSpecies//, IIconProvider, IG
IClassification branch;

private static LinkedList<ExtraTreeSpecies> list;
private static HashMap<ExtraTreeSpecies, String> namesMap;
private static BiMap<ExtraTreeSpecies, String> namesMap;
private static Map<String, ExtraTreeSpecies> revNamesMap;

public static List<ExtraTreeSpecies> values() {
if (list == null) {
Expand All @@ -175,9 +180,18 @@ public static List<ExtraTreeSpecies> values() {
return list;
}

public static Map<String, ExtraTreeSpecies> names(){
if(revNamesMap == null){
TreeMap m = new TreeMap<String, ExtraTreeSpecies>(String.CASE_INSENSITIVE_ORDER);
m.putAll(namesMap.inverse());
revNamesMap = m;
}
return revNamesMap;
}

public String getSpeciesName() {
if (namesMap == null) {
namesMap = new HashMap<>();
namesMap = HashBiMap.create();
for (Field f : ExtraTreeSpecies.class.getFields()) {
if (f.getType() == ExtraTreeSpecies.class) {
try {
Expand All @@ -187,6 +201,7 @@ public String getSpeciesName() {
}
}
}

}
String value = namesMap.get(this);
if (value == null || value.isEmpty()) {
Expand Down Expand Up @@ -221,19 +236,19 @@ public static void init() {
ExtraTreeSpecies.Lime, ExtraTreeSpecies.KeyLime, ExtraTreeSpecies.FingerLime, ExtraTreeSpecies.Pomelo,
ExtraTreeSpecies.Grapefruit, ExtraTreeSpecies.Kumquat, ExtraTreeSpecies.Citron, ExtraTreeSpecies.BuddhaHand};
for (final ExtraTreeSpecies species3 : arr$3) {
species3.setLeafType(LeafType.Jungle);
species3.setLeafType(EnumLeafType.JUNGLE);
species3.saplingType = SaplingType.Fruit;
final IAlleleTreeSpecies citrus2 = (IAlleleTreeSpecies) AlleleManager.alleleRegistry.getAllele("forestry.treeLemon");
species3.setWorldGen(citrus2.getGenerator().getWorldGenerator(TreeManager.treeRoot.templateAsIndividual(citrus2.getRoot().getDefaultTemplate())).getClass());
species3.finished();
}
ExtraTreeSpecies.Banana.setLeafType(LeafType.Palm);
ExtraTreeSpecies.RedBanana.setLeafType(LeafType.Palm);
ExtraTreeSpecies.Plantain.setLeafType(LeafType.Palm);
ExtraTreeSpecies.Banana.setLeafType(EnumLeafType.PALM);
ExtraTreeSpecies.RedBanana.setLeafType(EnumLeafType.PALM);
ExtraTreeSpecies.Plantain.setLeafType(EnumLeafType.PALM);
ExtraTreeSpecies.Banana.finished();
ExtraTreeSpecies.RedBanana.finished();
ExtraTreeSpecies.Plantain.finished();
ExtraTreeSpecies.Hemlock.setLeafType(LeafType.Conifer);
ExtraTreeSpecies.Hemlock.setLeafType(EnumLeafType.CONIFERS);
ExtraTreeSpecies.Butternut.finished();
ExtraTreeSpecies.Butternut.setGirth(2);
ExtraTreeSpecies.Rowan.finished();
Expand All @@ -244,9 +259,9 @@ public static void init() {
ExtraTreeSpecies.Beech.finished();
ExtraTreeSpecies.CopperBeech.finished();
ExtraTreeSpecies.Aspen.finished();
ExtraTreeSpecies.Yew.setLeafType(LeafType.Conifer);
ExtraTreeSpecies.Cypress.setLeafType(LeafType.Conifer);
ExtraTreeSpecies.DouglasFir.setLeafType(LeafType.Conifer);
ExtraTreeSpecies.Yew.setLeafType(EnumLeafType.CONIFERS);
ExtraTreeSpecies.Cypress.setLeafType(EnumLeafType.CONIFERS);
ExtraTreeSpecies.DouglasFir.setLeafType(EnumLeafType.CONIFERS);
ExtraTreeSpecies.Yew.finished();
ExtraTreeSpecies.Cypress.finished();
ExtraTreeSpecies.Cypress.saplingType = SaplingType.Poplar;
Expand All @@ -259,9 +274,9 @@ public static void init() {
ExtraTreeSpecies.Whitebeam.finished();
ExtraTreeSpecies.Hawthorn.finished();
ExtraTreeSpecies.Pecan.finished();
ExtraTreeSpecies.Fir.setLeafType(LeafType.Conifer);
ExtraTreeSpecies.Cedar.setLeafType(LeafType.Conifer);
ExtraTreeSpecies.Sallow.setLeafType(LeafType.Willow);
ExtraTreeSpecies.Fir.setLeafType(EnumLeafType.CONIFERS);
ExtraTreeSpecies.Cedar.setLeafType(EnumLeafType.CONIFERS);
ExtraTreeSpecies.Sallow.setLeafType(EnumLeafType.WILLOW);
ExtraTreeSpecies.Elm.finished();
ExtraTreeSpecies.Elder.finished();
ExtraTreeSpecies.Holly.finished();
Expand All @@ -272,35 +287,35 @@ public static void init() {
ExtraTreeSpecies.Fir.finished();
ExtraTreeSpecies.Cedar.finished();
ExtraTreeSpecies.Cedar.setGirth(2);
ExtraTreeSpecies.RedMaple.setLeafType(LeafType.Maple);
ExtraTreeSpecies.BalsamFir.setLeafType(LeafType.Conifer);
ExtraTreeSpecies.LoblollyPine.setLeafType(LeafType.Conifer);
ExtraTreeSpecies.RedMaple.setLeafType(EnumLeafType.MAPLE);
ExtraTreeSpecies.BalsamFir.setLeafType(EnumLeafType.CONIFERS);
ExtraTreeSpecies.LoblollyPine.setLeafType(EnumLeafType.CONIFERS);
ExtraTreeSpecies.Olive.finished();
ExtraTreeSpecies.RedMaple.finished();
ExtraTreeSpecies.BalsamFir.finished();
ExtraTreeSpecies.LoblollyPine.finished();
ExtraTreeSpecies.Sweetgum.finished();
ExtraTreeSpecies.Locust.finished();
ExtraTreeSpecies.Pear.finished();
ExtraTreeSpecies.OsangeOsange.setLeafType(LeafType.Jungle);
ExtraTreeSpecies.OldFustic.setLeafType(LeafType.Jungle);
ExtraTreeSpecies.Brazilwood.setLeafType(LeafType.Jungle);
ExtraTreeSpecies.Logwood.setLeafType(LeafType.Jungle);
ExtraTreeSpecies.Rosewood.setLeafType(LeafType.Jungle);
ExtraTreeSpecies.Purpleheart.setLeafType(LeafType.Jungle);
ExtraTreeSpecies.OsangeOsange.setLeafType(EnumLeafType.JUNGLE);
ExtraTreeSpecies.OldFustic.setLeafType(EnumLeafType.JUNGLE);
ExtraTreeSpecies.Brazilwood.setLeafType(EnumLeafType.JUNGLE);
ExtraTreeSpecies.Logwood.setLeafType(EnumLeafType.JUNGLE);
ExtraTreeSpecies.Rosewood.setLeafType(EnumLeafType.JUNGLE);
ExtraTreeSpecies.Purpleheart.setLeafType(EnumLeafType.JUNGLE);
ExtraTreeSpecies.OsangeOsange.finished();
ExtraTreeSpecies.OldFustic.finished();
ExtraTreeSpecies.Brazilwood.finished();
ExtraTreeSpecies.Logwood.finished();
ExtraTreeSpecies.Rosewood.finished();
ExtraTreeSpecies.Purpleheart.finished();
ExtraTreeSpecies.Gingko.setLeafType(LeafType.Jungle);
ExtraTreeSpecies.Brazilnut.setLeafType(LeafType.Jungle);
ExtraTreeSpecies.RoseGum.setLeafType(LeafType.Jungle);
ExtraTreeSpecies.SwampGum.setLeafType(LeafType.Jungle);
ExtraTreeSpecies.Coffee.setLeafType(LeafType.Jungle);
ExtraTreeSpecies.MonkeyPuzzle.setLeafType(LeafType.Conifer);
ExtraTreeSpecies.RainbowGum.setLeafType(LeafType.Jungle);
ExtraTreeSpecies.Gingko.setLeafType(EnumLeafType.JUNGLE);
ExtraTreeSpecies.Brazilnut.setLeafType(EnumLeafType.JUNGLE);
ExtraTreeSpecies.RoseGum.setLeafType(EnumLeafType.JUNGLE);
ExtraTreeSpecies.SwampGum.setLeafType(EnumLeafType.JUNGLE);
ExtraTreeSpecies.Coffee.setLeafType(EnumLeafType.JUNGLE);
ExtraTreeSpecies.MonkeyPuzzle.setLeafType(EnumLeafType.CONIFERS);
ExtraTreeSpecies.RainbowGum.setLeafType(EnumLeafType.JUNGLE);
ExtraTreeSpecies.Iroko.finished();
ExtraTreeSpecies.Gingko.finished();
ExtraTreeSpecies.Brazilnut.finished();
Expand All @@ -314,7 +329,7 @@ public static void init() {
ExtraTreeSpecies.MonkeyPuzzle.setGirth(2);
ExtraTreeSpecies.RainbowGum.finished();
ExtraTreeSpecies.PinkIvory.finished();
ExtraTreeSpecies.Juniper.setLeafType(LeafType.Conifer);
ExtraTreeSpecies.Juniper.setLeafType(EnumLeafType.CONIFERS);
ExtraTreeSpecies.Blackcurrant.saplingType = SaplingType.Shrub;
ExtraTreeSpecies.Redcurrant.saplingType = SaplingType.Shrub;
ExtraTreeSpecies.Blackberry.saplingType = SaplingType.Shrub;
Expand All @@ -333,16 +348,16 @@ public static void init() {
}
(species3.branch = branch).addMemberSpecies(species3);
}
ExtraTreeSpecies.Cinnamon.setLeafType(LeafType.Jungle);
ExtraTreeSpecies.Coconut.setLeafType(LeafType.Palm);
ExtraTreeSpecies.Cashew.setLeafType(LeafType.Jungle);
ExtraTreeSpecies.Avacado.setLeafType(LeafType.Jungle);
ExtraTreeSpecies.Nutmeg.setLeafType(LeafType.Jungle);
ExtraTreeSpecies.Allspice.setLeafType(LeafType.Jungle);
ExtraTreeSpecies.Chilli.setLeafType(LeafType.Jungle);
ExtraTreeSpecies.StarAnise.setLeafType(LeafType.Jungle);
ExtraTreeSpecies.Mango.setLeafType(LeafType.Jungle);
ExtraTreeSpecies.Starfruit.setLeafType(LeafType.Jungle);
ExtraTreeSpecies.Cinnamon.setLeafType(EnumLeafType.JUNGLE);
ExtraTreeSpecies.Coconut.setLeafType(EnumLeafType.PALM);
ExtraTreeSpecies.Cashew.setLeafType(EnumLeafType.JUNGLE);
ExtraTreeSpecies.Avacado.setLeafType(EnumLeafType.JUNGLE);
ExtraTreeSpecies.Nutmeg.setLeafType(EnumLeafType.JUNGLE);
ExtraTreeSpecies.Allspice.setLeafType(EnumLeafType.JUNGLE);
ExtraTreeSpecies.Chilli.setLeafType(EnumLeafType.JUNGLE);
ExtraTreeSpecies.StarAnise.setLeafType(EnumLeafType.JUNGLE);
ExtraTreeSpecies.Mango.setLeafType(EnumLeafType.JUNGLE);
ExtraTreeSpecies.Starfruit.setLeafType(EnumLeafType.JUNGLE);
final IFruitFamily familyPrune = AlleleManager.alleleRegistry.getFruitFamily("forestry.prunes");
final IFruitFamily familyPome = AlleleManager.alleleRegistry.getFruitFamily("forestry.pomes");
final IFruitFamily familyJungle = AlleleManager.alleleRegistry.getFruitFamily("forestry.jungle");
Expand Down Expand Up @@ -582,7 +597,7 @@ public void preInit() {
int woodColor;

private ExtraTreeSpecies(final String branch, final String binomial, final int color, final int polColor, final int woodColor, final IWoodType wood, final IAlleleFruit fruit, SaplingType saplingType, final Class<? extends WorldGenerator> gen) {
this.leafType = LeafType.Normal;
this.leafType = EnumLeafType.DECIDUOUS;
this.saplingType = saplingType;
this.families = new ArrayList<>();
this.girth = 1;
Expand All @@ -608,7 +623,7 @@ public boolean equals(Object obj) {

@Override
public int getSpriteColour(int renderPass) {
return color;
return getGermlingColour(EnumGermlingType.SAPLING, renderPass);
}

@Override
Expand All @@ -630,18 +645,7 @@ public IWoodProvider getWoodProvider() {
@Nonnull
@Override
public ILeafSpriteProvider getLeafSpriteProvider() {
return new ILeafSpriteProvider() {
@Nonnull
@Override
public ResourceLocation getSprite(boolean pollinated, boolean fancy) {
return new ResourceLocation("asd");
}

@Override
public int getColor(boolean pollinated) {
return colorPollineted;
}
};
return TreeManager.treeFactory.getLeafIconProvider(leafType,new Color(color), new Color(colorPollineted));
}

@Nonnull
Expand Down Expand Up @@ -797,15 +801,15 @@ public WorldGenerator getGenerator(final ITreeGenData tree) {
return new WorldGenDefault(tree);
}

void setLeafType(final LeafType type) {
void setLeafType(final EnumLeafType type) {
this.leafType = type;
if (this.leafType == LeafType.Conifer) {
if (this.leafType == EnumLeafType.CONIFERS) {
this.saplingType = SaplingType.Conifer;
}
if (this.leafType == LeafType.Jungle) {
if (this.leafType == EnumLeafType.JUNGLE) {
this.saplingType = SaplingType.Jungle;
}
if (this.leafType == LeafType.Palm) {
if (this.leafType == EnumLeafType.PALM) {
this.saplingType = SaplingType.Palm;
}
}
Expand Down Expand Up @@ -879,15 +883,15 @@ public int getLeafColour(final ITree tree) {
return this.color;
}

public short getLeafIconIndex(final ITree tree, final boolean fancy) {
if (!fancy) {
return this.leafType.plainUID;
}
if (tree.getMate() != null) {
return this.leafType.changedUID;
}
return this.leafType.fancyUID;
}
// public short getLeafIconIndex(final ITree tree, final boolean fancy) {
// if (!fancy) {
// return this.leafType.plainUID;
// }
// if (tree.getMate() != null) {
// return this.leafType.changedUID;
// }
// return this.leafType.fancyUID;
// }

// @Override
// public int getIconColour(final int renderPass) {
Expand Down Expand Up @@ -1033,27 +1037,6 @@ public String getUnlocalizedName() {
return "extratrees.species." + this.getUID() + ".name";
}

public enum LeafType {
Normal((short) 10, (short) 11, (short) 12, "Deciduous"),
Conifer((short) 15, (short) 16, (short) 17, "Conifers"),
Jungle((short) 20, (short) 21, (short) 22, "Jungle"),
Willow((short) 25, (short) 26, (short) 27, "Willow"),
Maple((short) 30, (short) 31, (short) 32, "Maple"),
Palm((short) 35, (short) 36, (short) 37, "Palm");

public final short fancyUID;
public final short plainUID;
public final short changedUID;
public final String descript;

LeafType(final short fancyUID, final short plainUID, final short changedUID, final String descript) {
this.fancyUID = fancyUID;
this.plainUID = plainUID;
this.changedUID = changedUID;
this.descript = descript;
}
}

public enum SaplingType {
Default,
Jungle,
Expand Down

0 comments on commit c91a0c6

Please sign in to comment.