Convert anonymous inner classes to static inner classes.

Should fix the build issue, which is caused by the bug described here:
https://github.com/MinecraftForge/Srg2Source/pull/17
This commit is contained in:
mezz committed 2017-08-20 23:48:43 -07:00
1 parent de33285994
commit a12e293eed
43 files changed
+1342 -932

No files matched your search

@@ -256,7 +256,7 @@ public class BlockCeramicBrick extends Block implements IMultipassBlock<CeramicB
}
}
private class CeramicBrickMeshDefinition implements ItemMeshDefinition {
private static class CeramicBrickMeshDefinition implements ItemMeshDefinition {
@Override
public ModelResourceLocation getModelLocation(ItemStack stack) {
return new ModelResourceLocation(Constants.BOTANY_MOD_ID + ":ceramicBrick", "inventory");
@@ -147,29 +147,31 @@ public class FlowerBreedingSystem extends BreedingSystem {
@Override
public IFieldKitPlugin getFieldKitPlugin() {
return new IFieldKitPlugin() {
@Override
public Map<IChromosomeType, IPoint> getChromosomePickerPositions() {
Map<IChromosomeType, IPoint> positions = new HashMap<>();
positions.put(EnumFlowerChromosome.SPECIES, new Point(35, 81));
positions.put(EnumFlowerChromosome.PRIMARY, new Point(36, 28));
positions.put(EnumFlowerChromosome.SECONDARY, new Point(27, 13));
positions.put(EnumFlowerChromosome.FERTILITY, new Point(47, 15));
positions.put(EnumFlowerChromosome.TERRITORY, new Point(54, 31));
positions.put(EnumFlowerChromosome.EFFECT, new Point(15, 55));
positions.put(EnumFlowerChromosome.LIFESPAN, new Point(23, 38));
positions.put(EnumFlowerChromosome.TEMPERATURE_TOLERANCE, new Point(17, 77));
positions.put(EnumFlowerChromosome.HUMIDITY_TOLERANCE, new Point(52, 51));
positions.put(EnumFlowerChromosome.PH_TOLERANCE, new Point(54, 80));
positions.put(EnumFlowerChromosome.SAPPINESS, new Point(41, 42));
positions.put(EnumFlowerChromosome.STEM, new Point(37, 63));
return positions;
}
return new FieldKitPlugin();
}
@Override
public ITexture getTypeTexture() {
return new StandardTexture(0, 96, 96, 96, BinnieCoreTexture.GUI_BREEDING);
}
};
private static class FieldKitPlugin implements IFieldKitPlugin {
@Override
public Map<IChromosomeType, IPoint> getChromosomePickerPositions() {
Map<IChromosomeType, IPoint> positions = new HashMap<>();
positions.put(EnumFlowerChromosome.SPECIES, new Point(35, 81));
positions.put(EnumFlowerChromosome.PRIMARY, new Point(36, 28));
positions.put(EnumFlowerChromosome.SECONDARY, new Point(27, 13));
positions.put(EnumFlowerChromosome.FERTILITY, new Point(47, 15));
positions.put(EnumFlowerChromosome.TERRITORY, new Point(54, 31));
positions.put(EnumFlowerChromosome.EFFECT, new Point(15, 55));
positions.put(EnumFlowerChromosome.LIFESPAN, new Point(23, 38));
positions.put(EnumFlowerChromosome.TEMPERATURE_TOLERANCE, new Point(17, 77));
positions.put(EnumFlowerChromosome.HUMIDITY_TOLERANCE, new Point(52, 51));
positions.put(EnumFlowerChromosome.PH_TOLERANCE, new Point(54, 80));
positions.put(EnumFlowerChromosome.SAPPINESS, new Point(41, 42));
positions.put(EnumFlowerChromosome.STEM, new Point(37, 63));
return positions;
}
@Override
public ITexture getTypeTexture() {
return new StandardTexture(0, 96, 96, 96, BinnieCoreTexture.GUI_BREEDING);
}
}
}
@@ -24,6 +24,7 @@ import binnie.core.gui.renderer.RenderUtil;
import binnie.core.util.I18N;
import binnie.genetics.api.analyst.AnalystConstants;
@SideOnly(Side.CLIENT)
public class AnalystPageAppearance extends Control implements ITitledWidget {
public AnalystPageAppearance(IWidget parent, IArea area, IFlower flower) {
super(parent, area);
@@ -43,36 +44,51 @@ public class AnalystPageAppearance extends Control implements ITitledWidget {
IFlowerType type = genome.getType();
int sections = type.getSections();
int width = (sections > 1) ? 50 : 100;
new ControlIconDisplay(this, (getWidth() - width) / 2, y - ((sections == 1) ? 0 : 0)) {
@Override
@SideOnly(Side.CLIENT)
public void onRenderForeground(int guiWidth, int guiHeight) {
GlStateManager.pushMatrix();
float scale = width / 16.0f;
int dy = (sections > 1) ? 16 : 0;
GlStateManager.scale(scale, scale, 1.0f);
RenderUtil.setColour(flower.getGenome().getStemColor().getColor(false));
if (sections > 1) {
RenderUtil.drawSprite(Point.ZERO, FlowerSpriteManager.getStem(type, 1, true));
}
RenderUtil.drawSprite(new Point(0, dy), FlowerSpriteManager.getStem(type, 0, true));
RenderUtil.setColour(flower.getGenome().getPrimaryColor().getColor(false));
if (sections > 1) {
RenderUtil.drawSprite(Point.ZERO, FlowerSpriteManager.getPetal(type, 1, true));
}
RenderUtil.drawSprite(new Point(0, dy), FlowerSpriteManager.getPetal(type, 0, true));
RenderUtil.setColour(flower.getGenome().getSecondaryColor().getColor(false));
if (sections > 1) {
RenderUtil.drawSprite(Point.ZERO, FlowerSpriteManager.getVariant(type, 1, true));
}
RenderUtil.drawSprite(new Point(0, dy), FlowerSpriteManager.getVariant(type, 0, true));
GlStateManager.popMatrix();
}
};
new FlowerIconDisplay(this, width, y, sections, flower, type);
}
@Override
public String getTitle() {
return I18N.localise(AnalystConstants.APPEARANCE_KEY + ".title");
}
private static class FlowerIconDisplay extends ControlIconDisplay {
private final int width;
private final int sections;
private final IFlower flower;
private final IFlowerType type;
public FlowerIconDisplay(AnalystPageAppearance analystPageAppearance, int width, int y, int sections, IFlower flower, IFlowerType type) {
super(analystPageAppearance, (analystPageAppearance.getWidth() - width) / 2, y - ((sections == 1) ? 0 : 0));
this.width = width;
this.sections = sections;
this.flower = flower;
this.type = type;
}
@Override
@SideOnly(Side.CLIENT)
public void onRenderForeground(int guiWidth, int guiHeight) {
GlStateManager.pushMatrix();
float scale = width / 16.0f;
int dy = (sections > 1) ? 16 : 0;
GlStateManager.scale(scale, scale, 1.0f);
RenderUtil.setColour(flower.getGenome().getStemColor().getColor(false));
if (sections > 1) {
RenderUtil.drawSprite(Point.ZERO, FlowerSpriteManager.getStem(type, 1, true));
}
RenderUtil.drawSprite(new Point(0, dy), FlowerSpriteManager.getStem(type, 0, true));
RenderUtil.setColour(flower.getGenome().getPrimaryColor().getColor(false));
if (sections > 1) {
RenderUtil.drawSprite(Point.ZERO, FlowerSpriteManager.getPetal(type, 1, true));
}
RenderUtil.drawSprite(new Point(0, dy), FlowerSpriteManager.getPetal(type, 0, true));
RenderUtil.setColour(flower.getGenome().getSecondaryColor().getColor(false));
if (sections > 1) {
RenderUtil.drawSprite(Point.ZERO, FlowerSpriteManager.getVariant(type, 1, true));
}
RenderUtil.drawSprite(new Point(0, dy), FlowerSpriteManager.getVariant(type, 0, true));
GlStateManager.popMatrix();
}
}
}
@@ -108,35 +108,47 @@ public class AnalystPageSoil extends Control implements ITitledWidget {
}
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) {
return value.getLocalisedName(false);
}
@Override
protected int getColour(EnumMoisture value) {
return (new int[]{13434828, 6737151, 3368703})[value.ordinal()];
}
}.setValues(value, tol);
new MoistureBar(parent, x, y, w, h).setValues(value, 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) {
return value.getLocalisedName(false);
}
@Override
protected int getColour(EnumAcidity value) {
return (new int[]{16711782, 65280, 26367})[value.ordinal()];
}
}.setValues(value, tol);
new AcidityBar(parent, x, y, w, h).setValues(value, tol);
}
@Override
public String getTitle() {
return I18N.localise(AnalystConstants.SOIL_KEY + ".title");
}
private static class MoistureBar extends ControlToleranceBar<EnumMoisture> {
public MoistureBar(IWidget parent, int x, int y, int w, int h) {
super(parent, x, y, w, h, EnumMoisture.class);
}
@Override
protected String getName(EnumMoisture value) {
return value.getLocalisedName(false);
}
@Override
protected int getColour(EnumMoisture value) {
return (new int[]{13434828, 6737151, 3368703})[value.ordinal()];
}
}
private static class AcidityBar extends ControlToleranceBar<EnumAcidity> {
public AcidityBar(IWidget parent, int x, int y, int w, int h) {
super(parent, x, y, w, h, EnumAcidity.class);
}
@Override
protected String getName(EnumAcidity value) {
return value.getLocalisedName(false);
}
@Override
protected int getColour(EnumAcidity value) {
return (new int[]{16711782, 65280, 26367})[value.ordinal()];
}
}
}
@@ -49,7 +49,7 @@ public class WindowBotanistDatabase extends WindowAbstractDatabase {
new PageSpeciesMutations(getInfoPages(Mode.SPECIES), new DatabaseTab(Botany.instance, "species.further"));
new PageBranchOverview(getInfoPages(Mode.BRANCHES), new DatabaseTab(Botany.instance, "branches.overview"));
new PageBranchSpecies(getInfoPages(Mode.BRANCHES), new DatabaseTab(Botany.instance, "branches.species"));
createMode(FlowerMode.Color, new FlowerColorModeWidgets());
createMode(FlowerMode.Color, new FlowerColorModeWidgets(this));
new PageColorMixResultant(getInfoPages(FlowerMode.Color), new DatabaseTab(Botany.instance, "color.resultant"));
new PageColorMix(getInfoPages(FlowerMode.Color), new DatabaseTab(Botany.instance, "color.further"));
new PageBreeder(getInfoPages(Mode.BREEDER), getUsername(), new DatabaseTab(Botany.instance, "breeder"));
@@ -75,22 +75,29 @@ public class WindowBotanistDatabase extends WindowAbstractDatabase {
}
@SideOnly(Side.CLIENT)
private class FlowerColorModeWidgets extends ModeWidgets {
public FlowerColorModeWidgets() {
super(FlowerMode.Color, WindowBotanistDatabase.this);
private static class FlowerColorModeWidgets extends ModeWidgets {
public FlowerColorModeWidgets(WindowBotanistDatabase windowBotanistDatabase) {
super(FlowerMode.Color, windowBotanistDatabase);
}
@Override
public void createListBox(IArea area) {
listBox = new ControlListBox<IFlowerColor>(modePage, area.xPos(), area.yPos(), area.width(), area.height(), 12) {
@Override
public IWidget createOption(IFlowerColor value, int y) {
return new ControlColorOption(getContent(), value, y);
}
};
listBox = new FlowerColorControlListBox(this, area);
List<IFlowerColor> colors = Arrays.stream(EnumFlowerColor.values()).map(EnumFlowerColor::getFlowerColorAllele).collect(Collectors.toList());
listBox.setOptions(colors);
}
private static class FlowerColorControlListBox extends ControlListBox<IFlowerColor> {
public FlowerColorControlListBox(FlowerColorModeWidgets flowerColorModeWidgets, IArea area) {
super(flowerColorModeWidgets.modePage, area.xPos(), area.yPos(), area.width(), area.height(), 12);
}
@Override
public IWidget createOption(IFlowerColor value, int y) {
return new ControlColorOption(getContent(), value, y);
}
}
}
}
@@ -134,17 +134,7 @@ public abstract class WindowAbstractDatabase extends Window {
this.createMode(Mode.BRANCHES, new BranchesModeWidgets());
this.createMode(Mode.BREEDER, new BreederModeWidgets());
this.addTabs();
final ControlTabBar<IDatabaseMode> tab = new ControlTabBar<IDatabaseMode>(this, 176 + this.selectionBoxWidth, 24, 22, 176, Alignment.RIGHT, this.modePages.getValues()) {
@Override
public ControlTab<IDatabaseMode> createTab(final int x, final int y, final int w, final int h, final IDatabaseMode value) {
return new ControlTab<IDatabaseMode>(this, x, y, w, h, value) {
@Override
public String getName() {
return this.value.getName();
}
};
}
};
final ControlTabBar<IDatabaseMode> tab = new DatabaseTabBar(this);
CraftGUIUtil.linkWidgets(tab, this.modePages);
this.changeMode(Mode.SPECIES);
for (final IDatabaseMode mode : this.modes.keySet()) {
@@ -262,4 +252,26 @@ public abstract class WindowAbstractDatabase extends Window {
this.listBox = new ControlListBox(this.modePage, area.xPos(), area.yPos(), area.width(), area.height(), 12);
}
}
private static class DatabaseTabBar extends ControlTabBar<IDatabaseMode> {
public DatabaseTabBar(WindowAbstractDatabase windowAbstractDatabase) {
super(windowAbstractDatabase, 176 + windowAbstractDatabase.selectionBoxWidth, 24, 22, 176, Alignment.RIGHT, windowAbstractDatabase.modePages.getValues());
}
@Override
public ControlTab<IDatabaseMode> createTab(final int x, final int y, final int w, final int h, final IDatabaseMode value) {
return new DatabaseTab(this, x, y, w, h, value);
}
private static class DatabaseTab extends ControlTab<IDatabaseMode> {
public DatabaseTab(DatabaseTabBar databaseTabBar, int x, int y, int w, int h, IDatabaseMode value) {
super(databaseTabBar, x, y, w, h, value);
}
@Override
public String getName() {
return this.value.getName();
}
}
}
}
@@ -71,52 +71,15 @@ public class WindowGenesis extends Window {
public void initialiseClient() {
new ControlPlayerInventory(this);
this.setTitle(I18N.localise("binniecore.gui.genesis.title"));
final ControlTabBar<IBreedingSystem> tabSystems = new ControlTabBar<IBreedingSystem>(this, 8, 28, 23, 100, Alignment.LEFT, Binnie.GENETICS.getActiveSystems()) {
@Override
public ControlTab<IBreedingSystem> createTab(final int x, final int y, final int w, final int h, final IBreedingSystem value) {
return new ControlTabIcon<IBreedingSystem>(this, x, y, w, h, value) {
@Override
public ItemStack getItemStack() {
final ISpeciesType type = this.value.getDefaultType();
final IIndividual ind = this.value.getDefaultIndividual();
return this.value.getSpeciesRoot().getMemberStack(ind, type);
}
@Override
public String getName() {
return this.value.getName();
}
@Override
public int getOutlineColour() {
return this.value.getColour();
}
@Override
public boolean hasOutline() {
return true;
}
};
}
};
final ControlTabBar<IBreedingSystem> tabSystems = new GenesisTabSystems(this);
this.root = Binnie.GENETICS.getActiveSystems().iterator().next().getSpeciesRoot();
this.template = this.root.getDefaultTemplate();
final Area one = new Area(32, 28, 170, 100);
final Area two = new Area(214, 28, 100, 100);
new Panel(this, one.outset(1), MinecraftGUI.PanelType.BLACK);
new Panel(this, two.outset(1), MinecraftGUI.PanelType.BLACK);
this.geneList = new ControlListBox<Gene>(this, one.xPos(), one.yPos(), one.width(), one.height(), 10) {
@Override
public IWidget createOption(final Gene value, final int y) {
return new ControlGenesisOption(this.getContent(), value, y);
}
};
this.geneOptions = new ControlListBox<Gene>(this, two.xPos(), two.yPos(), two.width(), two.height(), 10) {
@Override
public IWidget createOption(final Gene value, final int y) {
return new ControlTextOption<>(this.getContent(), value, y);
}
};
this.geneList = new GeneList(this, one);
this.geneOptions = new GeneOptions(this, two);
tabSystems.addEventHandler(EventValueChanged.class, EventHandlerOrigin.SELF, tabSystems, event -> {
Object value = event.getValue();
if (!(value instanceof BreedingSystem)) {
@@ -227,4 +190,65 @@ public class WindowGenesis extends Window {
}
}
}
private static class GenesisTabSystems extends ControlTabBar<IBreedingSystem> {
public GenesisTabSystems(WindowGenesis windowGenesis) {
super(windowGenesis, 8, 28, 23, 100, Alignment.LEFT, Binnie.GENETICS.getActiveSystems());
}
@Override
public ControlTab<IBreedingSystem> createTab(final int x, final int y, final int w, final int h, final IBreedingSystem value) {
return new GenesisTabIcon(this, x, y, w, h, value);
}
private static class GenesisTabIcon extends ControlTabIcon<IBreedingSystem> {
public GenesisTabIcon(GenesisTabSystems genesisTabSystems, int x, int y, int w, int h, IBreedingSystem value) {
super(genesisTabSystems, x, y, w, h, value);
}
@Override
public ItemStack getItemStack() {
final ISpeciesType type = this.value.getDefaultType();
final IIndividual ind = this.value.getDefaultIndividual();
return this.value.getSpeciesRoot().getMemberStack(ind, type);
}
@Override
public String getName() {
return this.value.getName();
}
@Override
public int getOutlineColour() {
return this.value.getColour();
}
@Override
public boolean hasOutline() {
return true;
}
}
}
private static class GeneList extends ControlListBox<Gene> {
public GeneList(WindowGenesis windowGenesis, Area one) {
super(windowGenesis, one.xPos(), one.yPos(), one.width(), one.height(), 10);
}
@Override
public IWidget createOption(final Gene value, final int y) {
return new ControlGenesisOption(this.getContent(), value, y);
}
}
private static class GeneOptions extends ControlListBox<Gene> {
public GeneOptions(WindowGenesis windowGenesis, Area two) {
super(windowGenesis, two.xPos(), two.yPos(), two.width(), two.height(), 10);
}
@Override
public IWidget createOption(final Gene value, final int y) {
return new ControlTextOption<>(this.getContent(), value, y);
}
}
}
@@ -154,13 +154,7 @@ public abstract class Window extends TopLevelWidget implements INetwork.ReceiveG
protected abstract String getBackgroundTextureName();
public IBinnieTexture getBackgroundTextureFile(final int i) {
return new IBinnieTexture() {
@Override
@SideOnly(Side.CLIENT)
public BinnieResource getTexture() {
return Binnie.RESOURCE.getPNG(getModId(), ResourceType.GUI, getBackgroundTextureName() + ((i == 1) ? "" : i));
}
};
return new BackgroundTexture(this, i);
}
public boolean showHelpButton() {
@@ -321,4 +315,20 @@ public abstract class Window extends TopLevelWidget implements INetwork.ReceiveG
public Texture getBackground2() {
return this.bgText2;
}
private static class BackgroundTexture implements IBinnieTexture {
private final int i;
private Window window;
public BackgroundTexture(Window window, int i) {
this.i = i;
this.window = window;
}
@Override
@SideOnly(Side.CLIENT)
public BinnieResource getTexture() {
return Binnie.RESOURCE.getPNG(window.getModId(), ResourceType.GUI, window.getBackgroundTextureName() + ((i == 1) ? "" : i));
}
}
}
@@ -52,14 +52,12 @@ public class ComponentInventoryTransfer extends MachineComponent {
this.transfers.add(transfer);
}
public abstract static class Condition {
@Nullable
public Transfer transfer;
public abstract boolean fulfilled(final ItemStack p0);
@FunctionalInterface
public interface Condition {
boolean fulfilled(final ItemStack itemStack);
}
public abstract class Transfer {
public abstract static class Transfer {
protected final IMachine machine;
@Nullable
protected Condition condition;
@@ -83,7 +81,7 @@ public class ComponentInventoryTransfer extends MachineComponent {
public final Transfer setCondition(final Condition condition) {
this.condition = condition;
return condition.transfer = this;
return this;
}
public final IMachine getMachine() {
@@ -107,32 +107,7 @@ public class WindowCompartment extends WindowMachine implements IWindowAffectsSh
final int compartmentWidth = compartmentPageWidth + (doubleTabbed ? 48 : 24);
final int compartmentHeight = compartmentPageHeight;
final Control controlCompartment = new Control(this, x, y, compartmentWidth, compartmentHeight);
final ControlTabBar<Integer> tab = new ControlTabBar<Integer>(controlCompartment, 0, 0, 24, compartmentPageHeight, Alignment.LEFT, Arrays.asList(tabs1)) {
@Override
public ControlTab<Integer> createTab(final int x, final int y, final int w, final int h, final Integer value) {
return new ControlTabIcon<Integer>(this, x, y, w, h, value) {
@Override
public ItemStack getItemStack() {
return WindowCompartment.this.getTab(this.value).getIcon();
}
@Override
public String getName() {
return WindowCompartment.this.getTab(this.value).getName();
}
@Override
public int getOutlineColour() {
return WindowCompartment.this.getTab(this.value).getColor().getColor();
}
@Override
public boolean hasOutline() {
return true;
}
};
}
};
final ControlTabBar<Integer> tab = new CompartmentTabBar1(this, controlCompartment, compartmentPageHeight, tabs1);
final String[] tabHelp = {"Compartment Tab", "Tabs that divide the inventory into sections. Each one can be labelled seperately."};
tab.addHelp(tabHelp);
tab.addEventHandler(EventValueChanged.class, EventHandlerOrigin.DIRECT_CHILD, tab, event -> {
@@ -155,15 +130,7 @@ public class WindowCompartment extends WindowMachine implements IWindowAffectsSh
int i = 0;
for (int p2 = 0; p2 < inv.getTabNumber(); ++p2) {
final ControlPage thisPage = page[p2];
final Panel panel = new Panel(thisPage, 0, 0, thisPage.getWidth(), thisPage.getHeight(), MinecraftGUI.PanelType.BLACK) {
@Override
@SideOnly(Side.CLIENT)
public void onRenderForeground(int guiWidth, int guiHeight) {
final ITexture iTexture = CraftGUI.RENDER.getTexture(CraftGUITexture.TAB_OUTLINE);
RenderUtil.setColour(WindowCompartment.this.getTab(WindowCompartment.this.panels.get(this)).getColor().getColor());
CraftGUI.RENDER.texture(iTexture, this.getArea().inset(3));
}
};
final Panel panel = new CompartmentPanel(this, thisPage);
this.panels.put(panel, p2);
final int[] slotsIDs = new int[inv.getPageSize()];
for (int k = 0; k < inv.getPageSize(); ++k) {
@@ -173,32 +140,7 @@ public class WindowCompartment extends WindowMachine implements IWindowAffectsSh
}
x += compartmentPageWidth;
if (tabs2.length > 0) {
final ControlTabBar<Integer> tab2 = new ControlTabBar<Integer>(controlCompartment, 24 + compartmentPageWidth, 0, 24, compartmentPageHeight, Alignment.RIGHT, Arrays.asList(tabs2)) {
@Override
public ControlTab<Integer> createTab(final int x, final int y, final int w, final int h, final Integer value) {
return new ControlTabIcon<Integer>(this, x, y, w, h, value) {
@Override
public ItemStack getItemStack() {
return WindowCompartment.this.getTab(this.value).getIcon();
}
@Override
public String getName() {
return WindowCompartment.this.getTab(this.value).getName();
}
@Override
public int getOutlineColour() {
return WindowCompartment.this.getTab(this.value).getColor().getColor();
}
@Override
public boolean hasOutline() {
return true;
}
};
}
};
final ControlTabBar<Integer> tab2 = new CompartmentTabBar2(this, controlCompartment, compartmentPageWidth, compartmentPageHeight, tabs2);
tab2.addHelp(tabHelp);
tab2.addEventHandler(EventValueChanged.class, EventHandlerOrigin.DIRECT_CHILD, tab2, event -> {
if (event.getValue() == null) {
@@ -271,27 +213,14 @@ public class WindowCompartment extends WindowMachine implements IWindowAffectsSh
color.addHelp("Select a colour to highlight the current tab");
}
y2 += 20;
final ControlButton searchButton = new ControlButton(controlCompartment, compartmentWidth - 24 - 64 - 8, compartmentPageHeight, 64, 16, "Search") {
@Override
@SideOnly(Side.CLIENT)
protected void onMouseClick(final EventMouse.Down event) {
WindowCompartment.this.createSearchDialog();
}
@Override
@SideOnly(Side.CLIENT)
public void onRenderBackground(int guiWidth, int guiHeight) {
final Object texture = this.isMouseOver() ? CraftGUITexture.TAB_HIGHLIGHTED : CraftGUITexture.TAB;
CraftGUI.RENDER.texture(CraftGUI.RENDER.getTexture(texture).crop(Alignment.BOTTOM, 8), this.getArea());
}
};
final ControlButton searchButton = new SearchButton(this, controlCompartment, compartmentWidth, compartmentPageHeight);
searchButton.addHelp("Search Button");
searchButton.addHelp("Clicking this will open the Search dialog. This allows you to search the inventory for specific items.");
}
@SideOnly(Side.CLIENT)
public void createSearchDialog() {
new SearchDialog();
new SearchDialog(this);
}
@Override
@@ -347,15 +276,17 @@ public class WindowCompartment extends WindowMachine implements IWindowAffectsSh
return this.getTab(this.currentTab);
}
private class SearchDialog extends Dialog {
private static class SearchDialog extends Dialog {
Control slotGrid;
String textSearch = "";
boolean sortByName = false;
boolean includeItems = true;
boolean includeBlocks = true;
private WindowCompartment windowCompartment;
public SearchDialog() {
super(WindowCompartment.this, 252, 192);
public SearchDialog(WindowCompartment windowCompartment) {
super(windowCompartment, 252, 192);
this.windowCompartment = windowCompartment;
}
@Override
@@ -364,14 +295,7 @@ public class WindowCompartment extends WindowMachine implements IWindowAffectsSh
@Override
public void initialise() {
final ControlScrollableContent<IWidget> scroll = new ControlScrollableContent<IWidget>(this, 124, 16, 116, 92, 6) {
@Override
@SideOnly(Side.CLIENT)
public void onRenderBackground(int guiWidth, int guiHeight) {
RenderUtil.setColour(11184810);
CraftGUI.RENDER.texture(CraftGUITexture.OUTLINE, this.getArea().inset(new Border(0, 6, 0, 0)));
}
};
final ControlScrollableContent<IWidget> scroll = new SearchScrollContent(this);
scroll.setScrollableContent(this.slotGrid = new Control(scroll, 1, 1, 108, 18));
new ControlPlayerInventory(this, true);
new ControlTextEdit(this, 16, 16, 100, 14).addEventHandler(EventTextEdit.class, event -> {
@@ -380,33 +304,15 @@ public class WindowCompartment extends WindowMachine implements IWindowAffectsSh
});
this.includeItems = true;
this.includeBlocks = true;
new ControlCheckbox(this, 16, 40, 100, "Sort A-Z", this.sortByName) {
@Override
protected void onValueChanged(final boolean value) {
sortByName = value;
updateSearch();
}
};
new ControlCheckbox(this, 16, 64, 100, "Include Items", this.includeItems) {
@Override
protected void onValueChanged(final boolean value) {
includeItems = value;
updateSearch();
}
};
new ControlCheckbox(this, 16, 88, 100, "Include Blocks", this.includeBlocks) {
@Override
protected void onValueChanged(final boolean value) {
includeBlocks = value;
updateSearch();
}
};
new SortAlphabeticalCheckbox(this);
new IncludeItemsCheckbox(this);
new IncludeBlocksCheckbox(this);
this.updateSearch();
}
private void updateSearch() {
Map<Integer, String> slotIds = new HashMap<>();
final IInventory inv = WindowCompartment.this.getInventory();
final IInventory inv = windowCompartment.getInventory();
for (int i = 0; i < inv.getSizeInventory(); ++i) {
final ItemStack stack = inv.getStackInSlot(i);
if (!stack.isEmpty()) {
@@ -453,5 +359,163 @@ public class WindowCompartment extends WindowMachine implements IWindowAffectsSh
}
}
}
private static class SearchScrollContent extends ControlScrollableContent<IWidget> {
private SearchDialog searchDialog;
public SearchScrollContent(SearchDialog searchDialog) {
super(searchDialog, 124, 16, 116, 92, 6);
this.searchDialog = searchDialog;
}
@Override
@SideOnly(Side.CLIENT)
public void onRenderBackground(int guiWidth, int guiHeight) {
RenderUtil.setColour(11184810);
CraftGUI.RENDER.texture(CraftGUITexture.OUTLINE, searchDialog.windowCompartment.getArea().inset(new Border(0, 6, 0, 0)));
}
}
private static class SortAlphabeticalCheckbox extends ControlCheckbox {
private SearchDialog searchDialog;
public SortAlphabeticalCheckbox(SearchDialog searchDialog) {
super(searchDialog, 16, 40, 100, "Sort A-Z", searchDialog.sortByName);
this.searchDialog = searchDialog;
}
@Override
protected void onValueChanged(final boolean value) {
searchDialog.sortByName = value;
searchDialog.updateSearch();
}
}
private static class IncludeItemsCheckbox extends ControlCheckbox {
private SearchDialog searchDialog;
public IncludeItemsCheckbox(SearchDialog searchDialog) {
super(searchDialog, 16, 64, 100, "Include Items", searchDialog.includeItems);
this.searchDialog = searchDialog;
}
@Override
protected void onValueChanged(final boolean value) {
searchDialog.includeItems = value;
searchDialog.updateSearch();
}
}
private static class IncludeBlocksCheckbox extends ControlCheckbox {
private SearchDialog searchDialog;
public IncludeBlocksCheckbox(SearchDialog searchDialog) {
super(searchDialog, 16, 88, 100, "Include Blocks", searchDialog.includeBlocks);
this.searchDialog = searchDialog;
}
@Override
protected void onValueChanged(final boolean value) {
searchDialog.includeBlocks = value;
searchDialog.updateSearch();
}
}
}
private static class CompartmentTabBar1 extends ControlTabBar<Integer> {
private WindowCompartment windowCompartment;
public CompartmentTabBar1(final WindowCompartment windowCompartment, Control controlCompartment, int compartmentPageHeight, Integer[] tabs1) {
super(controlCompartment, 0, 0, 24, compartmentPageHeight, Alignment.LEFT, Arrays.asList(tabs1));
this.windowCompartment = windowCompartment;
}
@Override
public ControlTab<Integer> createTab(final int x, final int y, final int w, final int h, final Integer value) {
return new CompartmentTabIcon(this, this.windowCompartment, x, y, w, h, value);
}
}
private static class CompartmentTabBar2 extends ControlTabBar<Integer> {
private WindowCompartment windowCompartment;
public CompartmentTabBar2(WindowCompartment windowCompartment, Control controlCompartment, int compartmentPageWidth, int compartmentPageHeight, Integer[] tabs2) {
super(controlCompartment, 24 + compartmentPageWidth, 0, 24, compartmentPageHeight, Alignment.RIGHT, Arrays.asList(tabs2));
this.windowCompartment = windowCompartment;
}
@Override
public ControlTab<Integer> createTab(final int x, final int y, final int w, final int h, final Integer value) {
return new CompartmentTabIcon(this, this.windowCompartment, x, y, w, h, value);
}
}
private static class CompartmentTabIcon extends ControlTabIcon<Integer> {
private WindowCompartment windowCompartment;
public CompartmentTabIcon(ControlTabBar<Integer> compartmentTabBar, WindowCompartment windowCompartment, int x, int y, int w, int h, Integer value) {
super(compartmentTabBar, x, y, w, h, value);
this.windowCompartment = windowCompartment;
}
@Override
public ItemStack getItemStack() {
return windowCompartment.getTab(this.value).getIcon();
}
@Override
public String getName() {
return windowCompartment.getTab(this.value).getName();
}
@Override
public int getOutlineColour() {
return windowCompartment.getTab(this.value).getColor().getColor();
}
@Override
public boolean hasOutline() {
return true;
}
}
private static class CompartmentPanel extends Panel {
private WindowCompartment windowCompartment;
public CompartmentPanel(WindowCompartment windowCompartment, ControlPage thisPage) {
super(thisPage, 0, 0, thisPage.getWidth(), thisPage.getHeight(), MinecraftGUI.PanelType.BLACK);
this.windowCompartment = windowCompartment;
}
@Override
@SideOnly(Side.CLIENT)
public void onRenderForeground(int guiWidth, int guiHeight) {
final ITexture iTexture = CraftGUI.RENDER.getTexture(CraftGUITexture.TAB_OUTLINE);
CompartmentTab tab = windowCompartment.getTab(windowCompartment.panels.get(this));
RenderUtil.setColour(tab.getColor().getColor());
CraftGUI.RENDER.texture(iTexture, this.getArea().inset(3));
}
}
private static class SearchButton extends ControlButton {
private WindowCompartment windowCompartment;
public SearchButton(WindowCompartment windowCompartment, Control controlCompartment, int compartmentWidth, int compartmentPageHeight) {
super(controlCompartment, compartmentWidth - 24 - 64 - 8, compartmentPageHeight, 64, 16, "Search");
this.windowCompartment = windowCompartment;
}
@Override
@SideOnly(Side.CLIENT)
protected void onMouseClick(final EventMouse.Down event) {
windowCompartment.createSearchDialog();
}
@Override
@SideOnly(Side.CLIENT)
public void onRenderBackground(int guiWidth, int guiHeight) {
final Object texture = this.isMouseOver() ? CraftGUITexture.TAB_HIGHLIGHTED : CraftGUITexture.TAB;
CraftGUI.RENDER.texture(CraftGUI.RENDER.getTexture(texture).crop(Alignment.BOTTOM, 8), this.getArea());
}
}
}
@@ -32,17 +32,7 @@ public class AlvearyLogicFrameHousing extends AbstractAlvearyLogic {
public AlvearyLogicFrameHousing(TileEntityExtraBeesAlvearyPart tile) {
this.tile = tile;
inv = new ItemStackHandler(1) {
@Nonnull
@Override
public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) {
if (!(stack.getItem() instanceof IHiveFrame)) {
return stack;
}
return super.insertItem(slot, stack, simulate);
}
};
inv = new HiveFrameItemStackHandler();
}
public IItemHandlerModifiable getInventory() {
@@ -118,4 +108,20 @@ public class AlvearyLogicFrameHousing extends AbstractAlvearyLogic {
public boolean hasGui() {
return true;
}
private static class HiveFrameItemStackHandler extends ItemStackHandler {
public HiveFrameItemStackHandler() {
super(1);
}
@Nonnull
@Override
public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) {
if (!(stack.getItem() instanceof IHiveFrame)) {
return stack;
}
return super.insertItem(slot, stack, simulate);
}
}
}
@@ -28,17 +28,7 @@ public class AlvearyLogicHatchery extends AbstractAlvearyLogic {
private final IItemHandlerModifiable inv;
public AlvearyLogicHatchery() {
inv = new ItemStackHandler(5) {
@Nonnull
@Override
public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) {
if (!stack.isEmpty() && Utils.getBeeRoot().getType(stack) != EnumBeeType.LARVAE) {
return stack;
}
return super.insertItem(slot, stack, simulate);
}
};
inv = new LarvaeItemStackHandler();
}
public IItemHandlerModifiable getInventory() {
@@ -82,4 +72,20 @@ public class AlvearyLogicHatchery extends AbstractAlvearyLogic {
public boolean hasGui() {
return true;
}
private static class LarvaeItemStackHandler extends ItemStackHandler {
public LarvaeItemStackHandler() {
super(5);
}
@Nonnull
@Override
public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) {
if (!stack.isEmpty() && Utils.getBeeRoot().getType(stack) != EnumBeeType.LARVAE) {
return stack;
}
return super.insertItem(slot, stack, simulate);
}
}
}
@@ -25,17 +25,7 @@ public class AlvearyLogicMutator extends AbstractAlvearyLogic {
private final IItemHandlerModifiable inv;
public AlvearyLogicMutator() {
this.inv = new ItemStackHandler(1) {
@Nonnull
@Override
public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) {
if (!AlvearyMutationHandler.isMutationItem(stack)) {
return stack;
}
return super.insertItem(slot, stack, simulate);
}
};
this.inv = new MutationItemStackHandler();
}
public IItemHandlerModifiable getInventory() {
@@ -71,4 +61,20 @@ public class AlvearyLogicMutator extends AbstractAlvearyLogic {
public boolean hasGui() {
return true;
}
private static class MutationItemStackHandler extends ItemStackHandler {
public MutationItemStackHandler() {
super(1);
}
@Nonnull
@Override
public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) {
if (!AlvearyMutationHandler.isMutationItem(stack)) {
return stack;
}
return super.insertItem(slot, stack, simulate);
}
}
}
@@ -40,17 +40,7 @@ public class AlvearyLogicStimulator extends AbstractAlvearyLogic {
this.powered = false;
this.modifiers = new StimulatorCircuit[0];
this.energyStorage = new EnergyStorage(10000);
this.inv = new ItemStackHandler(1) {
@Nonnull
@Override
public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) {
if (!ChipsetManager.circuitRegistry.isChipset(stack)) {
return stack;
}
return super.insertItem(slot, stack, simulate);
}
};
this.inv = new ChipsetItemStackHandler();
}
public IItemHandlerModifiable getInventory() {
@@ -251,4 +241,20 @@ public class AlvearyLogicStimulator extends AbstractAlvearyLogic {
public boolean hasGui() {
return true;
}
private static class ChipsetItemStackHandler extends ItemStackHandler {
public ChipsetItemStackHandler() {
super(1);
}
@Nonnull
@Override
public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) {
if (!ChipsetManager.circuitRegistry.isChipset(stack)) {
return stack;
}
return super.insertItem(slot, stack, simulate);
}
}
}
@@ -158,30 +158,32 @@ public class BeeBreedingSystem extends BreedingSystem {
@Override
public IFieldKitPlugin getFieldKitPlugin() {
return new IFieldKitPlugin() {
@Override
public Map<IChromosomeType, IPoint> getChromosomePickerPositions() {
Map<IChromosomeType, IPoint> positions = new HashMap<>();
positions.put(EnumBeeChromosome.SPECIES, new Point(28, 47));
positions.put(EnumBeeChromosome.SPEED, new Point(28, 72));
positions.put(EnumBeeChromosome.LIFESPAN, new Point(19, 20));
positions.put(EnumBeeChromosome.FERTILITY, new Point(55, 65));
positions.put(EnumBeeChromosome.TEMPERATURE_TOLERANCE, new Point(28, 1));
positions.put(EnumBeeChromosome.NEVER_SLEEPS, new Point(61, 37));
positions.put(EnumBeeChromosome.HUMIDITY_TOLERANCE, new Point(81, 76));
positions.put(EnumBeeChromosome.TOLERATES_RAIN, new Point(44, 21));
positions.put(EnumBeeChromosome.CAVE_DWELLING, new Point(3, 37));
positions.put(EnumBeeChromosome.FLOWER_PROVIDER, new Point(4, 65));
positions.put(EnumBeeChromosome.FLOWERING, new Point(83, 27));
positions.put(EnumBeeChromosome.TERRITORY, new Point(71, 10));
positions.put(EnumBeeChromosome.EFFECT, new Point(84, 54));
return positions;
}
return new FieldKitPlugin();
}
@Override
public ITexture getTypeTexture() {
return new StandardTexture(0, 0, 96, 96, BinnieCoreTexture.GUI_BREEDING);
}
};
private static class FieldKitPlugin implements IFieldKitPlugin {
@Override
public Map<IChromosomeType, IPoint> getChromosomePickerPositions() {
Map<IChromosomeType, IPoint> positions = new HashMap<>();
positions.put(EnumBeeChromosome.SPECIES, new Point(28, 47));
positions.put(EnumBeeChromosome.SPEED, new Point(28, 72));
positions.put(EnumBeeChromosome.LIFESPAN, new Point(19, 20));
positions.put(EnumBeeChromosome.FERTILITY, new Point(55, 65));
positions.put(EnumBeeChromosome.TEMPERATURE_TOLERANCE, new Point(28, 1));
positions.put(EnumBeeChromosome.NEVER_SLEEPS, new Point(61, 37));
positions.put(EnumBeeChromosome.HUMIDITY_TOLERANCE, new Point(81, 76));
positions.put(EnumBeeChromosome.TOLERATES_RAIN, new Point(44, 21));
positions.put(EnumBeeChromosome.CAVE_DWELLING, new Point(3, 37));
positions.put(EnumBeeChromosome.FLOWER_PROVIDER, new Point(4, 65));
positions.put(EnumBeeChromosome.FLOWERING, new Point(83, 27));
positions.put(EnumBeeChromosome.TERRITORY, new Point(71, 10));
positions.put(EnumBeeChromosome.EFFECT, new Point(84, 54));
return positions;
}
@Override
public ITexture getTypeTexture() {
return new StandardTexture(0, 0, 96, 96, BinnieCoreTexture.GUI_BREEDING);
}
}
}
@@ -143,33 +143,7 @@ public class AnalystPageBeeProducts extends Control implements ITitledWidget {
}
private void createProductEntry(ItemStack key, Float value, int y, float speed) {
ControlItemDisplay item = new ControlItemDisplay(this, 16, y) {
@Override
@SideOnly(Side.CLIENT)
public void getTooltip(Tooltip tooltip, ITooltipFlag tooltipFlag) {
super.getTooltip(tooltip, tooltipFlag);
NonNullList<ItemStack> centrifugeProducts = NonNullList.create();
ForestryRecipeUtil.getCentrifugeOutputs(key, centrifugeProducts);
if (!centrifugeProducts.isEmpty()) {
tooltip.add(I18N.localise(AnalystConstants.PRODUCTS_KEY + ".centrifuges") + ": ");
for (ItemStack prod : centrifugeProducts) {
NBTTagCompound nbt = new NBTTagCompound();
prod.writeToNBT(nbt);
tooltip.add(prod, prod.getDisplayName());
}
}
NonNullList<ItemStack> squeezerProducts = NonNullList.create();
ForestryRecipeUtil.getSqueezerOutputs(key, squeezerProducts);
if (!squeezerProducts.isEmpty()) {
tooltip.add(I18N.localise(AnalystConstants.PRODUCTS_KEY + ".squeezes") + ": ");
for (ItemStack prod2 : squeezerProducts) {
NBTTagCompound nbt2 = new NBTTagCompound();
prod2.writeToNBT(nbt2);
tooltip.add(prod2, prod2.getDisplayName());
}
}
}
};
ControlItemDisplay item = new BeeProductItem(this, y, key);
item.setTooltip();
ControlText textWidget = new ControlTextCentered(this, y + 4, "");
@@ -184,4 +158,39 @@ public class AnalystPageBeeProducts extends Control implements ITitledWidget {
public String getTitle() {
return I18N.localise(AnalystConstants.PRODUCTS_KEY + ".title");
}
private static class BeeProductItem extends ControlItemDisplay {
private final ItemStack key;
public BeeProductItem(AnalystPageBeeProducts analystPageBeeProducts, int y, ItemStack key) {
super(analystPageBeeProducts, 16, y);
this.key = key;
}
@Override
@SideOnly(Side.CLIENT)
public void getTooltip(Tooltip tooltip, ITooltipFlag tooltipFlag) {
super.getTooltip(tooltip, tooltipFlag);
NonNullList<ItemStack> centrifugeProducts = NonNullList.create();
ForestryRecipeUtil.getCentrifugeOutputs(key, centrifugeProducts);
if (!centrifugeProducts.isEmpty()) {
tooltip.add(I18N.localise(AnalystConstants.PRODUCTS_KEY + ".centrifuges") + ": ");
for (ItemStack prod : centrifugeProducts) {
NBTTagCompound nbt = new NBTTagCompound();
prod.writeToNBT(nbt);
tooltip.add(prod, prod.getDisplayName());
}
}
NonNullList<ItemStack> squeezerProducts = NonNullList.create();
ForestryRecipeUtil.getSqueezerOutputs(key, squeezerProducts);
if (!squeezerProducts.isEmpty()) {
tooltip.add(I18N.localise(AnalystConstants.PRODUCTS_KEY + ".squeezes") + ": ");
for (ItemStack prod2 : squeezerProducts) {
NBTTagCompound nbt2 = new NBTTagCompound();
prod2.writeToNBT(nbt2);
tooltip.add(prod2, prod2.getDisplayName());
}
}
}
}
}
@@ -63,7 +63,7 @@ public class ControlProductsBox extends ControlListBox<ControlProductsBox.Produc
SPECIALTIES
}
class Product {
static class Product {
ItemStack item;
float chance;
@@ -19,13 +19,7 @@ public final class FluidRegister {
private static Fluid createFluid(String name) {
name = name.toLowerCase();
Fluid ret = new Fluid(name, new ExtraBeesResourceLocation("blocks/liquids/" + name), new ExtraBeesResourceLocation("blocks/liquids/" + name)) {
@Override
public int getColor() {
return 16777215;
}
};
Fluid ret = new Fluid(name, new ExtraBeesResourceLocation("blocks/liquids/" + name), new ExtraBeesResourceLocation("blocks/liquids/" + name));
FluidRegistry.registerFluid(ret);
return ret;
}
@@ -42,24 +42,7 @@ public class ExtraBeesClientProxy extends ExtraBeesCommonProxy {
private static final ModelManager modelManager = ModelManager.getInstance();
private static IBakedModel bakeModelFor(Block block) {
return new BlankModel() {
@Override
protected ItemOverrideList createOverrides() {
return new ItemOverrideList(ImmutableList.of()) {
@Override
@SuppressWarnings("deprecation")
public IBakedModel handleItemState(IBakedModel originalModel, ItemStack stack, @Nullable World world, @Nullable EntityLivingBase entity) {
Minecraft minecraft = Minecraft.getMinecraft();
BlockRendererDispatcher blockRendererDispatcher = minecraft.getBlockRendererDispatcher();
BlockModelShapes blockModelShapes = blockRendererDispatcher.getBlockModelShapes();
IBlockState stateFromMeta = block.getStateFromMeta(stack.getMetadata());
return blockModelShapes.getModelForState(stateFromMeta);
}
};
}
};
return new BakedModelForBlock(block);
}
@Override
@@ -106,4 +89,37 @@ public class ExtraBeesClientProxy extends ExtraBeesCommonProxy {
private void registerItemBlockLink(ResourceLocation item, Block block, IRegistry<ModelResourceLocation, IBakedModel> registry) {
registry.putObject(new ModelResourceLocation(item, "inventory"), bakeModelFor(block));
}
private static class BakedModelForBlock extends BlankModel {
private final Block block;
public BakedModelForBlock(Block block) {
this.block = block;
}
@Override
protected ItemOverrideList createOverrides() {
return new BlockItemOverrideList(block);
}
private static class BlockItemOverrideList extends ItemOverrideList {
private Block block;
public BlockItemOverrideList(Block block) {
super(ImmutableList.of());
this.block = block;
}
@Override
@SuppressWarnings("deprecation")
public IBakedModel handleItemState(IBakedModel originalModel, ItemStack stack, @Nullable World world, @Nullable EntityLivingBase entity) {
Minecraft minecraft = Minecraft.getMinecraft();
BlockRendererDispatcher blockRendererDispatcher = minecraft.getBlockRendererDispatcher();
BlockModelShapes blockModelShapes = blockRendererDispatcher.getBlockModelShapes();
IBlockState stateFromMeta = block.getStateFromMeta(stack.getMetadata());
return blockModelShapes.getModelForState(stateFromMeta);
}
}
}
}
@@ -24,28 +24,30 @@ public enum EnumSaplingType {
Shrub;
public IGermlingModelProvider getGermlingModelProvider(Color leaf, Color wood) {
return new DefaultGermlingModelProvider(this, leaf, wood);
return new DefaultGermlingModelProvider(this, this, leaf, wood);
}
private class DefaultGermlingModelProvider implements IGermlingModelProvider {
private static class DefaultGermlingModelProvider implements IGermlingModelProvider {
private ModelResourceLocation germlingModel;
private ModelResourceLocation pollenModel;
private EnumSaplingType saplingType;
private Color leaf;
private Color wood;
private EnumSaplingType enumSaplingType;
public DefaultGermlingModelProvider(EnumSaplingType saplingType, Color leaf, Color wood) {
public DefaultGermlingModelProvider(EnumSaplingType enumSaplingType, EnumSaplingType saplingType, Color leaf, Color wood) {
this.saplingType = saplingType;
this.wood = wood;
this.leaf = leaf;
this.enumSaplingType = enumSaplingType;
}
@SideOnly(Side.CLIENT)
@Override
public void registerModels(Item item, IModelManager manager, EnumGermlingType type) {
if (type == EnumGermlingType.SAPLING) {
germlingModel = manager.getModelLocation("extratrees", "saplings/tree_" + name());
ModelBakery.registerItemVariants(item, new ResourceLocation("extratrees", "saplings/tree_" + name()));
germlingModel = manager.getModelLocation("extratrees", "saplings/tree_" + enumSaplingType.name());
ModelBakery.registerItemVariants(item, new ResourceLocation("extratrees", "saplings/tree_" + enumSaplingType.name()));
}
if (type == EnumGermlingType.POLLEN) {
pollenModel = manager.getModelLocation("pollen");
@@ -160,31 +160,33 @@ public class MothBreedingSystem extends BreedingSystem {
@Override
public IFieldKitPlugin getFieldKitPlugin() {
return new IFieldKitPlugin() {
@Override
public Map<IChromosomeType, IPoint> getChromosomePickerPositions() {
Map<IChromosomeType, IPoint> positions = new HashMap<>();
positions.put(EnumButterflyChromosome.SPECIES, new Point(40, 40));
positions.put(EnumButterflyChromosome.SIZE, new Point(63, 32));
positions.put(EnumButterflyChromosome.SPEED, new Point(32, 63));
positions.put(EnumButterflyChromosome.LIFESPAN, new Point(11, 27));
positions.put(EnumButterflyChromosome.METABOLISM, new Point(16, 12));
positions.put(EnumButterflyChromosome.FERTILITY, new Point(17, 63));
positions.put(EnumButterflyChromosome.TEMPERATURE_TOLERANCE, new Point(34, 12));
positions.put(EnumButterflyChromosome.HUMIDITY_TOLERANCE, new Point(22, 46));
positions.put(EnumButterflyChromosome.NOCTURNAL, new Point(53, 26));
positions.put(EnumButterflyChromosome.TOLERANT_FLYER, new Point(71, 53));
positions.put(EnumButterflyChromosome.FIRE_RESIST, new Point(78, 12));
positions.put(EnumButterflyChromosome.FLOWER_PROVIDER, new Point(55, 55));
positions.put(EnumButterflyChromosome.EFFECT, new Point(27, 31));
positions.put(EnumButterflyChromosome.COCOON, new Point(87, 45));
return positions;
}
return new FieldKitPlugin();
}
@Override
public ITexture getTypeTexture() {
return new StandardTexture(96, 96, 96, 96, BinnieCoreTexture.GUI_BREEDING);
}
};
private static class FieldKitPlugin implements IFieldKitPlugin {
@Override
public Map<IChromosomeType, IPoint> getChromosomePickerPositions() {
Map<IChromosomeType, IPoint> positions = new HashMap<>();
positions.put(EnumButterflyChromosome.SPECIES, new Point(40, 40));
positions.put(EnumButterflyChromosome.SIZE, new Point(63, 32));
positions.put(EnumButterflyChromosome.SPEED, new Point(32, 63));
positions.put(EnumButterflyChromosome.LIFESPAN, new Point(11, 27));
positions.put(EnumButterflyChromosome.METABOLISM, new Point(16, 12));
positions.put(EnumButterflyChromosome.FERTILITY, new Point(17, 63));
positions.put(EnumButterflyChromosome.TEMPERATURE_TOLERANCE, new Point(34, 12));
positions.put(EnumButterflyChromosome.HUMIDITY_TOLERANCE, new Point(22, 46));
positions.put(EnumButterflyChromosome.NOCTURNAL, new Point(53, 26));
positions.put(EnumButterflyChromosome.TOLERANT_FLYER, new Point(71, 53));
positions.put(EnumButterflyChromosome.FIRE_RESIST, new Point(78, 12));
positions.put(EnumButterflyChromosome.FLOWER_PROVIDER, new Point(55, 55));
positions.put(EnumButterflyChromosome.EFFECT, new Point(27, 31));
positions.put(EnumButterflyChromosome.COCOON, new Point(87, 45));
return positions;
}
@Override
public ITexture getTypeTexture() {
return new StandardTexture(96, 96, 96, 96, BinnieCoreTexture.GUI_BREEDING);
}
}
}
@@ -51,50 +51,9 @@ public class WindowArboristDatabase extends WindowAbstractDatabase {
new PageBranchOverview(this.getInfoPages(Mode.BRANCHES), new DatabaseTab(ExtraTrees.instance, "branches.overview"));
new PageBranchSpecies(this.getInfoPages(Mode.BRANCHES), new DatabaseTab(ExtraTrees.instance, "branches.species"));
new PageBreeder(this.getInfoPages(Mode.BREEDER), this.getUsername(), new DatabaseTab(ExtraTrees.instance, "breeder"));
this.createMode(TreeMode.FRUIT, new ModeWidgets(TreeMode.FRUIT, this) {
@Override
public void createListBox(final IArea area) {
ControlListBox<ItemStack> controlListBox = new ControlListBox<ItemStack>(this.modePage, area.xPos(), area.yPos(), area.width(), area.height(), 12) {
@Override
@SideOnly(Side.CLIENT)
public IWidget createOption(final ItemStack value, final int y) {
return new ControlItemStackOption(this.getContent(), value, y);
}
};
ITreeBreedingSystem breedingSystem = (ITreeBreedingSystem) WindowArboristDatabase.this.getBreedingSystem();
controlListBox.setOptions(breedingSystem.getAllFruits());
this.listBox = controlListBox;
}
});
this.createMode(TreeMode.WOOD, new ModeWidgets(TreeMode.WOOD, this) {
@Override
public void createListBox(final IArea area) {
ControlListBox<ItemStack> controlListBox = new ControlListBox<ItemStack>(this.modePage, area.xPos(), area.yPos(), area.width(), area.height(), 12) {
@Override
@SideOnly(Side.CLIENT)
public IWidget createOption(final ItemStack value, final int y) {
return new ControlItemStackOption(this.getContent(), value, y);
}
};
ITreeBreedingSystem breedingSystem = (ITreeBreedingSystem) WindowArboristDatabase.this.getBreedingSystem();
controlListBox.setOptions(breedingSystem.getAllWoods());
this.listBox = controlListBox;
}
});
this.createMode(TreeMode.PLANKS, new ModeWidgets(TreeMode.PLANKS, this) {
@Override
public void createListBox(final IArea area) {
ControlListBox<ItemStack> controlListBox = new ControlListBox<ItemStack>(this.modePage, area.xPos(), area.yPos(), area.width(), area.height(), 12) {
@Override
@SideOnly(Side.CLIENT)
public IWidget createOption(final ItemStack value, final int y) {
return new ControlItemStackOption(this.getContent(), value, y);
}
};
controlListBox.setOptions(WoodManager.getAllPlankTypes().stream().map(IDesignMaterial::getStack).collect(Collectors.toList()));
this.listBox = controlListBox;
}
});
this.createMode(TreeMode.FRUIT, new FruitModeWidgets(this));
this.createMode(TreeMode.WOOD, new WoodModeWidgets(this));
this.createMode(TreeMode.PLANKS, new PlanksModeWidgets(this));
new PageFruit(this.getInfoPages(TreeMode.FRUIT), new DatabaseTab(ExtraTrees.instance, "fruit.natural"), true);
new PageFruit(this.getInfoPages(TreeMode.FRUIT), new DatabaseTab(ExtraTrees.instance, "fruit.potential"), false);
new PageWood(this.getInfoPages(TreeMode.WOOD), new DatabaseTab(ExtraTrees.instance, "wood.natural"));
@@ -122,4 +81,90 @@ public class WindowArboristDatabase extends WindowAbstractDatabase {
return I18N.localise("extratrees.gui.database.mode." + this.name().toLowerCase());
}
}
private static class FruitModeWidgets extends ModeWidgets {
private WindowArboristDatabase windowArboristDatabase;
public FruitModeWidgets(WindowArboristDatabase windowArboristDatabase) {
super(TreeMode.FRUIT, windowArboristDatabase);
this.windowArboristDatabase = windowArboristDatabase;
}
@Override
public void createListBox(final IArea area) {
ControlListBox<ItemStack> controlListBox = new FruitModeControlListBox(this, area);
ITreeBreedingSystem breedingSystem = (ITreeBreedingSystem) windowArboristDatabase.getBreedingSystem();
controlListBox.setOptions(breedingSystem.getAllFruits());
this.listBox = controlListBox;
}
private static class FruitModeControlListBox extends ControlListBox<ItemStack> {
public FruitModeControlListBox(FruitModeWidgets fruitModeWidgets, IArea area) {
super(fruitModeWidgets.modePage, area.xPos(), area.yPos(), area.width(), area.height(), 12);
}
@Override
@SideOnly(Side.CLIENT)
public IWidget createOption(final ItemStack value, final int y) {
return new ControlItemStackOption(this.getContent(), value, y);
}
}
}
private static class WoodModeWidgets extends ModeWidgets {
private WindowArboristDatabase windowArboristDatabase;
public WoodModeWidgets(WindowArboristDatabase windowArboristDatabase) {
super(TreeMode.WOOD, windowArboristDatabase);
this.windowArboristDatabase = windowArboristDatabase;
}
@Override
public void createListBox(final IArea area) {
ControlListBox<ItemStack> controlListBox = new WoodModeControlListBox(this, area);
ITreeBreedingSystem breedingSystem = (ITreeBreedingSystem) windowArboristDatabase.getBreedingSystem();
controlListBox.setOptions(breedingSystem.getAllWoods());
this.listBox = controlListBox;
}
private static class WoodModeControlListBox extends ControlListBox<ItemStack> {
public WoodModeControlListBox(WoodModeWidgets woodModeWidgets, IArea area) {
super(woodModeWidgets.modePage, area.xPos(), area.yPos(), area.width(), area.height(), 12);
}
@Override
@SideOnly(Side.CLIENT)
public IWidget createOption(final ItemStack value, final int y) {
return new ControlItemStackOption(this.getContent(), value, y);
}
}
}
private static class PlanksModeWidgets extends ModeWidgets {
public PlanksModeWidgets(WindowArboristDatabase windowArboristDatabase) {
super(TreeMode.PLANKS, windowArboristDatabase);
}
@Override
public void createListBox(final IArea area) {
ControlListBox<ItemStack> controlListBox = new PlanksModeControlListBox(this, area);
controlListBox.setOptions(WoodManager.getAllPlankTypes().stream().map(IDesignMaterial::getStack).collect(Collectors.toList()));
this.listBox = controlListBox;
}
private static class PlanksModeControlListBox extends ControlListBox<ItemStack> {
public PlanksModeControlListBox(PlanksModeWidgets planksModeWidgets, IArea area) {
super(planksModeWidgets.modePage, area.xPos(), area.yPos(), area.width(), area.height(), 12);
}
@Override
@SideOnly(Side.CLIENT)
public IWidget createOption(final ItemStack value, final int y) {
return new ControlItemStackOption(this.getContent(), value, y);
}
}
}
}
@@ -20,7 +20,7 @@ import net.minecraftforge.fml.common.registry.ForgeRegistries;
public class LumbermillRecipeManager implements ILumbermillManager {
private static final Multimap<Item, ILumbermillRecipe> recipes = ArrayListMultimap.create();
private static final InventoryCrafting FAKE_CRAFT_INV = new InventoryCrafting(new FakeCraftingHandler(), 3, 3) {};
private static final InventoryCrafting FAKE_CRAFT_INV = new FakeInventoryCrafting();
public static ItemStack getPlankProduct(ItemStack logStack, World world) {
Item logItem = logStack.getItem();
@@ -91,4 +91,10 @@ public class LumbermillRecipeManager implements ILumbermillManager {
return false;
}
}
private static class FakeInventoryCrafting extends InventoryCrafting {
public FakeInventoryCrafting() {
super(new FakeCraftingHandler(), 3, 3);
}
}
}
@@ -94,7 +94,7 @@ public class ProxyClient extends Proxy implements IExtraTreeProxy {
getModelManager().registerItemAndBlockColors();
}
class CustomMapper extends StateMapperBase {
static class CustomMapper extends StateMapperBase {
ResourceLocation rl;
public CustomMapper(String name) {
@@ -280,28 +280,7 @@ public class TreeBreedingSystem extends BreedingSystem implements binnie.genetic
@Override
public IFieldKitPlugin getFieldKitPlugin() {
return new IFieldKitPlugin() {
@Override
public Map<IChromosomeType, IPoint> getChromosomePickerPositions() {
Map<IChromosomeType, IPoint> positions = new HashMap<>();
positions.put(EnumTreeChromosome.SPECIES, new Point(48, 48));
positions.put(EnumTreeChromosome.HEIGHT, new Point(43, 84));
positions.put(EnumTreeChromosome.FERTILITY, new Point(25, 63));
positions.put(EnumTreeChromosome.FRUITS, new Point(72, 57));
positions.put(EnumTreeChromosome.YIELD, new Point(21, 43));
positions.put(EnumTreeChromosome.SAPPINESS, new Point(15, 17));
positions.put(EnumTreeChromosome.EFFECT, new Point(67, 15));
positions.put(EnumTreeChromosome.MATURATION, new Point(70, 34));
positions.put(EnumTreeChromosome.GIRTH, new Point(45, 67));
positions.put(EnumTreeChromosome.FIREPROOF, new Point(5, 70));
return positions;
}
@Override
public ITexture getTypeTexture() {
return new StandardTexture(96, 0, 96, 96, BinnieCoreTexture.GUI_BREEDING);
}
};
return new FieldKitPlugin();
}
@Override
@@ -313,4 +292,27 @@ public class TreeBreedingSystem extends BreedingSystem implements binnie.genetic
public Set<ItemStack> getAllWoods() {
return allWoods;
}
private static class FieldKitPlugin implements IFieldKitPlugin {
@Override
public Map<IChromosomeType, IPoint> getChromosomePickerPositions() {
Map<IChromosomeType, IPoint> positions = new HashMap<>();
positions.put(EnumTreeChromosome.SPECIES, new Point(48, 48));
positions.put(EnumTreeChromosome.HEIGHT, new Point(43, 84));
positions.put(EnumTreeChromosome.FERTILITY, new Point(25, 63));
positions.put(EnumTreeChromosome.FRUITS, new Point(72, 57));
positions.put(EnumTreeChromosome.YIELD, new Point(21, 43));
positions.put(EnumTreeChromosome.SAPPINESS, new Point(15, 17));
positions.put(EnumTreeChromosome.EFFECT, new Point(67, 15));
positions.put(EnumTreeChromosome.MATURATION, new Point(70, 34));
positions.put(EnumTreeChromosome.GIRTH, new Point(45, 67));
positions.put(EnumTreeChromosome.FIREPROOF, new Point(5, 70));
return positions;
}
@Override
public ITexture getTypeTexture() {
return new StandardTexture(96, 0, 96, 96, BinnieCoreTexture.GUI_BREEDING);
}
}
}
@@ -34,6 +34,7 @@ import binnie.core.gui.resource.textures.CraftGUITexture;
import binnie.core.gui.window.Panel;
import binnie.core.util.I18N;
@SideOnly(Side.CLIENT)
public class AnalystPageDatabase extends Control implements ITitledWidget {
private final ControlScrollableContent scroll;
boolean isMaster;
@@ -45,35 +46,7 @@ public class AnalystPageDatabase extends Control implements ITitledWidget {
int y = 4;
new ControlTextCentered(this, y, TextFormatting.UNDERLINE + getTitle()).setColor(getColor());
y += 16;
new ControlTextEdit(this, 20, y, getWidth() - 40, 16) {
@Override
public void onTextEdit(String value) {
Collection<IAlleleSpecies> options = new ArrayList<>();
getSpecies(system);
for (IAlleleSpecies species : getSpecies(system)) {
if (value != null) {
if (!Objects.equals(value, "")) {
if (!species.getAlleleName().toLowerCase().contains(value.toLowerCase())) {
continue;
}
}
}
options.add(species);
}
scroll.deleteAllChildren();
scroll.setScrollableContent(getItemScrollList(system, options));
}
@Override
@SideOnly(Side.CLIENT)
public void onRenderBackground(int guiWidth, int guiHeight) {
RenderUtil.setColour(5592405);
CraftGUI.RENDER.texture(CraftGUITexture.TAB_SOLID, getArea().inset(1));
RenderUtil.setColour(AnalystPageDatabase.this.getColor());
CraftGUI.RENDER.texture(CraftGUITexture.TAB_OUTLINE, getArea());
renderTextField();
}
};
new SpeciesSearch(this, y, system);
y += 22;
new Panel(this, 3, y - 1, getWidth() - 6, getHeight() - y - 8 + 2, MinecraftGUI.PanelType.TAB_OUTLINE).setColor(getColor());
boolean textView = false;
@@ -86,41 +59,12 @@ public class AnalystPageDatabase extends Control implements ITitledWidget {
String maturation = system.getAlleleName(EnumTreeChromosome.MATURATION, system.getIndividual(species.getUID()).getGenome().getActiveAllele(EnumTreeChromosome.MATURATION));
}
if (textView) {
scroll = new ControlListBox<IAlleleSpecies>(this, 4, y, getWidth() - 8, getHeight() - y - 8 - 20, 0) {
@Override
public void initialise() {
super.initialise();
setOptions(options);
}
@Override
public IWidget createOption(IAlleleSpecies v, int y) {
return new Control(getContent(), 0, y, getWidth(), 12) {
IAlleleSpecies value = v;
@Override
@SideOnly(Side.CLIENT)
public void onRenderBackground(int guiWidth, int guiHeight) {
RenderUtil.drawText(getArea(), TextJustification.MIDDLE_CENTER, value.getAlleleName(), 16777215);
}
};
}
};
scroll = new Scroll(this, y, options);
} else {
scroll = new ControlScrollableContent(this, 4, y, getWidth() - 8, getHeight() - y - 8, 0);
scroll.setScrollableContent(getItemScrollList(system, options));
}
new ControlScrollBar(this, scroll.getXPos() + scroll.getWidth() - 6, scroll.getYPos() + 3, 3, scroll.getHeight() - 6, scroll) {
@Override
@SideOnly(Side.CLIENT)
public void onRenderBackground(int guiWidth, int guiHeight) {
if (!isEnabled()) {
return;
}
RenderUtil.drawGradientRect(getArea(), 1140850688 + AnalystPageDatabase.this.getColor(), 1140850688 + AnalystPageDatabase.this.getColor());
RenderUtil.drawSolidRect(getRenderArea(), AnalystPageDatabase.this.getColor());
}
};
new DatabaseScrollBar(this);
}
private static int getColor(IBreedingSystem system){
@@ -137,49 +81,7 @@ public class AnalystPageDatabase extends Control implements ITitledWidget {
}
private IWidget getItemScrollList(IBreedingSystem system, Collection<IAlleleSpecies> options) {
return new Control(scroll, 0, 0, scroll.getWidth(), scroll.getHeight()) {
@Override
public void initialise() {
int maxBiomePerLine = (getWidth() - 4 + 2) / 18;
int biomeListX = -6 + (getWidth() - (maxBiomePerLine * 18 - 2)) / 2;
int dx = 0;
int dy = 0;
for (IAlleleSpecies species : options) {
IIndividual ind = system.getSpeciesRoot().templateAsIndividual(system.getSpeciesRoot().getTemplate(species));
new ControlIndividualDisplay(this, biomeListX + dx, 2 + dy, ind) {
@Override
public void initialise() {
addSelfEventHandler(EventMouse.Down.class, event -> {
WindowAnalyst window = (WindowAnalyst) AnalystPageDatabase.this.getTopParent();
window.setIndividual(ind);
});
}
@Override
@SideOnly(Side.CLIENT)
public void onRenderBackground(int guiWidth, int guiHeight) {
WindowAnalyst window = (WindowAnalyst) AnalystPageDatabase.this.getTopParent();
if (window.getIndividual() != null && window.getIndividual().getGenome().getPrimary() == species) {
RenderUtil.setColour(15658734);
CraftGUI.RENDER.texture(CraftGUITexture.TAB_SOLID, getArea().outset(1));
RenderUtil.setColour(AnalystPageDatabase.this.getColor());
CraftGUI.RENDER.texture(CraftGUITexture.TAB_OUTLINE, getArea().outset(1));
} else if (calculateIsMouseOver()) {
RenderUtil.setColour(15658734);
CraftGUI.RENDER.texture(CraftGUITexture.TAB_SOLID, getArea().outset(1));
}
super.onRenderBackground(guiWidth, guiHeight);
}
};
dx += 18;
if (dx >= 18 * maxBiomePerLine) {
dx = 0;
dy += 18;
}
}
setSize(new Point(getWidth(), 4 + dy + 18));
}
};
return new ItemScrollList(this, options, system);
}
@Override
@@ -192,4 +94,162 @@ public class AnalystPageDatabase extends Control implements ITitledWidget {
species.addAll(isMaster ? system.getAllSpecies() : system.getDiscoveredSpecies(getWindow().getWorld(), getWindow().getPlayer().getGameProfile()));
return species;
}
private static class Scroll extends ControlListBox<IAlleleSpecies> {
private final Collection<IAlleleSpecies> options;
public Scroll(AnalystPageDatabase analystPageDatabase, int y, Collection<IAlleleSpecies> options) {
super(analystPageDatabase, 4, y, analystPageDatabase.getWidth() - 8, analystPageDatabase.getHeight() - y - 8 - 20, 0);
this.options = options;
}
@Override
public void initialise() {
super.initialise();
setOptions(options);
}
@Override
public IWidget createOption(IAlleleSpecies v, int y) {
return new ScrollOption(this, y, v);
}
private static class ScrollOption extends Control {
private final IAlleleSpecies v;
IAlleleSpecies value;
public ScrollOption(Scroll scroll, int y, IAlleleSpecies v) {
super(scroll.getContent(), 0, y, scroll.getWidth(), 12);
this.v = v;
value = v;
}
@Override
@SideOnly(Side.CLIENT)
public void onRenderBackground(int guiWidth, int guiHeight) {
RenderUtil.drawText(getArea(), TextJustification.MIDDLE_CENTER, value.getAlleleName(), 16777215);
}
}
}
private static class SpeciesSearch extends ControlTextEdit {
private final IBreedingSystem system;
private AnalystPageDatabase analystPageDatabase;
public SpeciesSearch(AnalystPageDatabase analystPageDatabase, int y, IBreedingSystem system) {
super(analystPageDatabase, 20, y, analystPageDatabase.getWidth() - 40, 16);
this.system = system;
this.analystPageDatabase = analystPageDatabase;
}
@Override
public void onTextEdit(String value) {
Collection<IAlleleSpecies> options = new ArrayList<>();
analystPageDatabase.getSpecies(system);
for (IAlleleSpecies species : analystPageDatabase.getSpecies(system)) {
if (value == null || Objects.equals(value, "") || species.getAlleleName().toLowerCase().contains(value.toLowerCase())) {
options.add(species);
}
}
analystPageDatabase.scroll.deleteAllChildren();
analystPageDatabase.scroll.setScrollableContent(analystPageDatabase.getItemScrollList(system, options));
}
@Override
@SideOnly(Side.CLIENT)
public void onRenderBackground(int guiWidth, int guiHeight) {
RenderUtil.setColour(5592405);
CraftGUI.RENDER.texture(CraftGUITexture.TAB_SOLID, getArea().inset(1));
RenderUtil.setColour(analystPageDatabase.getColor());
CraftGUI.RENDER.texture(CraftGUITexture.TAB_OUTLINE, getArea());
renderTextField();
}
}
private static class DatabaseScrollBar extends ControlScrollBar {
private AnalystPageDatabase analystPageDatabase;
public DatabaseScrollBar(AnalystPageDatabase analystPageDatabase) {
super(analystPageDatabase, analystPageDatabase.scroll.getXPos() + analystPageDatabase.scroll.getWidth() - 6, analystPageDatabase.scroll.getYPos() + 3, 3, analystPageDatabase.scroll.getHeight() - 6, analystPageDatabase.scroll);
this.analystPageDatabase = analystPageDatabase;
}
@Override
@SideOnly(Side.CLIENT)
public void onRenderBackground(int guiWidth, int guiHeight) {
if (!isEnabled()) {
return;
}
RenderUtil.drawGradientRect(getArea(), 1140850688 + analystPageDatabase.getColor(), 1140850688 + analystPageDatabase.getColor());
RenderUtil.drawSolidRect(getRenderArea(), analystPageDatabase.getColor());
}
}
private static class ItemScrollList extends Control {
private final Collection<IAlleleSpecies> options;
private final IBreedingSystem system;
private AnalystPageDatabase analystPageDatabase;
public ItemScrollList(final AnalystPageDatabase analystPageDatabase, Collection<IAlleleSpecies> options, IBreedingSystem system) {
super(analystPageDatabase.scroll, 0, 0, analystPageDatabase.scroll.getWidth(), analystPageDatabase.scroll.getHeight());
this.options = options;
this.system = system;
this.analystPageDatabase = analystPageDatabase;
}
@Override
public void initialise() {
int maxBiomePerLine = (getWidth() - 4 + 2) / 18;
int biomeListX = -6 + (getWidth() - (maxBiomePerLine * 18 - 2)) / 2;
int dx = 0;
int dy = 0;
for (IAlleleSpecies species : options) {
IIndividual ind = system.getSpeciesRoot().templateAsIndividual(system.getSpeciesRoot().getTemplate(species));
new SpeciesIndividualDisplay(this, biomeListX, dx, dy, ind, species);
dx += 18;
if (dx >= 18 * maxBiomePerLine) {
dx = 0;
dy += 18;
}
}
setSize(new Point(getWidth(), 4 + dy + 18));
}
private static class SpeciesIndividualDisplay extends ControlIndividualDisplay {
private final IIndividual ind;
private final IAlleleSpecies species;
private ItemScrollList itemScrollList;
public SpeciesIndividualDisplay(ItemScrollList itemScrollList, int biomeListX, int dx, int dy, IIndividual ind, IAlleleSpecies species) {
super(itemScrollList, biomeListX + dx, 2 + dy, ind);
this.ind = ind;
this.species = species;
this.itemScrollList = itemScrollList;
}
@Override
public void initialise() {
addSelfEventHandler(EventMouse.Down.class, event -> {
WindowAnalyst window = (WindowAnalyst) itemScrollList.analystPageDatabase.getTopParent();
window.setIndividual(ind);
});
}
@Override
@SideOnly(Side.CLIENT)
public void onRenderBackground(int guiWidth, int guiHeight) {
WindowAnalyst window = (WindowAnalyst) itemScrollList.analystPageDatabase.getTopParent();
if (window.getIndividual() != null && window.getIndividual().getGenome().getPrimary() == species) {
RenderUtil.setColour(15658734);
CraftGUI.RENDER.texture(CraftGUITexture.TAB_SOLID, getArea().outset(1));
RenderUtil.setColour(itemScrollList.analystPageDatabase.getColor());
CraftGUI.RENDER.texture(CraftGUITexture.TAB_OUTLINE, getArea().outset(1));
} else if (calculateIsMouseOver()) {
RenderUtil.setColour(15658734);
CraftGUI.RENDER.texture(CraftGUITexture.TAB_SOLID, getArea().outset(1));
}
super.onRenderBackground(guiWidth, guiHeight);
}
}
}
}
@@ -42,21 +42,7 @@ public class AnalystPageGenome extends Control implements ITitledWidget {
y += 16;
ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(ind);
IBreedingSystem system = Binnie.GENETICS.getSystem(root);
Control scaled = new Control(this, 0, y, 0, 0) {
@Override
@SideOnly(Side.CLIENT)
public void onRenderBackground(int guiWidth, int guiHeight) {
GlStateManager.pushMatrix();
GlStateManager.translate(10.0f, -15.0f, 0.0f);
GlStateManager.scale(0.9f, 0.95f, 1.0f);
}
@Override
@SideOnly(Side.CLIENT)
public void onRenderForeground(int guiWidth, int guiHeight) {
GlStateManager.popMatrix();
}
};
Control scaled = new Scaled(this, y);
for (IChromosomeType chromo : system.getActiveKaryotype()) {
IAllele allele = active ? ind.getGenome().getActiveAllele(chromo) : ind.getGenome().getInactiveAllele(chromo);
String alleleName = system.getAlleleName(chromo, allele);
@@ -78,4 +64,24 @@ public class AnalystPageGenome extends Control implements ITitledWidget {
}
return I18N.localise(AnalystConstants.GENOME_KEY + ".title", I18N.localise(stateKey));
}
private static class Scaled extends Control {
public Scaled(AnalystPageGenome analystPageGenome, int y) {
super(analystPageGenome, 0, y, 0, 0);
}
@Override
@SideOnly(Side.CLIENT)
public void onRenderBackground(int guiWidth, int guiHeight) {
GlStateManager.pushMatrix();
GlStateManager.translate(10.0f, -15.0f, 0.0f);
GlStateManager.scale(0.9f, 0.95f, 1.0f);
}
@Override
@SideOnly(Side.CLIENT)
public void onRenderForeground(int guiWidth, int guiHeight) {
GlStateManager.popMatrix();
}
}
}
@@ -21,56 +21,10 @@ public class AnalystPanel extends Panel {
this.window = window;
setColor(4473924);
int sectionWidth = (getWidth() - 8 - 4) / 2;
window.leftPage = new ControlScrollableContent<IWidget>(this, 3, 3, sectionWidth + 2, getHeight() - 8 + 2, 0) {
@Override
@SideOnly(Side.CLIENT)
public void onRenderBackground(int guiWidth, int guiHeight) {
if (getContent() == null) {
return;
}
RenderUtil.setColour(getContent().getColor());
CraftGUI.RENDER.texture(CraftGUITexture.TAB_OUTLINE, getArea());
}
};
new ControlScrollBar(this, sectionWidth + 2 - 3, 6, 3, getHeight() - 8 + 2 - 6, window.leftPage) {
@Override
@SideOnly(Side.CLIENT)
public void onRenderBackground(int guiWidth, int guiHeight) {
if (!isEnabled()) {
return;
}
if (window.leftPage.getContent() == null) {
return;
}
RenderUtil.drawGradientRect(getArea(), 1140850688 + window.leftPage.getContent().getColor(), 1140850688 + window.leftPage.getContent().getColor());
RenderUtil.drawSolidRect(getRenderArea(), window.leftPage.getContent().getColor());
}
};
window.rightPage = new ControlScrollableContent<IWidget>(this, 3 + sectionWidth + 4, 3, sectionWidth + 2, getHeight() - 8 + 2, 0) {
@Override
@SideOnly(Side.CLIENT)
public void onRenderBackground(int guiWidth, int guiHeight) {
if (getContent() == null) {
return;
}
RenderUtil.setColour(getContent().getColor());
CraftGUI.RENDER.texture(CraftGUITexture.TAB_OUTLINE, getArea());
}
};
new ControlScrollBar(this, sectionWidth + 2 - 3 + sectionWidth + 4, 6, 3, getHeight() - 8 + 2 - 6, window.rightPage) {
@Override
@SideOnly(Side.CLIENT)
public void onRenderBackground(int guiWidth, int guiHeight) {
if (!isEnabled()) {
return;
}
if (window.rightPage.getContent() == null) {
return;
}
RenderUtil.drawGradientRect(getArea(), 1140850688 + window.rightPage.getContent().getColor(), 1140850688 + window.rightPage.getContent().getColor());
RenderUtil.drawSolidRect(getRenderArea(), window.rightPage.getContent().getColor());
}
};
window.leftPage = new LeftPage(this, sectionWidth);
new LeftPageScrollBar(this, sectionWidth, window);
window.rightPage = new RightPage(this, sectionWidth);
new RightPageScrollBar(this, sectionWidth, window);
window.analystPageSize = new Area(1, 1, sectionWidth, getHeight() - 8);
}
@@ -80,4 +34,80 @@ public class AnalystPanel extends Panel {
RenderUtil.drawGradientRect(getArea(), 1157627903, 1728053247);
super.onRenderBackground(guiWidth, guiHeight);
}
private static class LeftPage extends ControlScrollableContent<IWidget> {
public LeftPage(AnalystPanel analystPanel, int sectionWidth) {
super(analystPanel, 3, 3, sectionWidth + 2, analystPanel.getHeight() - 8 + 2, 0);
}
@Override
@SideOnly(Side.CLIENT)
public void onRenderBackground(int guiWidth, int guiHeight) {
if (getContent() == null) {
return;
}
RenderUtil.setColour(getContent().getColor());
CraftGUI.RENDER.texture(CraftGUITexture.TAB_OUTLINE, getArea());
}
}
private static class LeftPageScrollBar extends ControlScrollBar {
private final WindowAnalyst window;
public LeftPageScrollBar(AnalystPanel analystPanel, int sectionWidth, WindowAnalyst window) {
super(analystPanel, sectionWidth + 2 - 3, 6, 3, analystPanel.getHeight() - 8 + 2 - 6, window.leftPage);
this.window = window;
}
@Override
@SideOnly(Side.CLIENT)
public void onRenderBackground(int guiWidth, int guiHeight) {
if (!isEnabled()) {
return;
}
if (window.leftPage.getContent() == null) {
return;
}
RenderUtil.drawGradientRect(getArea(), 1140850688 + window.leftPage.getContent().getColor(), 1140850688 + window.leftPage.getContent().getColor());
RenderUtil.drawSolidRect(getRenderArea(), window.leftPage.getContent().getColor());
}
}
private static class RightPage extends ControlScrollableContent<IWidget> {
public RightPage(AnalystPanel analystPanel, int sectionWidth) {
super(analystPanel, 3 + sectionWidth + 4, 3, sectionWidth + 2, analystPanel.getHeight() - 8 + 2, 0);
}
@Override
@SideOnly(Side.CLIENT)
public void onRenderBackground(int guiWidth, int guiHeight) {
if (getContent() == null) {
return;
}
RenderUtil.setColour(getContent().getColor());
CraftGUI.RENDER.texture(CraftGUITexture.TAB_OUTLINE, getArea());
}
}
private static class RightPageScrollBar extends ControlScrollBar {
private final WindowAnalyst window;
public RightPageScrollBar(AnalystPanel analystPanel, int sectionWidth, WindowAnalyst window) {
super(analystPanel, sectionWidth + 2 - 3 + sectionWidth + 4, 6, 3, analystPanel.getHeight() - 8 + 2 - 6, window.rightPage);
this.window = window;
}
@Override
@SideOnly(Side.CLIENT)
public void onRenderBackground(int guiWidth, int guiHeight) {
if (!isEnabled()) {
return;
}
if (window.rightPage.getContent() == null) {
return;
}
RenderUtil.drawGradientRect(getArea(), 1140850688 + window.rightPage.getContent().getColor(), 1140850688 + window.rightPage.getContent().getColor());
RenderUtil.drawSolidRect(getRenderArea(), window.rightPage.getContent().getColor());
}
}
}
@@ -87,12 +87,7 @@ public class WindowAnalyst extends Window {
private void setupValidators() {
if (!isDatabase) {
getWindowInventory().setValidator(0, new SlotValidator.Individual() {
@Override
public boolean isValid(ItemStack itemStack) {
return ManagerGenetics.isAnalysed(itemStack) || (ManagerGenetics.isAnalysable(itemStack) && !getWindowInventory().getStackInSlot(1).isEmpty());
}
});
getWindowInventory().setValidator(0, new AnalystSlotValidator(this));
getWindowInventory().setValidator(1, new SlotValidator.Item(GeneticsItems.DNADye.get(1), ModuleMachine.spriteDye));
}
}
@@ -151,13 +146,7 @@ public class WindowAnalyst extends Window {
}
});
if (!isDatabase) {
analystNone = new Control(analystPanel, 0, 0, analystPanel.getWidth(), analystPanel.getHeight()) {
@Override
public void initialise() {
new ControlTextCentered(this, 20, I18N.localise("genetics.gui.analyst.desc")).setColor(4473924);
new ControlPlayerInventory(this);
}
};
analystNone = new AnalystNoneControl(this);
}
setIndividual(null);
@@ -340,4 +329,38 @@ public class WindowAnalyst extends Window {
current = null;
updatePages(true);
}
private static class AnalystSlotValidator extends SlotValidator.Individual {
private WindowAnalyst windowAnalyst;
public AnalystSlotValidator(WindowAnalyst windowAnalyst) {
this.windowAnalyst = windowAnalyst;
}
@Override
public boolean isValid(ItemStack itemStack) {
if (ManagerGenetics.isAnalysed(itemStack)) {
return true;
}
if (ManagerGenetics.isAnalysable(itemStack)) {
WindowInventory windowInventory = windowAnalyst.getWindowInventory();
if (!windowInventory.getStackInSlot(1).isEmpty()) {
return true;
}
}
return false;
}
}
private static class AnalystNoneControl extends Control {
public AnalystNoneControl(WindowAnalyst windowAnalyst) {
super(windowAnalyst.analystPanel, 0, 0, windowAnalyst.analystPanel.getWidth(), windowAnalyst.analystPanel.getHeight());
}
@Override
public void initialise() {
new ControlTextCentered(this, 20, I18N.localise("genetics.gui.analyst.desc")).setColor(4473924);
new ControlPlayerInventory(this);
}
}
}
@@ -87,35 +87,47 @@ public class AnalystPageClimate<T extends IIndividual> extends Control implement
}
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) {
return value.name;
}
@Override
protected int getColour(EnumTemperature value) {
return (new int[]{65531, 7912447, 5242672, 16776960, 16753152, 16711680})[value.ordinal() - 1];
}
}.setValues(value, tol);
new TemperatureBar(parent, x, y, w, h).setValues(value, 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) {
return value.name;
}
@Override
protected int getColour(EnumHumidity value) {
return (new int[]{16770979, 1769216, 3177727})[value.ordinal()];
}
}.setValues(value, tol);
new HumidityBar(parent, x, y, w, h).setValues(value, tol);
}
@Override
public String getTitle() {
return I18N.localise(AnalystConstants.CLIMATE_KEY + ".title");
}
private static class TemperatureBar extends ControlToleranceBar<EnumTemperature> {
public TemperatureBar(IWidget parent, int x, int y, int w, int h) {
super(parent, x, y, w, h, EnumTemperature.class);
}
@Override
protected String getName(EnumTemperature value) {
return value.name;
}
@Override
protected int getColour(EnumTemperature value) {
return (new int[]{65531, 7912447, 5242672, 16776960, 16753152, 16711680})[value.ordinal() - 1];
}
}
private static class HumidityBar extends ControlToleranceBar<EnumHumidity> {
public HumidityBar(IWidget parent, int x, int y, int w, int h) {
super(parent, x, y, w, h, EnumHumidity.class);
}
@Override
protected String getName(EnumHumidity value) {
return value.name;
}
@Override
protected int getColour(EnumHumidity value) {
return (new int[]{16770979, 1769216, 3177727})[value.ordinal()];
}
}
}
@@ -0,0 +1,18 @@
package binnie.genetics.machine;
import binnie.core.machines.inventory.TankValidator;
import forestry.core.fluids.Fluids;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
public class EthanolTankValidator extends TankValidator {
@Override
public String getTooltip() {
return FluidRegistry.getFluidStack(Fluids.BIO_ETHANOL.getTag(), 1).getLocalizedName();
}
@Override
public boolean isValid(final FluidStack stack) {
return Fluids.BIO_ETHANOL.getTag().equals(stack.getFluid().getName());
}
}
@@ -14,6 +14,7 @@ import binnie.core.machines.power.ComponentPowerReceptor;
import binnie.genetics.core.GeneticsGUI;
import binnie.genetics.machine.ComponentGeneticGUI;
import binnie.genetics.machine.GeneticMachine;
import net.minecraft.util.NonNullList;
public class PackageAcclimatiser extends GeneticMachine.PackageGeneticBase implements IMachineInformation {
public PackageAcclimatiser() {
@@ -41,11 +42,9 @@ public class PackageAcclimatiser extends GeneticMachine.PackageGeneticBase imple
}
final ComponentInventoryTransfer transfer = new ComponentInventoryTransfer(machine);
transfer.addRestock(Acclimatiser.SLOT_RESERVE, Acclimatiser.SLOT_TARGET, 1);
transfer.addStorage(Acclimatiser.SLOT_TARGET, Acclimatiser.SLOT_DRONE, new ComponentInventoryTransfer.Condition() {
@Override
public boolean fulfilled(final ItemStack stack) {
return !Acclimatiser.canAcclimatise(stack, machine.getMachineUtil().getNonEmptyStacks(Acclimatiser.SLOT_ACCLIMATISER));
}
transfer.addStorage(Acclimatiser.SLOT_TARGET, Acclimatiser.SLOT_DRONE, (stack) -> {
NonNullList<ItemStack> stacks = machine.getMachineUtil().getNonEmptyStacks(Acclimatiser.SLOT_ACCLIMATISER);
return !Acclimatiser.canAcclimatise(stack, stacks);
});
new ComponentPowerReceptor(machine, 5000);
new AcclimatiserLogic(machine);
@@ -3,6 +3,7 @@ package binnie.genetics.machine.analyser;
import java.util.Random;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.particle.ParticleManager;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
import net.minecraft.entity.item.EntityItem;
@@ -33,36 +34,8 @@ public class AnalyserFX extends MachineComponent implements IRender.DisplayTick,
@Override
public void onDisplayTick(World world, BlockPos pos, Random rand) {
if (rand.nextFloat() < 1.0f && this.getUtil().getProcess().isInProgress()) {
BinnieCore.getBinnieProxy().getMinecraftInstance().effectRenderer.addEffect(new Particle(world, pos.getX() + 0.5, pos.getY() + 1.3 + rand.nextDouble() * 0.2, pos.getZ() + 0.5, 0.0, 0.0, 0.0) {
double axisX = this.posX;
double axisZ = this.posZ;
double angle = this.rand.nextDouble() * 2.0 * 3.1415;
{
this.axisX = 0.0;
this.axisZ = 0.0;
this.angle = 0.0;
this.motionX = 0.05 * (this.rand.nextDouble() - 0.5);
this.motionZ = 0.05 * (this.rand.nextDouble() - 0.5);
this.motionY = 0.0;
this.particleMaxAge = 25;
this.particleGravity = 0.05f;
this.canCollide = true;
this.setRBGColorF(0.6f, 0.0f, 1.0f);
}
@Override
@SideOnly(Side.CLIENT)
public void onUpdate() {
super.onUpdate();
this.setAlphaF((float) Math.cos(1.57 * this.particleAge / this.particleMaxAge));
}
@Override
public int getFXLayer() {
return 0;
}
});
ParticleManager effectRenderer = BinnieCore.getBinnieProxy().getMinecraftInstance().effectRenderer;
effectRenderer.addEffect(new AnalyserParticle(world, pos, rand));
}
}
@@ -118,4 +91,39 @@ public class AnalyserFX extends MachineComponent implements IRender.DisplayTick,
//this.getMachine().getWorld().markBlockForUpdate(this.getMachine().getTileEntity().xCoord, this.getMachine().getTileEntity().yCoord, this.getMachine().getTileEntity().zCoord);
}
}
private static class AnalyserParticle extends Particle {
private double axisX;
private double axisZ;
private double angle;
public AnalyserParticle(World world, BlockPos pos, Random rand) {
super(world, pos.getX() + 0.5, pos.getY() + 1.3 + rand.nextDouble() * 0.2, pos.getZ() + 0.5, 0.0, 0.0, 0.0);
axisX = this.posX;
axisZ = this.posZ;
angle = this.rand.nextDouble() * 2.0 * 3.1415;
this.axisX = 0.0;
this.axisZ = 0.0;
this.angle = 0.0;
this.motionX = 0.05 * (this.rand.nextDouble() - 0.5);
this.motionZ = 0.05 * (this.rand.nextDouble() - 0.5);
this.motionY = 0.0;
this.particleMaxAge = 25;
this.particleGravity = 0.05f;
this.canCollide = true;
this.setRBGColorF(0.6f, 0.0f, 1.0f);
}
@Override
@SideOnly(Side.CLIENT)
public void onUpdate() {
super.onUpdate();
this.setAlphaF((float) Math.cos(1.57 * this.particleAge / this.particleMaxAge));
}
@Override
public int getFXLayer() {
return 0;
}
}
}
@@ -37,29 +37,14 @@ public class PackageAnalyser extends GeneticMachine.PackageGeneticBase implement
slotTarget.forbidInteraction();
InventorySlot slotDye = inventory.addSlot(Analyser.SLOT_DYE, "dye");
slotDye.forbidExtraction();
slotDye.setValidator(new SlotValidator(ModuleMachine.spriteDye) {
@Override
public boolean isValid(final ItemStack itemStack) {
return itemStack.isItemEqual(GeneticsItems.DNADye.get(1));
}
@Override
public String getTooltip() {
return GeneticsItems.DNADye.get(1).getDisplayName();
}
});
slotDye.setValidator(new DyeSlotValidator());
for (InventorySlot slot : inventory.addSlotArray(Analyser.SLOT_FINISHED, "output")) {
slot.forbidInsertion();
slot.setReadOnly();
}
ComponentInventoryTransfer transfer = new ComponentInventoryTransfer(machine);
transfer.addRestock(Analyser.SLOT_RESERVE, 6, 1);
transfer.addStorage(6, Analyser.SLOT_FINISHED, new ComponentInventoryTransfer.Condition() {
@Override
public boolean fulfilled(final ItemStack stack) {
return ManagerGenetics.isAnalysed(stack);
}
});
transfer.addStorage(6, Analyser.SLOT_FINISHED, (stack) -> ManagerGenetics.isAnalysed(stack));
new ComponentChargedSlots(machine).addCharge(13);
new ComponentPowerReceptor(machine, 500);
new AnalyserLogic(machine);
@@ -74,4 +59,20 @@ public class PackageAnalyser extends GeneticMachine.PackageGeneticBase implement
@Override
public void register() {
}
private static class DyeSlotValidator extends SlotValidator {
public DyeSlotValidator() {
super(ModuleMachine.spriteDye);
}
@Override
public boolean isValid(final ItemStack itemStack) {
return itemStack.isItemEqual(GeneticsItems.DNADye.get(1));
}
@Override
public String getTooltip() {
return GeneticsItems.DNADye.get(1).getDisplayName();
}
}
}
@@ -110,31 +110,7 @@ public class WindowGeneBank extends WindowMachine {
this.genes = new ControlGeneScroll(scroll, 1, 1, geneBoxWidth, 116);
scroll.setScrollableContent(this.genes);
this.genes.setGenes(Binnie.GENETICS.getFirstActiveSystem());
final ControlTabBar<IBreedingSystem> tabBar = new ControlTabBar<IBreedingSystem>(this, boxX, 32, 24, 120, Alignment.LEFT, Binnie.GENETICS.getActiveSystems()) {
@Override
public ControlTab<IBreedingSystem> createTab(final int x, final int y, final int w, final int h, final IBreedingSystem value) {
return new ControlTabIcon<IBreedingSystem>(this, x, y, w, h, value) {
@Override
public void getTooltip(final Tooltip tooltip, ITooltipFlag tooltipFlag) {
tooltip.add(this.getValue().toString());
int totalGenes = 0;
int seqGenes = 0;
final GeneTracker tracker = GeneTracker.getTracker(WindowGeneBank.this.getWorld(), WindowGeneBank.this.getUsername());
final Map<IChromosomeType, List<IAllele>> genes = Binnie.GENETICS.getChromosomeMap(this.getValue().getSpeciesRoot());
for (final Map.Entry<IChromosomeType, List<IAllele>> entry : genes.entrySet()) {
totalGenes += entry.getValue().size();
for (final IAllele allele : entry.getValue()) {
final Gene gene = new Gene(allele, entry.getKey(), this.getValue().getSpeciesRoot());
if (tracker.isSequenced(gene)) {
++seqGenes;
}
}
}
tooltip.add("" + seqGenes + "/" + totalGenes + " Genes");
}
};
}
};
final ControlTabBar<IBreedingSystem> tabBar = new GeneBankTabBar(this, boxX);
tabBar.setValue(Binnie.GENETICS.getFirstActiveSystem());
boxX -= 8;
final ControlTabBar<String> infoTabs = new ControlTabBar<>(this, boxX + 8, 160, 16, 50, Alignment.LEFT, Arrays.asList("Info", "Stats", "Ranking"));
@@ -187,4 +163,46 @@ public class WindowGeneBank extends WindowMachine {
return this.system.getChromosomeName(this.chromosome);
}
}
private static class GeneBankTabBar extends ControlTabBar<IBreedingSystem> {
private WindowGeneBank windowGeneBank;
public GeneBankTabBar(final WindowGeneBank windowGeneBank, int boxX) {
super(windowGeneBank, boxX, 32, 24, 120, Alignment.LEFT, Binnie.GENETICS.getActiveSystems());
this.windowGeneBank = windowGeneBank;
}
@Override
public ControlTab<IBreedingSystem> createTab(final int x, final int y, final int w, final int h, final IBreedingSystem value) {
return new GeneBankTab(this, x, y, w, h, value);
}
private static class GeneBankTab extends ControlTabIcon<IBreedingSystem> {
private GeneBankTabBar geneBankTabBar;
public GeneBankTab(GeneBankTabBar geneBankTabBar, int x, int y, int w, int h, IBreedingSystem value) {
super(geneBankTabBar, x, y, w, h, value);
this.geneBankTabBar = geneBankTabBar;
}
@Override
public void getTooltip(final Tooltip tooltip, ITooltipFlag tooltipFlag) {
tooltip.add(this.getValue().toString());
int totalGenes = 0;
int seqGenes = 0;
final GeneTracker tracker = GeneTracker.getTracker(geneBankTabBar.windowGeneBank.getWorld(), geneBankTabBar.windowGeneBank.getUsername());
final Map<IChromosomeType, List<IAllele>> genes = Binnie.GENETICS.getChromosomeMap(this.getValue().getSpeciesRoot());
for (final Map.Entry<IChromosomeType, List<IAllele>> entry : genes.entrySet()) {
totalGenes += entry.getValue().size();
for (final IAllele allele : entry.getValue()) {
final Gene gene = new Gene(allele, entry.getKey(), this.getValue().getSpeciesRoot());
if (tracker.isSequenced(gene)) {
++seqGenes;
}
}
}
tooltip.add("" + seqGenes + "/" + totalGenes + " Genes");
}
}
}
}
@@ -1,12 +1,8 @@
package binnie.genetics.machine.genepool;
import binnie.genetics.machine.EthanolTankValidator;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import forestry.core.fluids.Fluids;
import binnie.core.gui.minecraft.IMachineInformation;
import binnie.core.machines.Machine;
import binnie.core.machines.TileEntityMachine;
@@ -17,7 +13,6 @@ import binnie.core.machines.inventory.ComponentTankContainer;
import binnie.core.machines.inventory.InventorySlot;
import binnie.core.machines.inventory.SlotValidator;
import binnie.core.machines.inventory.TankSlot;
import binnie.core.machines.inventory.TankValidator;
import binnie.core.machines.power.ComponentPowerReceptor;
import binnie.genetics.core.GeneticsGUI;
import binnie.genetics.item.GeneticsItems;
@@ -50,17 +45,7 @@ public class PackageGenepool extends GeneticMachine.PackageGeneticBase implement
tankDNA.setReadOnly();
TankSlot tankEthanol = tanks.addTank(Genepool.TANK_ETHANOL, "input", 1000);
tankEthanol.forbidExtraction();
tankEthanol.setValidator(new TankValidator() {
@Override
public String getTooltip() {
return FluidRegistry.getFluidStack(Fluids.BIO_ETHANOL.getTag(), 1).getLocalizedName();
}
@Override
public boolean isValid(final FluidStack stack) {
return Fluids.BIO_ETHANOL.getTag().equals(stack.getFluid().getName());
}
});
tankEthanol.setValidator(new EthanolTankValidator());
ComponentInventoryTransfer transfer = new ComponentInventoryTransfer(machine);
transfer.addRestock(Genepool.SLOT_RESERVE, Genepool.SLOT_BEE, 1);
new ComponentPowerReceptor(machine, 1600);
@@ -78,4 +63,5 @@ public class PackageGenepool extends GeneticMachine.PackageGeneticBase implement
@Override
public void register() {
}
}
@@ -44,22 +44,8 @@ public class Incubator {
Incubator.RECIPES.add(new IncubatorRecipe(new ItemStack(Items.BLAZE_POWDER), GeneticLiquid.Bacteria.get(10), GeneticLiquid.BacteriaVector.get(10), 0.05f));
if (BinnieCore.isApicultureActive()) {
final ItemStack beeLarvaeWildcard = Mods.Forestry.stack("bee_larvae_ge", 1, OreDictionary.WILDCARD_VALUE);
Incubator.RECIPES.add(LARVAE_RECIPE = new IncubatorRecipeLarvae(beeLarvaeWildcard, GeneticLiquid.GrowthMedium.get(50), null, 1.0f, 0.05f) {
@Override
public ItemStack getOutputStack(final MachineUtil machine) {
final ItemStack larvae = machine.getStack(3);
final IBee bee = BeeManager.beeRoot.getMember(larvae);
if (bee == null) {
return ItemStack.EMPTY;
}
return BeeManager.beeRoot.getMemberStack(bee, EnumBeeType.DRONE);
}
@Override
public ItemStack getExpectedOutput() {
return Mods.Forestry.stack("bee_drone_ge", 1, OreDictionary.WILDCARD_VALUE);
}
});
LARVAE_RECIPE = new IncubatorRecipeLarvae(beeLarvaeWildcard);
Incubator.RECIPES.add(LARVAE_RECIPE);
}
}
@@ -1,13 +1,32 @@
package binnie.genetics.machine.incubator;
import javax.annotation.Nullable;
import binnie.core.Mods;
import binnie.core.machines.MachineUtil;
import binnie.genetics.item.GeneticLiquid;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.IBee;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.oredict.OreDictionary;
public class IncubatorRecipeLarvae extends IncubatorRecipe {
public IncubatorRecipeLarvae(ItemStack itemStack, FluidStack input, @Nullable FluidStack output, float lossChance, float chance) {
super(itemStack, input, output, lossChance, chance);
public IncubatorRecipeLarvae(ItemStack beeLarvaeWildcard) {
super(beeLarvaeWildcard, GeneticLiquid.GrowthMedium.get(50), null, 1.0f, 0.05f);
}
@Override
public ItemStack getOutputStack(final MachineUtil machine) {
final ItemStack larvae = machine.getStack(3);
final IBee bee = BeeManager.beeRoot.getMember(larvae);
if (bee == null) {
return ItemStack.EMPTY;
}
return BeeManager.beeRoot.getMemberStack(bee, EnumBeeType.DRONE);
}
@Override
public ItemStack getExpectedOutput() {
return Mods.Forestry.stack("bee_drone_ge", 1, OreDictionary.WILDCARD_VALUE);
}
}
@@ -1,5 +1,6 @@
package binnie.genetics.machine.inoculator;
import binnie.core.machines.inventory.TankValidator;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
@@ -15,7 +16,6 @@ import binnie.core.machines.inventory.ComponentInventoryTransfer;
import binnie.core.machines.inventory.ComponentTankContainer;
import binnie.core.machines.inventory.InventorySlot;
import binnie.core.machines.inventory.SlotValidator;
import binnie.core.machines.inventory.Validator;
import binnie.core.machines.power.ComponentPowerReceptor;
import binnie.genetics.api.IItemSerum;
import binnie.genetics.core.GeneticsGUI;
@@ -37,17 +37,7 @@ public class PackageInoculator extends GeneticMachine.PackageGeneticBase impleme
InventorySlot slotSerumVial = inventory.addSlot(Inoculator.SLOT_SERUM_VIAL, "serum.active");
slotSerumVial.forbidInteraction();
slotSerumVial.setReadOnly();
final SlotValidator serumValid = new SlotValidator(ModuleMachine.spriteSerum) {
@Override
public boolean isValid(final ItemStack itemStack) {
return itemStack.getItem() instanceof IItemSerum;
}
@Override
public String getTooltip() {
return "Serum Vials & Arrays";
}
};
final SlotValidator serumValid = new SerumSlotValidator();
slotSerumVial.setValidator(serumValid);
for (InventorySlot slot : inventory.addSlotArray(Inoculator.SLOT_SERUM_RESERVE, "serum.input")) {
slot.setValidator(serumValid);
@@ -73,39 +63,21 @@ public class PackageInoculator extends GeneticMachine.PackageGeneticBase impleme
final ComponentInventoryTransfer transfer = new ComponentInventoryTransfer(machine);
transfer.addRestock(Inoculator.SLOT_RESERVE, 9, 1);
transfer.addRestock(Inoculator.SLOT_SERUM_RESERVE, 0);
transfer.addStorage(Inoculator.SLOT_SERUM_VIAL, Inoculator.SLOT_SERUM_EXPENDED, new ComponentInventoryTransfer.Condition() {
@Override
public boolean fulfilled(final ItemStack stack) {
return Engineering.getCharges(stack) == 0;
}
});
transfer.addStorage(Inoculator.SLOT_TARGET, Inoculator.SLOT_FINISHED, new ComponentInventoryTransfer.Condition() {
@Override
public boolean fulfilled(final ItemStack stack) {
if (!stack.isEmpty()) {
IMachine machine = this.transfer.getMachine();
MachineUtil machineUtil = machine.getMachineUtil();
if (!machineUtil.getStack(Inoculator.SLOT_SERUM_VIAL).isEmpty() && machine.getInterface(InoculatorLogic.class).isValidSerum() != null) {
return true;
}
transfer.addStorage(Inoculator.SLOT_SERUM_VIAL, Inoculator.SLOT_SERUM_EXPENDED, (stack) -> Engineering.getCharges(stack) == 0);
transfer.addStorage(Inoculator.SLOT_TARGET, Inoculator.SLOT_FINISHED, (stack) -> {
if (!stack.isEmpty()) {
IMachine machine1 = transfer.getMachine();
MachineUtil machineUtil = machine1.getMachineUtil();
if (!machineUtil.getStack(Inoculator.SLOT_SERUM_VIAL).isEmpty() && machine1.getInterface(InoculatorLogic.class).isValidSerum() != null) {
return true;
}
return false;
}
return false;
});
new ComponentPowerReceptor(machine, 15000);
new InoculatorLogic(machine);
new InoculatorFX(machine);
new ComponentTankContainer(machine).addTank(Inoculator.TANK_VEKTOR, "input", 1000).setValidator(new Validator<FluidStack>() {
@Override
public boolean isValid(final FluidStack object) {
return GeneticLiquid.BacteriaVector.get(1).isFluidEqual(object);
}
@Override
public String getTooltip() {
return GeneticLiquid.BacteriaVector.toString();
}
});
new ComponentTankContainer(machine).addTank(Inoculator.TANK_VEKTOR, "input", 1000).setValidator(new BacteriaVectorTankValidator());
}
@Override
@@ -116,4 +88,32 @@ public class PackageInoculator extends GeneticMachine.PackageGeneticBase impleme
@Override
public void register() {
}
private static class SerumSlotValidator extends SlotValidator {
public SerumSlotValidator() {
super(ModuleMachine.spriteSerum);
}
@Override
public boolean isValid(final ItemStack itemStack) {
return itemStack.getItem() instanceof IItemSerum;
}
@Override
public String getTooltip() {
return "Serum Vials & Arrays";
}
}
private static class BacteriaVectorTankValidator extends TankValidator {
@Override
public boolean isValid(final FluidStack object) {
return GeneticLiquid.BacteriaVector.get(1).isFluidEqual(object);
}
@Override
public String getTooltip() {
return GeneticLiquid.BacteriaVector.toString();
}
}
}
@@ -2,6 +2,7 @@ package binnie.genetics.machine.isolator;
import java.util.Objects;
import binnie.genetics.machine.EthanolTankValidator;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.fluids.FluidRegistry;
@@ -57,17 +58,7 @@ public class PackageIsolator extends GeneticMachine.PackageGeneticBase implement
slot.forbidInsertion();
}
final ComponentTankContainer tanks = new ComponentTankContainer(machine);
tanks.addTank(Isolator.TANK_ETHANOL, "input", 1000).setValidator(new TankValidator() {
@Override
public String getTooltip() {
return FluidRegistry.getFluidStack(Fluids.BIO_ETHANOL.getTag(), 1).getLocalizedName();
}
@Override
public boolean isValid(final FluidStack stack) {
return Objects.equals(stack.getFluid().getName(), Fluids.BIO_ETHANOL.getTag());
}
});
tanks.addTank(Isolator.TANK_ETHANOL, "input", 1000).setValidator(new EthanolTankValidator());
final ComponentChargedSlots chargedSlots = new ComponentChargedSlots(machine);
chargedSlots.addCharge(Isolator.SLOT_ENZYME);
final ComponentInventoryTransfer transfer = new ComponentInventoryTransfer(machine);
@@ -1,5 +1,6 @@
package binnie.genetics.machine.polymeriser;
import binnie.core.machines.inventory.TankValidator;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
@@ -51,35 +52,10 @@ public class PackagePolymeriser extends GeneticMachine.PackageGeneticBase implem
}
ComponentInventoryTransfer transfer = new ComponentInventoryTransfer(machine);
transfer.addRestock(Polymeriser.SLOT_SERUM_RESERVE, Polymeriser.SLOT_SERUM, 1);
transfer.addStorage(Polymeriser.SLOT_SERUM, Polymeriser.SLOT_SERUM_FINISHED, new ComponentInventoryTransfer.Condition() {
@Override
public boolean fulfilled(final ItemStack stack) {
return !stack.isItemDamaged();
}
});
transfer.addStorage(Polymeriser.SLOT_SERUM, Polymeriser.SLOT_SERUM_FINISHED, (stack) -> !stack.isItemDamaged());
ComponentTankContainer tank = new ComponentTankContainer(machine);
tank.addTank(Polymeriser.TANK_BACTERIA, "input", 1000).setValidator(new Validator<FluidStack>() {
@Override
public boolean isValid(final FluidStack itemStack) {
return GeneticLiquid.BacteriaPoly.get(1).isFluidEqual(itemStack);
}
@Override
public String getTooltip() {
return GeneticLiquid.BacteriaPoly.get(1).getLocalizedName();
}
});
tank.addTank(Polymeriser.TANK_DNA, "input", 1000).setValidator(new Validator<FluidStack>() {
@Override
public boolean isValid(final FluidStack itemStack) {
return GeneticLiquid.RawDNA.get(1).isFluidEqual(itemStack);
}
@Override
public String getTooltip() {
return GeneticLiquid.RawDNA.get(1).getLocalizedName();
}
});
tank.addTank(Polymeriser.TANK_BACTERIA, "input", 1000).setValidator(new BacteriaTankValidator());
tank.addTank(Polymeriser.TANK_DNA, "input", 1000).setValidator(new DnaTankValidator());
new ComponentChargedSlots(machine).addCharge(1);
new ComponentPowerReceptor(machine, 8000);
new PolymeriserLogic(machine);
@@ -94,4 +70,28 @@ public class PackagePolymeriser extends GeneticMachine.PackageGeneticBase implem
@Override
public void register() {
}
private static class BacteriaTankValidator extends TankValidator {
@Override
public boolean isValid(final FluidStack itemStack) {
return GeneticLiquid.BacteriaPoly.get(1).isFluidEqual(itemStack);
}
@Override
public String getTooltip() {
return GeneticLiquid.BacteriaPoly.get(1).getLocalizedName();
}
}
private static class DnaTankValidator extends TankValidator {
@Override
public boolean isValid(final FluidStack itemStack) {
return GeneticLiquid.RawDNA.get(1).isFluidEqual(itemStack);
}
@Override
public String getTooltip() {
return GeneticLiquid.RawDNA.get(1).getLocalizedName();
}
}
}
@@ -33,17 +33,7 @@ public class PackageSplicer extends AdvGeneticMachine.PackageAdvGeneticBase impl
InventorySlot slotSerumVial = inventory.addSlot(Splicer.SLOT_SERUM_VIAL, "serum.active");
slotSerumVial.forbidInteraction();
slotSerumVial.setReadOnly();
final SlotValidator serumValid = new SlotValidator(ModuleMachine.spriteSerum) {
@Override
public boolean isValid(final ItemStack itemStack) {
return itemStack.getItem() instanceof IItemSerum;
}
@Override
public String getTooltip() {
return I18N.localise("genetics.machine.adv_machine.splicer.tooltips.slots.serum");
}
};
final SlotValidator serumValid = new SerumSlotValidator();
slotSerumVial.setValidator(serumValid);
for (InventorySlot slot : inventory.addSlotArray(Splicer.SLOT_SERUM_RESERVE, "serum.input")) {
slot.setValidator(serumValid);
@@ -69,24 +59,16 @@ public class PackageSplicer extends AdvGeneticMachine.PackageAdvGeneticBase impl
final ComponentInventoryTransfer transfer = new ComponentInventoryTransfer(machine);
transfer.addRestock(Splicer.SLOT_RESERVE, Splicer.SLOT_TARGET, 1);
transfer.addRestock(Splicer.SLOT_SERUM_RESERVE, Splicer.SLOT_SERUM_VIAL);
transfer.addStorage(Splicer.SLOT_SERUM_VIAL, Splicer.SLOT_SERUM_EXPENDED, new ComponentInventoryTransfer.Condition() {
@Override
public boolean fulfilled(final ItemStack stack) {
return Engineering.getCharges(stack) == 0;
}
});
transfer.addStorage(Splicer.SLOT_TARGET, Splicer.SLOT_FINISHED, new ComponentInventoryTransfer.Condition() {
@Override
public boolean fulfilled(final ItemStack stack) {
if (!stack.isEmpty()) {
IMachine machine = this.transfer.getMachine();
MachineUtil machineUtil = machine.getMachineUtil();
if (!machineUtil.getStack(Splicer.SLOT_SERUM_VIAL).isEmpty() && machine.getInterface(SplicerLogic.class).isValidSerum() != null) {
return true;
}
transfer.addStorage(Splicer.SLOT_SERUM_VIAL, Splicer.SLOT_SERUM_EXPENDED, (stack) -> Engineering.getCharges(stack) == 0);
transfer.addStorage(Splicer.SLOT_TARGET, Splicer.SLOT_FINISHED, (stack) -> {
if (!stack.isEmpty()) {
IMachine machine1 = transfer.getMachine();
MachineUtil machineUtil = machine1.getMachineUtil();
if (!machineUtil.getStack(Splicer.SLOT_SERUM_VIAL).isEmpty() && machine1.getInterface(SplicerLogic.class).isValidSerum() != null) {
return true;
}
return false;
}
return false;
});
new ComponentPowerReceptor(machine, 20000);
new SplicerLogic(machine);
@@ -101,4 +83,20 @@ public class PackageSplicer extends AdvGeneticMachine.PackageAdvGeneticBase impl
@Override
public void register() {
}
private static class SerumSlotValidator extends SlotValidator {
public SerumSlotValidator() {
super(ModuleMachine.spriteSerum);
}
@Override
public boolean isValid(final ItemStack itemStack) {
return itemStack.getItem() instanceof IItemSerum;
}
@Override
public String getTooltip() {
return I18N.localise("genetics.machine.adv_machine.splicer.tooltips.slots.serum");
}
}
}
@@ -3,6 +3,7 @@ package binnie.genetics.machine.splicer;
import java.util.Random;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.particle.ParticleManager;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
import net.minecraft.entity.item.EntityItem;
@@ -34,40 +35,8 @@ public class SplicerFX extends MachineComponent implements IRender.DisplayTick,
public void onDisplayTick(World world, BlockPos pos, Random rand) {
final int tick = (int) (world.getTotalWorldTime() % 3L);
if (tick == 0 && this.getUtil().getProcess().isInProgress()) {
BinnieCore.getBinnieProxy().getMinecraftInstance().effectRenderer.addEffect(new Particle(world, pos.getX() + 0.5, pos.getY() + 1.5, pos.getZ() + 0.5, 0.0, 0.0, 0.0) {
double axisX = this.posX;
double axisZ = this.posZ;
double angle = (int) (this.world.getTotalWorldTime() % 4L) * 0.5 * 3.1415;
{
this.axisX = 0.0;
this.axisZ = 0.0;
this.angle = 0.0;
this.motionX = 0.0;
this.motionZ = 0.0;
this.motionY = (this.rand.nextDouble() - 0.5) * 0.02;
this.particleMaxAge = 240;
this.particleGravity = 0.0f;
this.canCollide = true;
this.setRBGColorF(0.3f + this.rand.nextFloat() * 0.5f, 0.3f + this.rand.nextFloat() * 0.5f, 0.0f);
}
@Override
@SideOnly(Side.CLIENT)
public void onUpdate() {
super.onUpdate();
final double speed = 0.04;
this.angle -= speed;
final double dist = 0.25 + 0.2 * Math.sin(this.particleAge / 50.0f);
this.setPosition(this.axisX + dist * Math.sin(this.angle), this.posY, this.axisZ + dist * Math.cos(this.angle));
this.setAlphaF((float) Math.cos(1.57 * this.particleAge / this.particleMaxAge));
}
@Override
public int getFXLayer() {
return 0;
}
});
ParticleManager effectRenderer = BinnieCore.getBinnieProxy().getMinecraftInstance().effectRenderer;
effectRenderer.addEffect(new SplicerParticle(world, pos));
}
}
@@ -123,4 +92,43 @@ public class SplicerFX extends MachineComponent implements IRender.DisplayTick,
}
this.getUtil().refreshBlock();
}
private static class SplicerParticle extends Particle {
private double axisX;
private double axisZ;
private double angle;
public SplicerParticle(World world, BlockPos pos) {
super(world, pos.getX() + 0.5, pos.getY() + 1.5, pos.getZ() + 0.5, 0.0, 0.0, 0.0);
axisX = this.posX;
axisZ = this.posZ;
angle = (int) (this.world.getTotalWorldTime() % 4L) * 0.5 * 3.1415;
this.axisX = 0.0;
this.axisZ = 0.0;
this.angle = 0.0;
this.motionX = 0.0;
this.motionZ = 0.0;
this.motionY = (this.rand.nextDouble() - 0.5) * 0.02;
this.particleMaxAge = 240;
this.particleGravity = 0.0f;
this.canCollide = true;
this.setRBGColorF(0.3f + this.rand.nextFloat() * 0.5f, 0.3f + this.rand.nextFloat() * 0.5f, 0.0f);
}
@Override
@SideOnly(Side.CLIENT)
public void onUpdate() {
super.onUpdate();
final double speed = 0.04;
this.angle -= speed;
final double dist = 0.25 + 0.2 * Math.sin(this.particleAge / 50.0f);
this.setPosition(this.axisX + dist * Math.sin(this.angle), this.posY, this.axisZ + dist * Math.cos(this.angle));
this.setAlphaF((float) Math.cos(1.57 * this.particleAge / this.particleMaxAge));
}
@Override
public int getFXLayer() {
return 0;
}
}
}