Skip to content

Commit

Permalink
Revert "Slightly improve render performance of genetic items (bee, tr…
Browse files Browse the repository at this point in the history
…ees, etc)"

This reverts commit 3df3d91.
  • Loading branch information
mezz committed Nov 30, 2017
1 parent 13f49fc commit b07e5a1
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 10 deletions.
@@ -1,6 +1,7 @@
package forestry.apiculture.compat;

import com.google.common.base.Preconditions;
import forestry.api.apiculture.BeeManager;
import forestry.api.genetics.IAlleleSpecies;
import forestry.apiculture.ModuleApiculture;
import forestry.apiculture.items.ItemRegistryApiculture;
Expand All @@ -19,7 +20,7 @@ public void registerItemSubtypes(ISubtypeRegistry subtypeRegistry) {
Preconditions.checkNotNull(items);

ISubtypeRegistry.ISubtypeInterpreter beeSubtypeInterpreter = itemStack -> {
IAlleleSpecies species = Genome.getSpeciesDirectly(itemStack);
IAlleleSpecies species = Genome.getSpeciesDirectly(BeeManager.beeRoot, itemStack);
return species == null ? ISubtypeRegistry.ISubtypeInterpreter.NONE : species.getUID();
};

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/forestry/apiculture/genetics/BeeGenome.java
Expand Up @@ -84,7 +84,7 @@ public BeeGenome(IChromosome[] chromosomes) {
public static IAlleleBeeSpecies getSpecies(ItemStack itemStack) {
Preconditions.checkArgument(BeeManager.beeRoot.isMember(itemStack), "itemStack must be a bee");

IAlleleSpecies species = getSpeciesDirectly(itemStack);
IAlleleSpecies species = getSpeciesDirectly(BeeManager.beeRoot, itemStack);
if (species instanceof IAlleleBeeSpecies) {
return (IAlleleBeeSpecies) species;
}
Expand Down
Expand Up @@ -48,7 +48,7 @@ public TreeGenome(NBTTagCompound nbttagcompound) {
public static IAlleleTreeSpecies getSpecies(ItemStack itemStack) {
Preconditions.checkArgument(TreeManager.treeRoot.isMember(itemStack), "ItemStack must be a tree");

IAlleleSpecies species = getSpeciesDirectly(itemStack);
IAlleleSpecies species = getSpeciesDirectly(TreeManager.treeRoot, itemStack);
if (species instanceof IAlleleTreeSpecies) {
return (IAlleleTreeSpecies) species;
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/forestry/core/genetics/Chromosome.java
Expand Up @@ -22,8 +22,8 @@
import forestry.api.genetics.ISpeciesRoot;

public class Chromosome implements IChromosome {
public static final String UID0_TAG = "UID0";
public static final String UID1_TAG = "UID1";
private static final String UID0_TAG = "UID0";
private static final String UID1_TAG = "UID1";

private final IAllele primary;
private final IAllele secondary;
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/forestry/core/genetics/Genome.java
Expand Up @@ -15,7 +15,6 @@
import javax.annotation.Nullable;
import java.util.Arrays;

import forestry.api.genetics.AlleleManager;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
Expand Down Expand Up @@ -110,7 +109,7 @@ private IAllele[] getDefaultTemplate() {
* We need this because the client uses the species for rendering.
*/
@Nullable
public static IAlleleSpecies getSpeciesDirectly(ItemStack itemStack) {
public static IAlleleSpecies getSpeciesDirectly(ISpeciesRoot speciesRoot, ItemStack itemStack) {
NBTTagCompound nbtTagCompound = itemStack.getTagCompound();
if (nbtTagCompound == null) {
return null;
Expand All @@ -127,11 +126,13 @@ public static IAlleleSpecies getSpeciesDirectly(ItemStack itemStack) {
}

NBTTagCompound chromosomeNBT = chromosomesNBT.getCompoundTagAt(0);
String speciesUid = chromosomeNBT.getString(Chromosome.UID0_TAG);
IAllele activeAllele = AlleleManager.alleleRegistry.getAllele(speciesUid);
Chromosome chromosome = Chromosome.create(null, null, speciesRoot.getSpeciesChromosomeType(), chromosomeNBT);

IAllele activeAllele = chromosome.getActiveAllele();
if (!(activeAllele instanceof IAlleleSpecies)) {
return null;
}

return (IAlleleSpecies) activeAllele;
}

Expand Down
Expand Up @@ -49,7 +49,7 @@ public ButterflyGenome(IChromosome[] chromosomes) {
public static IAlleleButterflySpecies getSpecies(ItemStack itemStack) {
Preconditions.checkArgument(ButterflyManager.butterflyRoot.isMember(itemStack), "Must be a butterfly");

IAlleleSpecies species = getSpeciesDirectly(itemStack);
IAlleleSpecies species = getSpeciesDirectly(ButterflyManager.butterflyRoot, itemStack);
if (species instanceof IAlleleButterflySpecies) {
return (IAlleleButterflySpecies) species;
}
Expand Down

0 comments on commit b07e5a1

Please sign in to comment.