mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-21 04:32:24 +00:00
Clean Up and localise flower tooltip
This commit is contained in:
1 parent
d706224e56
commit
5a64454906
4 files changed
+86
-67
No files matched your search
@@ -7,12 +7,14 @@ import binnie.botany.api.EnumFlowerChromosome;
|
||||
import binnie.botany.api.EnumFlowerStage;
|
||||
import binnie.botany.api.IAlleleFlowerSpecies;
|
||||
import binnie.botany.api.IFlower;
|
||||
import binnie.botany.api.IFlowerGenome;
|
||||
import binnie.botany.api.IFlowerType;
|
||||
import binnie.botany.core.BotanyCore;
|
||||
import binnie.botany.genetics.Flower;
|
||||
import binnie.core.BinnieCore;
|
||||
import forestry.api.core.IItemModelRegister;
|
||||
import forestry.api.core.IModelManager;
|
||||
import forestry.api.genetics.IGenome;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.IPollinatable;
|
||||
import forestry.core.config.Config;
|
||||
@@ -34,6 +36,7 @@ import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
@@ -79,26 +82,36 @@ public class ItemBotany extends Item implements IColoredItem, IItemModelRegister
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(final ItemStack itemstack, final EntityPlayer player, final List list, final boolean flag) {
|
||||
if (!itemstack.hasTagCompound()) {
|
||||
public void addInformation(final ItemStack itemStack, final EntityPlayer player, final List list, final boolean flag) {
|
||||
if (!itemStack.hasTagCompound()) {
|
||||
return;
|
||||
}
|
||||
final IFlower individual = (IFlower) this.getIndividual(itemstack);
|
||||
if (individual == null) {
|
||||
list.add("This item is bugged. Destroy it!");
|
||||
IFlower individual = (IFlower) this.getIndividual(itemStack);
|
||||
if (individual == null || individual.getGenome() == null) {
|
||||
list.add(TextFormatting.DARK_RED + Binnie.Language.localise("botany.flower.destroy"));
|
||||
return;
|
||||
}
|
||||
list.add("§e" + individual.getGenome().getPrimaryColor().getColourName() + ((individual.getGenome().getPrimaryColor() == individual.getGenome().getSecondaryColor()) ? "" : (" and " + individual.getGenome().getSecondaryColor().getColourName())) + ", " + individual.getGenome().getStemColor().getColourName() + " Stem");
|
||||
IFlowerGenome genome = individual.getGenome();
|
||||
//Colors
|
||||
String primaryColor = genome.getPrimaryColor().getColourName();
|
||||
String secondaryColor = genome.getSecondaryColor().getColourName();
|
||||
String stemColor = genome.getStemColor().getColourName();
|
||||
String colourInfo;
|
||||
if(!primaryColor.equals(secondaryColor)){
|
||||
colourInfo = Binnie.Language.localise("botany.grammar.flower.secondary");
|
||||
}else{
|
||||
colourInfo = Binnie.Language.localise("botany.grammar.flower");
|
||||
}
|
||||
list.add(TextFormatting.YELLOW + colourInfo.replaceAll("%PRIMARY", primaryColor).replaceAll("%SECONDARY", secondaryColor).replaceAll("%STEM", stemColor));
|
||||
|
||||
if (individual.isAnalyzed()) {
|
||||
if (BinnieCore.proxy.isShiftDown()) {
|
||||
individual.addTooltip(list);
|
||||
} else {
|
||||
list.add(TextFormatting.ITALIC + "<" + Binnie.Language.localise("for.gui.tooltip.tmi") + ">");
|
||||
}
|
||||
else {
|
||||
list.add("§o<Hold shift for details>");
|
||||
}
|
||||
}
|
||||
else {
|
||||
list.add("<Unknown>");
|
||||
} else {
|
||||
list.add("<" + Binnie.Language.localise("for.gui.unknown") + ">");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,15 +12,19 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class Flower extends Individual implements IFlower {
|
||||
@Nonnull
|
||||
public IFlowerGenome genome;
|
||||
@Nullable
|
||||
public IFlowerGenome mate;
|
||||
int age;
|
||||
boolean wilting;
|
||||
boolean flowered;
|
||||
private int age;
|
||||
private boolean wilting;
|
||||
private boolean flowered;
|
||||
|
||||
public Flower(@Nonnull final NBTTagCompound nbt) {
|
||||
super(nbt);
|
||||
@@ -118,36 +122,32 @@ public class Flower extends Individual implements IFlower {
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
public int getMetadata() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFlowerGenome getGenome() {
|
||||
return this.genome;
|
||||
}
|
||||
|
||||
private IChromosome inheritChromosome(final Random rand, final IChromosome parent1, final IChromosome parent2) {
|
||||
IAllele choice1;
|
||||
private IChromosome inheritChromosome(Random rand, IChromosome parentFirst, IChromosome parentSecond) {
|
||||
IAllele choiceFirst;
|
||||
if (rand.nextBoolean()) {
|
||||
choice1 = parent1.getPrimaryAllele();
|
||||
choiceFirst = parentFirst.getPrimaryAllele();
|
||||
} else {
|
||||
choice1 = parent1.getSecondaryAllele();
|
||||
choiceFirst = parentFirst.getSecondaryAllele();
|
||||
}
|
||||
IAllele choice2;
|
||||
IAllele choiceSecond;
|
||||
if (rand.nextBoolean()) {
|
||||
choice2 = parent2.getPrimaryAllele();
|
||||
choiceSecond = parentSecond.getPrimaryAllele();
|
||||
} else {
|
||||
choice2 = parent2.getSecondaryAllele();
|
||||
choiceSecond = parentSecond.getSecondaryAllele();
|
||||
}
|
||||
if (rand.nextBoolean()) {
|
||||
return new Chromosome(choice1, choice2);
|
||||
return new Chromosome(choiceFirst, choiceSecond);
|
||||
}
|
||||
return new Chromosome(choice2, choice1);
|
||||
return new Chromosome(choiceSecond, choiceFirst);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mate(final IFlower other) {
|
||||
public void mate(IFlower other) {
|
||||
this.mate = new FlowerGenome(other.getGenome().getChromosomes());
|
||||
}
|
||||
|
||||
@@ -213,73 +213,73 @@ public class Flower extends Individual implements IFlower {
|
||||
@Override
|
||||
public IFlower getOffspring(final World world, final BlockPos pos) {
|
||||
final IChromosome[] chromosomes = new IChromosome[this.genome.getChromosomes().length];
|
||||
IChromosome[] parent1 = this.genome.getChromosomes();
|
||||
IChromosome[] parent2 = this.mate.getChromosomes();
|
||||
parent1 = this.mutateSpecies(world, pos, this.genome, this.mate);
|
||||
parent2 = this.mutateSpecies(world, pos, this.mate, this.genome);
|
||||
for (int i = 0; i < parent1.length; ++i) {
|
||||
if (parent1[i] != null && parent2[i] != null) {
|
||||
chromosomes[i] = Chromosome.inheritChromosome(world.rand, parent1[i], parent2[i]);
|
||||
IChromosome[] parentFirst = this.genome.getChromosomes();
|
||||
IChromosome[] parentSecond = this.mate.getChromosomes();
|
||||
parentFirst = this.mutateSpecies(world, pos, this.genome, this.mate);
|
||||
parentSecond = this.mutateSpecies(world, pos, this.mate, this.genome);
|
||||
for (int i = 0; i < parentFirst.length; ++i) {
|
||||
if (parentFirst[i] != null && parentSecond[i] != null) {
|
||||
chromosomes[i] = Chromosome.inheritChromosome(world.rand, parentFirst[i], parentSecond[i]);
|
||||
}
|
||||
}
|
||||
return new Flower(new FlowerGenome(chromosomes), 0);
|
||||
}
|
||||
|
||||
private IChromosome[] mutateSpecies(final World world, final BlockPos pos, final IFlowerGenome genomeOne, final IFlowerGenome genomeTwo) {
|
||||
IChromosome[] parent1 = genomeOne.getChromosomes();
|
||||
final IChromosome[] parent2 = genomeTwo.getChromosomes();
|
||||
IAlleleFlowerSpecies allele0;
|
||||
IAlleleFlowerSpecies allele2;
|
||||
private IChromosome[] mutateSpecies(World world, BlockPos pos, IFlowerGenome genomeFirst, IFlowerGenome genomeSecond) {
|
||||
IChromosome[] parentFirst = genomeFirst.getChromosomes();
|
||||
final IChromosome[] parentSecond = genomeSecond.getChromosomes();
|
||||
IAlleleFlowerSpecies alleleFrist;
|
||||
IAlleleFlowerSpecies alleleSecond;
|
||||
IFlowerGenome genome0;
|
||||
IFlowerGenome genome2;
|
||||
if (world.rand.nextBoolean()) {
|
||||
allele0 = (IAlleleFlowerSpecies) parent1[EnumTreeChromosome.SPECIES.ordinal()].getPrimaryAllele();
|
||||
allele2 = (IAlleleFlowerSpecies) parent2[EnumTreeChromosome.SPECIES.ordinal()].getSecondaryAllele();
|
||||
genome0 = genomeOne;
|
||||
genome2 = genomeTwo;
|
||||
alleleFrist = (IAlleleFlowerSpecies) parentFirst[EnumTreeChromosome.SPECIES.ordinal()].getPrimaryAllele();
|
||||
alleleSecond = (IAlleleFlowerSpecies) parentSecond[EnumTreeChromosome.SPECIES.ordinal()].getSecondaryAllele();
|
||||
genome0 = genomeFirst;
|
||||
genome2 = genomeSecond;
|
||||
} else {
|
||||
allele0 = (IAlleleFlowerSpecies) parent2[EnumTreeChromosome.SPECIES.ordinal()].getPrimaryAllele();
|
||||
allele2 = (IAlleleFlowerSpecies) parent1[EnumTreeChromosome.SPECIES.ordinal()].getSecondaryAllele();
|
||||
genome0 = genomeTwo;
|
||||
genome2 = genomeOne;
|
||||
alleleFrist = (IAlleleFlowerSpecies) parentSecond[EnumTreeChromosome.SPECIES.ordinal()].getPrimaryAllele();
|
||||
alleleSecond = (IAlleleFlowerSpecies) parentFirst[EnumTreeChromosome.SPECIES.ordinal()].getSecondaryAllele();
|
||||
genome0 = genomeSecond;
|
||||
genome2 = genomeFirst;
|
||||
}
|
||||
IFlowerColour colour1 = genome0.getPrimaryColor();
|
||||
IFlowerColour colour2 = genome2.getPrimaryColor();
|
||||
if (colour1 != colour2) {
|
||||
IFlowerColour colourFirst = genome0.getPrimaryColor();
|
||||
IFlowerColour colourSecond = genome2.getPrimaryColor();
|
||||
if (colourFirst != colourSecond) {
|
||||
for (final IColourMix mutation : BotanyCore.getFlowerRoot().getColourMixes(true)) {
|
||||
if (mutation.isMutation(colour1, colour2) && world.rand.nextFloat() * 100.0f < mutation.getChance()) {
|
||||
parent1[EnumFlowerChromosome.PRIMARY.ordinal()] = new Chromosome(mutation.getResult().getAllele());
|
||||
if (mutation.isMutation(colourFirst, colourSecond) && world.rand.nextFloat() * 100.0f < mutation.getChance()) {
|
||||
parentFirst[EnumFlowerChromosome.PRIMARY.ordinal()] = new Chromosome(mutation.getResult().getAllele());
|
||||
}
|
||||
}
|
||||
}
|
||||
colour1 = genome0.getSecondaryColor();
|
||||
colour2 = genome2.getSecondaryColor();
|
||||
if (colour1 != colour2) {
|
||||
colourFirst = genome0.getSecondaryColor();
|
||||
colourSecond = genome2.getSecondaryColor();
|
||||
if (colourFirst != colourSecond) {
|
||||
for (final IColourMix mutation : BotanyCore.getFlowerRoot().getColourMixes(true)) {
|
||||
if (mutation.isMutation(colour1, colour2) && world.rand.nextFloat() * 100.0f < mutation.getChance()) {
|
||||
parent1[EnumFlowerChromosome.SECONDARY.ordinal()] = new Chromosome(mutation.getResult().getAllele());
|
||||
if (mutation.isMutation(colourFirst, colourSecond) && world.rand.nextFloat() * 100.0f < mutation.getChance()) {
|
||||
parentFirst[EnumFlowerChromosome.SECONDARY.ordinal()] = new Chromosome(mutation.getResult().getAllele());
|
||||
}
|
||||
}
|
||||
}
|
||||
colour1 = genome0.getStemColor();
|
||||
colour2 = genome2.getStemColor();
|
||||
if (colour1 != colour2) {
|
||||
colourFirst = genome0.getStemColor();
|
||||
colourSecond = genome2.getStemColor();
|
||||
if (colourFirst != colourSecond) {
|
||||
for (final IColourMix mutation : BotanyCore.getFlowerRoot().getColourMixes(true)) {
|
||||
if (mutation.isMutation(colour1, colour2) && world.rand.nextFloat() * 100.0f < mutation.getChance()) {
|
||||
parent1[EnumFlowerChromosome.STEM.ordinal()] = new Chromosome(mutation.getResult().getAllele());
|
||||
if (mutation.isMutation(colourFirst, colourSecond) && world.rand.nextFloat() * 100.0f < mutation.getChance()) {
|
||||
parentFirst[EnumFlowerChromosome.STEM.ordinal()] = new Chromosome(mutation.getResult().getAllele());
|
||||
}
|
||||
}
|
||||
}
|
||||
IChromosome[] template = null;
|
||||
for (final IFlowerMutation mutation2 : BotanyCore.getFlowerRoot().getMutations(true)) {
|
||||
final float chance = mutation2.getChance(world, pos, allele0, allele2, genome0, genome2);
|
||||
final float chance = mutation2.getChance(world, pos, alleleFrist, alleleSecond, genome0, genome2);
|
||||
if (chance > 0.0f && world.rand.nextFloat() * 100.0f < chance && template == null) {
|
||||
template = BotanyCore.getFlowerRoot().templateAsChromosomes(mutation2.getTemplate());
|
||||
}
|
||||
}
|
||||
if (template != null) {
|
||||
parent1 = template;
|
||||
parentFirst = template;
|
||||
}
|
||||
return parent1;
|
||||
return parentFirst;
|
||||
}
|
||||
}
|
||||
@@ -30,9 +30,11 @@ public class BinnieModProxy implements IBinnieModProxy {
|
||||
return GameRegistry.register(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerModels() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerItemAndBlockColors() {
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user