mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-27 15:33:12 +00:00
Fix tolerance allele
This commit is contained in:
1 parent
8f8e497f58
commit
2b54db9342
17 files changed
+161
-162
No files matched your search
@@ -20,8 +20,8 @@ import binnie.botany.api.EnumFlowerStage;
|
||||
import binnie.botany.api.IBotanistTracker;
|
||||
import binnie.botany.core.BotanyCore;
|
||||
import binnie.core.genetics.BreedingSystem;
|
||||
import binnie.core.genetics.EnumTolerance;
|
||||
import binnie.core.genetics.ForestryAllele;
|
||||
import binnie.core.genetics.Tolerance;
|
||||
import binnie.core.util.I18N;
|
||||
|
||||
public class FlowerBreedingSystem extends BreedingSystem {
|
||||
@@ -108,7 +108,7 @@ public class FlowerBreedingSystem extends BreedingSystem {
|
||||
case HUMIDITY_TOLERANCE:
|
||||
case PH_TOLERANCE:
|
||||
case TEMPERATURE_TOLERANCE:
|
||||
for (Tolerance a3 : Tolerance.values()) {
|
||||
for (EnumTolerance a3 : EnumTolerance.values()) {
|
||||
alleles.add(a3.getAllele());
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -109,7 +109,7 @@ class BeeBreedingSystem extends BreedingSystem {
|
||||
}
|
||||
case HUMIDITY_TOLERANCE:
|
||||
case TEMPERATURE_TOLERANCE: {
|
||||
for (final Tolerance a3 : Tolerance.values()) {
|
||||
for (final EnumTolerance a3 : EnumTolerance.values()) {
|
||||
alleles.add(a3.getAllele());
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
package binnie.core.genetics;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import org.apache.commons.lang3.text.WordUtils;
|
||||
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IAllele;
|
||||
|
||||
public enum EnumTolerance {
|
||||
NONE(0, 0),
|
||||
BOTH_1(-1, 1), BOTH_2(-2, 2), BOTH_3(-3, 3), BOTH_4(-4, 4), BOTH_5(-5, 5),
|
||||
UP_1(0, 1), UP_2(0, 2), UP_3(0, 3), UP_4(0, 4), UP_5(0, 5),
|
||||
DOWN_1(-1, 0), DOWN_2(-2, 0), DOWN_3(-3, 0), DOWN_4(-4, 0), DOWN_5(-5, 0);
|
||||
|
||||
private final int[] bounds;
|
||||
private final String uid;
|
||||
|
||||
EnumTolerance(final int a, final int b) {
|
||||
this.bounds = new int[]{a, b};
|
||||
this.uid = "forestry.tolerance" + WordUtils.capitalize(this.toString());
|
||||
}
|
||||
|
||||
public static EnumTolerance get(final forestry.api.genetics.EnumTolerance tol) {
|
||||
return values()[tol.ordinal()];
|
||||
}
|
||||
|
||||
public static <T extends Enum<T>> boolean canTolerate(final T base, final T test, final forestry.api.genetics.EnumTolerance tol) {
|
||||
return get(tol).canTolerate(base, test);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return super.toString().toLowerCase(Locale.ENGLISH).replace("_", "");
|
||||
}
|
||||
|
||||
public String getUID() {
|
||||
return uid;
|
||||
}
|
||||
|
||||
public int[] getBounds() {
|
||||
return this.bounds;
|
||||
}
|
||||
|
||||
public IAllele getAllele() {
|
||||
return AlleleManager.alleleRegistry.getAllele(this.getUID());
|
||||
}
|
||||
|
||||
public <T extends Enum<T>> boolean canTolerate(final T base, final T test) {
|
||||
return test.ordinal() <= base.ordinal() + this.bounds[1] && test.ordinal() >= base.ordinal() + this.bounds[0];
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,6 @@ import forestry.api.apiculture.IBeeRoot;
|
||||
import forestry.api.arboriculture.ITreeRoot;
|
||||
import forestry.api.arboriculture.TreeManager;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.EnumTolerance;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IAlleleFloat;
|
||||
import forestry.api.genetics.IAlleleInteger;
|
||||
@@ -119,12 +118,12 @@ public class ManagerGenetics extends ManagerBase {
|
||||
return species.getRoot();
|
||||
}
|
||||
|
||||
public IAllele getToleranceAllele(final EnumTolerance tol) {
|
||||
return AlleleManager.alleleRegistry.getAllele(Tolerance.values()[tol.ordinal()].getUID());
|
||||
public IAllele getToleranceAllele(final forestry.api.genetics.EnumTolerance tol) {
|
||||
return AlleleManager.alleleRegistry.getAllele(EnumTolerance.values()[tol.ordinal()].getUID());
|
||||
}
|
||||
|
||||
public int[] getTolerance(final EnumTolerance tol) {
|
||||
return Tolerance.values()[tol.ordinal()].getBounds();
|
||||
public int[] getTolerance(final forestry.api.genetics.EnumTolerance tol) {
|
||||
return EnumTolerance.values()[tol.ordinal()].getBounds();
|
||||
}
|
||||
|
||||
public Collection<BreedingSystem> getActiveSystems() {
|
||||
|
||||
@@ -138,8 +138,8 @@ class MothBreedingSystem extends BreedingSystem {
|
||||
}
|
||||
case HUMIDITY_TOLERANCE:
|
||||
case TEMPERATURE_TOLERANCE: {
|
||||
for (final Tolerance a6 : Tolerance.values()) {
|
||||
alleles.add(a6.getAllele());
|
||||
for (EnumTolerance tolerance : EnumTolerance.values()) {
|
||||
alleles.add(tolerance.getAllele());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
package binnie.core.genetics;
|
||||
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.EnumTolerance;
|
||||
import forestry.api.genetics.IAllele;
|
||||
|
||||
public enum Tolerance {
|
||||
NONE(0, 0),
|
||||
BOTH_1(-1, 1),
|
||||
BOTH_2(-2, 2),
|
||||
BOTH_3(-3, 3),
|
||||
BOTH_4(-4, 4),
|
||||
BOTH_5(-5, 5),
|
||||
UP_1(0, 1),
|
||||
UP_2(0, 2),
|
||||
UP_3(0, 3),
|
||||
UP_4(0, 4),
|
||||
UP_5(0, 5),
|
||||
DOWN_1(-1, 0),
|
||||
DOWN_2(-2, 0),
|
||||
DOWN_3(-3, 0),
|
||||
DOWN_4(-4, 0),
|
||||
DOWN_5(-5, 0);
|
||||
|
||||
private int[] bounds;
|
||||
|
||||
Tolerance(final int a, final int b) {
|
||||
this.bounds = new int[]{a, b};
|
||||
}
|
||||
|
||||
public static Tolerance get(final EnumTolerance tol) {
|
||||
return values()[tol.ordinal()];
|
||||
}
|
||||
|
||||
public static <T extends Enum<T>> boolean canTolerate(final T base, final T test, final EnumTolerance tol) {
|
||||
return get(tol).canTolerate(base, test);
|
||||
}
|
||||
|
||||
public String getUID() {
|
||||
return "forestry.tolerance" + this.toString();
|
||||
}
|
||||
|
||||
public int[] getBounds() {
|
||||
return this.bounds;
|
||||
}
|
||||
|
||||
public IAllele getAllele() {
|
||||
return AlleleManager.alleleRegistry.getAllele(this.getUID());
|
||||
}
|
||||
|
||||
public <T extends Enum<T>> boolean canTolerate(final T base, final T test) {
|
||||
return test.ordinal() <= base.ordinal() + this.bounds[1] && test.ordinal() >= base.ordinal() + this.bounds[0];
|
||||
}
|
||||
}
|
||||
@@ -1,35 +1,39 @@
|
||||
package binnie.core.gui.minecraft;
|
||||
|
||||
public enum EnumColor {
|
||||
Black("Black", 0, '0'),
|
||||
DarkBlue("Dark Blue", 170, '1'),
|
||||
DarkGreen("Dark Green", 43520, '2'),
|
||||
DarkAqua("Dark Aqua", 43690, '3'),
|
||||
DarkRed("Dark Red", 11141120, '4'),
|
||||
Purple("Purple", 11141290, '5'),
|
||||
Gold("Gold", 16755200, '6'),
|
||||
Grey("Grey", 11184810, '7'),
|
||||
DarkGrey("Dark Grey", 5592405, '8'),
|
||||
Blue("Blue", 5592575, '9'),
|
||||
Green("Green", 5635925, 'a'),
|
||||
Aqua("Aqua", 5636095, 'b'),
|
||||
Red("Red", 16733525, 'c'),
|
||||
Pink("Pink", 16733695, 'd'),
|
||||
Yellow("Yellow", 16777045, 'e'),
|
||||
White("White", 16777215, 'f');
|
||||
BLACK("Black", 0, '0'),
|
||||
DARK_BLUE("Dark Blue", 170, '1'),
|
||||
DARK_GREEN("Dark Green", 43520, '2'),
|
||||
DARK_AQUA("Dark Aqua", 43690, '3'),
|
||||
DARK_RED("Dark Red", 11141120, '4'),
|
||||
PURPLE("Purple", 11141290, '5'),
|
||||
GOLD("Gold", 16755200, '6'),
|
||||
GREY("Grey", 11184810, '7'),
|
||||
DARK_GREY("Dark Grey", 5592405, '8'),
|
||||
BLUE("Blue", 5592575, '9'),
|
||||
GREEN("Green", 5635925, 'a'),
|
||||
AQUA("Aqua", 5636095, 'b'),
|
||||
RED("Red", 16733525, 'c'),
|
||||
PINK("Pink", 16733695, 'd'),
|
||||
YELLOW("Yellow", 16777045, 'e'),
|
||||
WHITE("White", 16777215, 'f');
|
||||
|
||||
int colour;
|
||||
int color;
|
||||
String name;
|
||||
char code;
|
||||
|
||||
EnumColor(final String name, final int colour, final char code) {
|
||||
EnumColor(final String name, int color, final char code) {
|
||||
this.name = name;
|
||||
this.colour = colour;
|
||||
this.color = color;
|
||||
this.code = code;
|
||||
System.out.print(name() + "(\"" + name + "\n,"+ Integer.toHexString(color) + ",\'" + code + "\'),\n");
|
||||
if(color == 16777215){
|
||||
getClass();
|
||||
}
|
||||
}
|
||||
|
||||
public int getColour() {
|
||||
return this.colour;
|
||||
public int getColor() {
|
||||
return this.color;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
|
||||
@@ -8,6 +8,8 @@ import java.util.List;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.RenderItem;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.VertexBuffer;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
@@ -45,14 +47,15 @@ public class RenderUtil {
|
||||
GlStateManager.pushAttrib();
|
||||
Preconditions.checkNotNull(itemStack);
|
||||
Minecraft minecraft = Minecraft.getMinecraft();
|
||||
net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting();
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
RenderItem renderItem = minecraft.getRenderItem();
|
||||
FontRenderer font = getFontRenderer(minecraft, itemStack);
|
||||
|
||||
if (rotating) {
|
||||
GlStateManager.pushMatrix();
|
||||
final float phase = Minecraft.getSystemTime() / 20;
|
||||
/** {@link net.minecraft.client.renderer.RenderItem#setupGuiTransform(int, int, boolean)} It adds 100 to zLevel from
|
||||
* {@link net.minecraft.client.renderer.RenderItem#renderItemAndEffectIntoGUI(net.minecraft.entity.EntityLivingBase, net.minecraft.item.ItemStack, int, int)}.
|
||||
/** {@link RenderItem#setupGuiTransform(int, int, boolean)} It adds 100 to zLevel from
|
||||
* {@link RenderItem#renderItemAndEffectIntoGUI(net.minecraft.entity.EntityLivingBase, net.minecraft.item.ItemStack, int, int)}.
|
||||
* So z=150
|
||||
**/
|
||||
GlStateManager.translate(8, 8, 150);
|
||||
@@ -60,13 +63,13 @@ public class RenderUtil {
|
||||
GlStateManager.translate(-8, -8, -150);
|
||||
}
|
||||
|
||||
minecraft.getRenderItem().renderItemAndEffectIntoGUI(null, itemStack, pos.xPos(), pos.yPos());
|
||||
renderItem.renderItemAndEffectIntoGUI(null, itemStack, pos.xPos(), pos.yPos());
|
||||
if (rotating) {
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
minecraft.getRenderItem().renderItemOverlayIntoGUI(font, itemStack, pos.xPos(), pos.yPos(), null);
|
||||
renderItem.renderItemOverlayIntoGUI(font, itemStack, pos.xPos(), pos.yPos(), null);
|
||||
|
||||
net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting();
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GlStateManager.popAttrib();
|
||||
}
|
||||
|
||||
@@ -133,7 +136,7 @@ public class RenderUtil {
|
||||
FontRenderer fontRendererObj = Minecraft.getMinecraft().fontRendererObj;
|
||||
final List<String> wrappedStrings = fontRendererObj.listFormattedStringToWidth(text, area.size().xPos());
|
||||
final float totalHeight = wrappedStrings.size() * getTextHeight();
|
||||
float posY = area.pos().yPos();
|
||||
float posY = pos.yPos();
|
||||
if (area.size().yPos() > totalHeight) {
|
||||
posY += (area.size().yPos() - totalHeight) * justification.getYOffset();
|
||||
}
|
||||
@@ -178,21 +181,21 @@ public class RenderUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static void drawFluid(Point pos, @Nullable FluidStack fluid) {
|
||||
public static void drawFluid(Point pos, @Nullable FluidStack fluidStack) {
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.enableAlpha();
|
||||
|
||||
Minecraft minecraft = Minecraft.getMinecraft();
|
||||
if (fluid != null) {
|
||||
Fluid fluid1 = fluid.getFluid();
|
||||
if (fluid1 != null) {
|
||||
TextureAtlasSprite fluidStillSprite = getStillFluidSprite(minecraft, fluid1);
|
||||
if (fluidStack != null) {
|
||||
Fluid fluid = fluidStack.getFluid();
|
||||
if (fluid != null) {
|
||||
TextureAtlasSprite stillSprite = getStillFluidSprite(minecraft, fluid);
|
||||
|
||||
int fluidColor = fluid1.getColor(fluid);
|
||||
int fluidColor = fluid.getColor(fluidStack);
|
||||
|
||||
minecraft.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
|
||||
setColour(fluidColor);
|
||||
drawTexture(pos.xPos(), pos.yPos(), fluidStillSprite, 0, 0, 100);
|
||||
drawTexture(pos.xPos(), pos.yPos(), stillSprite, 0, 0, 100);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ class CompartmentTab implements INbtWritable, INbtReadable {
|
||||
public CompartmentTab(final int id) {
|
||||
this.name = "";
|
||||
this.icon = new ItemStack(Items.PAPER);
|
||||
this.color = EnumColor.White;
|
||||
this.color = EnumColor.WHITE;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,13 +34,13 @@ class ControlColourSelector extends Control implements ITooltip, IControlValue<E
|
||||
@Override
|
||||
public void setValue(final EnumColor value) {
|
||||
this.value = value;
|
||||
this.setColor(this.getValue().getColour());
|
||||
this.setColor(this.getValue().getColor());
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void onRenderBackground(int guiWidth, int guiHeight) {
|
||||
super.onRenderBackground(guiWidth, guiHeight);
|
||||
RenderUtil.drawGradientRect(this.getArea(), -16777216 + this.value.getColour(), -16777216 + this.value.getColour());
|
||||
RenderUtil.drawGradientRect(this.getArea(), -16777216 + this.value.getColor(), -16777216 + this.value.getColor());
|
||||
}
|
||||
}
|
||||
@@ -123,7 +123,7 @@ public class WindowCompartment extends WindowMachine implements IWindowAffectsSh
|
||||
|
||||
@Override
|
||||
public int getOutlineColour() {
|
||||
return WindowCompartment.this.getTab(this.value).getColor().getColour();
|
||||
return WindowCompartment.this.getTab(this.value).getColor().getColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -160,7 +160,7 @@ public class WindowCompartment extends WindowMachine implements IWindowAffectsSh
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void onRenderForeground(int guiWidth, int guiHeight) {
|
||||
final Texture iTexture = CraftGUI.RENDER.getTexture(CraftGUITexture.TAB_OUTLINE);
|
||||
RenderUtil.setColour(WindowCompartment.this.getTab(WindowCompartment.this.panels.get(this)).getColor().getColour());
|
||||
RenderUtil.setColour(WindowCompartment.this.getTab(WindowCompartment.this.panels.get(this)).getColor().getColor());
|
||||
CraftGUI.RENDER.texture(iTexture, this.getArea().inset(3));
|
||||
}
|
||||
};
|
||||
@@ -189,7 +189,7 @@ public class WindowCompartment extends WindowMachine implements IWindowAffectsSh
|
||||
|
||||
@Override
|
||||
public int getOutlineColour() {
|
||||
return WindowCompartment.this.getTab(this.value).getColor().getColour();
|
||||
return WindowCompartment.this.getTab(this.value).getColor().getColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -257,7 +257,7 @@ public class WindowCompartment extends WindowMachine implements IWindowAffectsSh
|
||||
WindowCompartment.this.sendClientAction("comp-change-tab", nbt);
|
||||
}
|
||||
});
|
||||
this.tabColour = new ControlColourSelector(tabPropertyPanel, 82, y2 - 4, 16, 16, EnumColor.White);
|
||||
this.tabColour = new ControlColourSelector(tabPropertyPanel, 82, y2 - 4, 16, 16, EnumColor.WHITE);
|
||||
this.tabIcon.addHelp("Icon for Current Tab");
|
||||
this.tabIcon.addHelp("Click here with an item to change");
|
||||
y2 += 20;
|
||||
|
||||
@@ -147,12 +147,12 @@ public class AnalystPageMutations extends ControlAnalystPage {
|
||||
RenderUtil.drawItem(Point.ZERO, system.getDefaultMember(mutation.getAllele0().getUID()));
|
||||
RenderUtil.drawItem(new Point(28, 0), system.getDefaultMember(mutation.getAllele1().getUID()));
|
||||
if (specificChance != mutation.getBaseChance()) {
|
||||
RenderUtil.setColour(getMutationColour(mutation.getBaseChance()).getColour());
|
||||
RenderUtil.setColour(getMutationColour(mutation.getBaseChance()).getColor());
|
||||
drawSprite(ModuleItems.iconAdd0);
|
||||
RenderUtil.setColour(getMutationColour(specificChance).getColour());
|
||||
RenderUtil.setColour(getMutationColour(specificChance).getColor());
|
||||
drawSprite(ModuleItems.iconAdd1);
|
||||
} else {
|
||||
RenderUtil.setColour(getMutationColour(mutation.getBaseChance()).getColour());
|
||||
RenderUtil.setColour(getMutationColour(mutation.getBaseChance()).getColor());
|
||||
drawSprite(ModuleItems.iconAdd);
|
||||
}
|
||||
}
|
||||
@@ -205,14 +205,14 @@ public class AnalystPageMutations extends ControlAnalystPage {
|
||||
public void onRenderBackground(int guiWidth, int guiHeight) {
|
||||
RenderUtil.drawItem(Point.ZERO, system.getDefaultMember(speciesComb.getUID()));
|
||||
RenderUtil.drawItem(new Point(28, 0), system.getDefaultMember(mutation.getTemplate()[0].getUID()));
|
||||
RenderUtil.setColour(getMutationColour(mutation.getBaseChance()).getColour());
|
||||
RenderUtil.setColour(getMutationColour(mutation.getBaseChance()).getColor());
|
||||
if (specificChance2 != mutation.getBaseChance()) {
|
||||
RenderUtil.setColour(getMutationColour(mutation.getBaseChance()).getColour());
|
||||
RenderUtil.setColour(getMutationColour(mutation.getBaseChance()).getColor());
|
||||
drawSprite(ModuleItems.iconArrow0);
|
||||
RenderUtil.setColour(getMutationColour(specificChance2).getColour());
|
||||
RenderUtil.setColour(getMutationColour(specificChance2).getColor());
|
||||
drawSprite(ModuleItems.iconArrow1);
|
||||
} else {
|
||||
RenderUtil.setColour(getMutationColour(mutation.getBaseChance()).getColour());
|
||||
RenderUtil.setColour(getMutationColour(mutation.getBaseChance()).getColor());
|
||||
drawSprite(ModuleItems.iconArrow);
|
||||
}
|
||||
}
|
||||
@@ -251,21 +251,21 @@ public class AnalystPageMutations extends ControlAnalystPage {
|
||||
|
||||
protected EnumColor getMutationColour(float percent) {
|
||||
if (percent >= 20.0f) {
|
||||
return EnumColor.DarkGreen;
|
||||
return EnumColor.DARK_GREEN;
|
||||
}
|
||||
if (percent >= 15.0f) {
|
||||
return EnumColor.Green;
|
||||
return EnumColor.GREEN;
|
||||
}
|
||||
if (percent >= 10.0f) {
|
||||
return EnumColor.Yellow;
|
||||
return EnumColor.YELLOW;
|
||||
}
|
||||
if (percent >= 5.0f) {
|
||||
return EnumColor.Gold;
|
||||
return EnumColor.GOLD;
|
||||
}
|
||||
if (percent > 0.0f) {
|
||||
return EnumColor.Red;
|
||||
return EnumColor.RED;
|
||||
}
|
||||
return EnumColor.DarkRed;
|
||||
return EnumColor.DARK_RED;
|
||||
}
|
||||
|
||||
static class ControlUnknownMutation extends Control {
|
||||
|
||||
@@ -8,9 +8,8 @@ import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.genetics.EnumTolerance;
|
||||
|
||||
import binnie.core.genetics.Tolerance;
|
||||
import binnie.core.genetics.EnumTolerance;
|
||||
import binnie.core.gui.Attribute;
|
||||
import binnie.core.gui.ITooltip;
|
||||
import binnie.core.gui.IWidget;
|
||||
@@ -65,9 +64,9 @@ public abstract class ControlToleranceBar<T extends Enum<T>> extends Control imp
|
||||
}
|
||||
}
|
||||
|
||||
public void setValues(T value, EnumTolerance enumTol) {
|
||||
public void setValues(T value, forestry.api.genetics.EnumTolerance enumTol) {
|
||||
tolerated.clear();
|
||||
Tolerance tol = Tolerance.get(enumTol);
|
||||
EnumTolerance tol = EnumTolerance.get(enumTol);
|
||||
for (T full : fullSet) {
|
||||
if (full.ordinal() > value.ordinal() + tol.getBounds()[1]) {
|
||||
continue;
|
||||
|
||||
@@ -7,14 +7,12 @@ import java.util.List;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
|
||||
import forestry.api.genetics.EnumTolerance;
|
||||
|
||||
import binnie.botany.Botany;
|
||||
import binnie.botany.api.EnumAcidity;
|
||||
import binnie.botany.api.EnumMoisture;
|
||||
import binnie.botany.api.IFlower;
|
||||
import binnie.botany.gardening.BlockSoil;
|
||||
import binnie.core.genetics.Tolerance;
|
||||
import binnie.core.genetics.EnumTolerance;
|
||||
import binnie.core.gui.IWidget;
|
||||
import binnie.core.gui.controls.ControlText;
|
||||
import binnie.core.gui.controls.ControlTextCentered;
|
||||
@@ -31,9 +29,9 @@ public class AnalystPageSoil extends ControlAnalystPage {
|
||||
super(parent, area);
|
||||
setColor(6697728);
|
||||
EnumMoisture moisture = flower.getGenome().getPrimary().getMoisture();
|
||||
EnumTolerance moistureTol = flower.getGenome().getToleranceMoisture();
|
||||
forestry.api.genetics.EnumTolerance moistureTol = flower.getGenome().getToleranceMoisture();
|
||||
EnumAcidity pH = flower.getGenome().getPrimary().getPH();
|
||||
EnumTolerance pHTol = flower.getGenome().getTolerancePH();
|
||||
forestry.api.genetics.EnumTolerance pHTol = flower.getGenome().getTolerancePH();
|
||||
int y = 4;
|
||||
new ControlTextCentered(this, y, TextFormatting.UNDERLINE + getTitle()).setColor(getColor());
|
||||
y += 16;
|
||||
@@ -48,9 +46,9 @@ public class AnalystPageSoil extends ControlAnalystPage {
|
||||
new ControlText(this, new Area(4, y, getWidth() - 8, 14), I18N.localise(AnalystConstants.SOIL_KEY + ".recommended"), TextJustification.MIDDLE_CENTER).setColor(getColor());
|
||||
y += 12;
|
||||
EnumMoisture recomMoisture = EnumMoisture.NORMAL;
|
||||
boolean canTolNormal = Tolerance.canTolerate(moisture, EnumMoisture.NORMAL, moistureTol);
|
||||
boolean canTolDamp = Tolerance.canTolerate(moisture, EnumMoisture.DAMP, moistureTol);
|
||||
boolean canTolDry = Tolerance.canTolerate(moisture, EnumMoisture.DRY, moistureTol);
|
||||
boolean canTolNormal = EnumTolerance.canTolerate(moisture, EnumMoisture.NORMAL, moistureTol);
|
||||
boolean canTolDamp = EnumTolerance.canTolerate(moisture, EnumMoisture.DAMP, moistureTol);
|
||||
boolean canTolDry = EnumTolerance.canTolerate(moisture, EnumMoisture.DRY, moistureTol);
|
||||
if (canTolNormal) {
|
||||
if (canTolDamp && !canTolDry) {
|
||||
recomMoisture = EnumMoisture.DAMP;
|
||||
@@ -66,9 +64,9 @@ public class AnalystPageSoil extends ControlAnalystPage {
|
||||
}
|
||||
}
|
||||
EnumAcidity recomPH = EnumAcidity.NEUTRAL;
|
||||
boolean canTolNeutral = Tolerance.canTolerate(pH, EnumAcidity.NEUTRAL, pHTol);
|
||||
boolean canTolAcid = Tolerance.canTolerate(pH, EnumAcidity.ACID, pHTol);
|
||||
boolean canTolAlkaline = Tolerance.canTolerate(pH, EnumAcidity.ALKALINE, pHTol);
|
||||
boolean canTolNeutral = EnumTolerance.canTolerate(pH, EnumAcidity.NEUTRAL, pHTol);
|
||||
boolean canTolAcid = EnumTolerance.canTolerate(pH, EnumAcidity.ACID, pHTol);
|
||||
boolean canTolAlkaline = EnumTolerance.canTolerate(pH, EnumAcidity.ALKALINE, pHTol);
|
||||
if (canTolNeutral) {
|
||||
if (canTolAcid && !canTolAlkaline) {
|
||||
recomPH = EnumAcidity.ACID;
|
||||
@@ -93,7 +91,7 @@ public class AnalystPageSoil extends ControlAnalystPage {
|
||||
List<ItemStack> stacks = new ArrayList<>();
|
||||
for (EnumAcidity a : EnumSet.range(EnumAcidity.ACID, EnumAcidity.ALKALINE)) {
|
||||
for (EnumMoisture b : EnumSet.range(EnumMoisture.DRY, EnumMoisture.DAMP)) {
|
||||
if (Tolerance.canTolerate(pH, a, pHTol) && Tolerance.canTolerate(moisture, b, moistureTol) && (a != recomPH || b != recomMoisture)) {
|
||||
if (EnumTolerance.canTolerate(pH, a, pHTol) && EnumTolerance.canTolerate(moisture, b, moistureTol) && (a != recomPH || b != recomMoisture)) {
|
||||
stacks.add(new ItemStack(Botany.gardening().soil, 1, BlockSoil.getMeta(a, b)));
|
||||
}
|
||||
}
|
||||
@@ -108,7 +106,7 @@ public class AnalystPageSoil extends ControlAnalystPage {
|
||||
}
|
||||
}
|
||||
|
||||
protected void createMoisture(IWidget parent, int x, int y, int w, int h, EnumMoisture value, EnumTolerance tol) {
|
||||
protected void createMoisture(IWidget parent, int x, int y, int w, int h, EnumMoisture value, forestry.api.genetics.EnumTolerance tol) {
|
||||
new ControlToleranceBar<EnumMoisture>(parent, x, y, w, h, EnumMoisture.class) {
|
||||
@Override
|
||||
protected String getName(EnumMoisture value) {
|
||||
@@ -122,7 +120,7 @@ public class AnalystPageSoil extends ControlAnalystPage {
|
||||
}.setValues(value, tol);
|
||||
}
|
||||
|
||||
protected void createAcidity(IWidget parent, int x, int y, int w, int h, EnumAcidity value, EnumTolerance tol) {
|
||||
protected void createAcidity(IWidget parent, int x, int y, int w, int h, EnumAcidity value, forestry.api.genetics.EnumTolerance tol) {
|
||||
new ControlToleranceBar<EnumAcidity>(parent, x, y, w, h, EnumAcidity.class) {
|
||||
@Override
|
||||
protected String getName(EnumAcidity value) {
|
||||
|
||||
@@ -11,7 +11,6 @@ import forestry.api.apiculture.EnumBeeChromosome;
|
||||
import forestry.api.apiculture.IBee;
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.genetics.EnumTolerance;
|
||||
import forestry.api.genetics.IAlleleTolerance;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.lepidopterology.EnumButterflyChromosome;
|
||||
@@ -19,7 +18,7 @@ import forestry.api.lepidopterology.IButterfly;
|
||||
|
||||
import binnie.botany.api.EnumFlowerChromosome;
|
||||
import binnie.botany.api.IFlower;
|
||||
import binnie.core.genetics.Tolerance;
|
||||
import binnie.core.genetics.EnumTolerance;
|
||||
import binnie.core.gui.IWidget;
|
||||
import binnie.core.gui.controls.ControlText;
|
||||
import binnie.core.gui.controls.ControlTextCentered;
|
||||
@@ -37,16 +36,16 @@ public class AnalystPageClimate extends ControlAnalystPage {
|
||||
super(parent, area);
|
||||
setColor(26163);
|
||||
EnumTemperature temp = ind.getGenome().getPrimary().getTemperature();
|
||||
EnumTolerance tempTol = EnumTolerance.NONE;
|
||||
forestry.api.genetics.EnumTolerance tempTol = forestry.api.genetics.EnumTolerance.NONE;
|
||||
EnumHumidity humid = ind.getGenome().getPrimary().getHumidity();
|
||||
EnumTolerance humidTol = EnumTolerance.NONE;
|
||||
forestry.api.genetics.EnumTolerance humidTol = forestry.api.genetics.EnumTolerance.NONE;
|
||||
if (ind instanceof IBee) {
|
||||
tempTol = ((IAlleleTolerance) ind.getGenome().getActiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE)).getValue();
|
||||
humidTol = ((IAlleleTolerance) ind.getGenome().getActiveAllele(EnumBeeChromosome.HUMIDITY_TOLERANCE)).getValue();
|
||||
}
|
||||
if (ind instanceof IFlower) {
|
||||
tempTol = ((IAlleleTolerance) ind.getGenome().getActiveAllele(EnumFlowerChromosome.TEMPERATURE_TOLERANCE)).getValue();
|
||||
humidTol = EnumTolerance.BOTH_5;
|
||||
humidTol = forestry.api.genetics.EnumTolerance.BOTH_5;
|
||||
}
|
||||
if (ind instanceof IButterfly) {
|
||||
tempTol = ((IAlleleTolerance) ind.getGenome().getActiveAllele(EnumButterflyChromosome.TEMPERATURE_TOLERANCE)).getValue();
|
||||
@@ -71,8 +70,8 @@ public class AnalystPageClimate extends ControlAnalystPage {
|
||||
for (Biome biome : Biome.EXPLORATION_BIOMES_LIST) { //TODO check
|
||||
if (biome != null &&
|
||||
biome != Biomes.FROZEN_OCEAN &&
|
||||
Tolerance.canTolerate(temp, EnumTemperature.getFromBiome(biome), tempTol) &&
|
||||
Tolerance.canTolerate(humid, EnumHumidity.getFromValue(biome.getRainfall()), humidTol)) {
|
||||
EnumTolerance.canTolerate(temp, EnumTemperature.getFromBiome(biome), tempTol) &&
|
||||
EnumTolerance.canTolerate(humid, EnumHumidity.getFromValue(biome.getRainfall()), humidTol)) {
|
||||
boolean match = false;
|
||||
for (Biome eBiome : biomes) {
|
||||
if (biome.getBiomeName().contains(eBiome.getBiomeName()) && EnumHumidity.getFromValue(eBiome.getRainfall()) == EnumHumidity.getFromValue(biome.getRainfall()) && EnumTemperature.getFromBiome(eBiome) == EnumTemperature.getFromBiome(biome)) {
|
||||
@@ -99,7 +98,7 @@ public class AnalystPageClimate extends ControlAnalystPage {
|
||||
setSize(new Point(getWidth(), y + dy + 18 + 8));
|
||||
}
|
||||
|
||||
protected void createTemperatureBar(IWidget parent, int x, int y, int w, int h, EnumTemperature value, EnumTolerance tol) {
|
||||
protected void createTemperatureBar(IWidget parent, int x, int y, int w, int h, EnumTemperature value, forestry.api.genetics.EnumTolerance tol) {
|
||||
new ControlToleranceBar<EnumTemperature>(parent, x, y, w, h, EnumTemperature.class) {
|
||||
@Override
|
||||
protected String getName(EnumTemperature value) {
|
||||
@@ -113,7 +112,7 @@ public class AnalystPageClimate extends ControlAnalystPage {
|
||||
}.setValues(value, tol);
|
||||
}
|
||||
|
||||
protected void createHumidity(IWidget parent, int x, int y, int w, int h, EnumHumidity value, EnumTolerance tol) {
|
||||
protected void createHumidity(IWidget parent, int x, int y, int w, int h, EnumHumidity value, forestry.api.genetics.EnumTolerance tol) {
|
||||
new ControlToleranceBar<EnumHumidity>(parent, x, y, w, h, EnumHumidity.class) {
|
||||
@Override
|
||||
protected String getName(EnumHumidity value) {
|
||||
|
||||
@@ -15,7 +15,6 @@ import net.minecraftforge.fluids.FluidRegistry;
|
||||
|
||||
import forestry.api.apiculture.EnumBeeChromosome;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.EnumTolerance;
|
||||
import forestry.api.genetics.IChromosomeType;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import forestry.api.lepidopterology.EnumButterflyChromosome;
|
||||
@@ -23,7 +22,7 @@ import forestry.api.lepidopterology.EnumButterflyChromosome;
|
||||
import binnie.Binnie;
|
||||
import binnie.botany.api.EnumFlowerChromosome;
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.genetics.Tolerance;
|
||||
import binnie.core.genetics.EnumTolerance;
|
||||
import binnie.core.liquid.FluidContainerType;
|
||||
|
||||
public class Acclimatiser {
|
||||
@@ -137,13 +136,13 @@ public class Acclimatiser {
|
||||
return system.alter(stack, acc);
|
||||
}
|
||||
|
||||
public static Tolerance alterTolerance(final Tolerance tol, final float effect) {
|
||||
final int[] is = tol.getBounds();
|
||||
public static EnumTolerance alterTolerance(final EnumTolerance tol, final float effect) {
|
||||
int[] bounds = tol.getBounds();
|
||||
int[] range;
|
||||
if (effect < 0.0f) {
|
||||
range = new int[]{is[0] - 1, is[1]};
|
||||
range = new int[]{bounds[0] - 1, bounds[1]};
|
||||
} else {
|
||||
range = new int[]{is[0], is[1] + 1};
|
||||
range = new int[]{bounds[0], bounds[1] + 1};
|
||||
}
|
||||
if (range[0] < -5) {
|
||||
range[0] = -5;
|
||||
@@ -151,16 +150,16 @@ public class Acclimatiser {
|
||||
if (range[1] > 5) {
|
||||
range[1] = 5;
|
||||
}
|
||||
final EnumTolerance[] up = {EnumTolerance.NONE, EnumTolerance.UP_1, EnumTolerance.UP_2, EnumTolerance.UP_3, EnumTolerance.UP_4, EnumTolerance.UP_5};
|
||||
final EnumTolerance[] down = {EnumTolerance.NONE, EnumTolerance.DOWN_1, EnumTolerance.DOWN_2, EnumTolerance.DOWN_3, EnumTolerance.DOWN_4, EnumTolerance.DOWN_5};
|
||||
final EnumTolerance[] both = {EnumTolerance.NONE, EnumTolerance.BOTH_1, EnumTolerance.BOTH_2, EnumTolerance.BOTH_3, EnumTolerance.BOTH_4, EnumTolerance.BOTH_5};
|
||||
final forestry.api.genetics.EnumTolerance[] up = {forestry.api.genetics.EnumTolerance.NONE, forestry.api.genetics.EnumTolerance.UP_1, forestry.api.genetics.EnumTolerance.UP_2, forestry.api.genetics.EnumTolerance.UP_3, forestry.api.genetics.EnumTolerance.UP_4, forestry.api.genetics.EnumTolerance.UP_5};
|
||||
final forestry.api.genetics.EnumTolerance[] down = {forestry.api.genetics.EnumTolerance.NONE, forestry.api.genetics.EnumTolerance.DOWN_1, forestry.api.genetics.EnumTolerance.DOWN_2, forestry.api.genetics.EnumTolerance.DOWN_3, forestry.api.genetics.EnumTolerance.DOWN_4, forestry.api.genetics.EnumTolerance.DOWN_5};
|
||||
final forestry.api.genetics.EnumTolerance[] both = {forestry.api.genetics.EnumTolerance.NONE, forestry.api.genetics.EnumTolerance.BOTH_1, forestry.api.genetics.EnumTolerance.BOTH_2, forestry.api.genetics.EnumTolerance.BOTH_3, forestry.api.genetics.EnumTolerance.BOTH_4, forestry.api.genetics.EnumTolerance.BOTH_5};
|
||||
if (range[0] == 0) {
|
||||
return Tolerance.get(up[range[1]]);
|
||||
return EnumTolerance.get(up[range[1]]);
|
||||
}
|
||||
if (range[1] == 0) {
|
||||
return Tolerance.get(down[-range[0]]);
|
||||
return EnumTolerance.get(down[-range[0]]);
|
||||
}
|
||||
final int avg = (int) ((-range[0] + range[1]) / 2.0f + 0.6f);
|
||||
return Tolerance.get(both[avg]);
|
||||
return EnumTolerance.get(both[avg]);
|
||||
}
|
||||
}
|
||||
@@ -11,8 +11,8 @@ import forestry.api.genetics.IGenome;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
|
||||
import binnie.core.genetics.EnumTolerance;
|
||||
import binnie.core.genetics.Gene;
|
||||
import binnie.core.genetics.Tolerance;
|
||||
import binnie.genetics.machine.inoculator.Inoculator;
|
||||
|
||||
class ToleranceSystem {
|
||||
@@ -30,7 +30,7 @@ class ToleranceSystem {
|
||||
final IIndividual member = AlleleManager.alleleRegistry.getIndividual(stack);
|
||||
final IGenome genome = member.getGenome();
|
||||
final IAlleleTolerance tolAllele = (IAlleleTolerance) genome.getActiveAllele(this.chromosomeOrdinal);
|
||||
final Tolerance tol = Tolerance.get(tolAllele.getValue());
|
||||
final EnumTolerance tol = EnumTolerance.get(tolAllele.getValue());
|
||||
final float effect = this.type.getEffect(acclim);
|
||||
return (effect > 0.0f && tol.getBounds()[1] < 5) || (effect < 0.0f && tol.getBounds()[0] > -5);
|
||||
}
|
||||
@@ -44,8 +44,8 @@ class ToleranceSystem {
|
||||
final IIndividual member = AlleleManager.alleleRegistry.getIndividual(stack);
|
||||
final IGenome genome = member.getGenome();
|
||||
final IAlleleTolerance tolAllele = (IAlleleTolerance) genome.getActiveAllele(this.chromosomeOrdinal);
|
||||
final Tolerance tol = Tolerance.get(tolAllele.getValue());
|
||||
final Tolerance newTol = Acclimatiser.alterTolerance(tol, effect);
|
||||
final EnumTolerance tol = EnumTolerance.get(tolAllele.getValue());
|
||||
final EnumTolerance newTol = Acclimatiser.alterTolerance(tol, effect);
|
||||
if (rand.nextFloat() > 1.0f / (-newTol.getBounds()[0] + newTol.getBounds()[1])) {
|
||||
return stack;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user