mirror of
https://github.com/GTNewHorizons/BeeBetterAtBees-GTNH.git
synced 2026-11-25 14:24:27 +00:00
Merge pull request #4 from GTNewHorizons/fix-nei-rendering
Remove unnecessary glDepthMask calls
This commit is contained in:
9 files changed
+57
-83
No files matched your search
+2
-2
@@ -34,6 +34,6 @@
|
||||
* For more details, see https://docs.gradle.org/8.0.1/userguide/java_library_plugin.html#sec:java_library_configurations_graph
|
||||
*/
|
||||
dependencies {
|
||||
api "com.github.GTNewHorizons:NotEnoughItems:2.5.4-GTNH:dev"
|
||||
api "com.github.GTNewHorizons:ForestryMC:4.8.2:dev"
|
||||
api "com.github.GTNewHorizons:NotEnoughItems:2.6.1-GTNH:dev"
|
||||
api "com.github.GTNewHorizons:ForestryMC:4.9.3:dev"
|
||||
}
|
||||
+6
-5
@@ -33,7 +33,7 @@ channel = stable
|
||||
mappingsVersion = 12
|
||||
|
||||
# Defines other MCP mappings for dependency deobfuscation.
|
||||
remoteMappings = https://raw.githubusercontent.com/MinecraftForge/FML/1.7.10/conf/
|
||||
remoteMappings = https\://raw.githubusercontent.com/MinecraftForge/FML/1.7.10/conf/
|
||||
|
||||
# Select a default username for testing your mod. You can always override this per-run by running
|
||||
# `./gradlew runClient --username=AnotherPlayer`, or configuring this command in your IDE.
|
||||
@@ -61,6 +61,9 @@ gradleTokenModId =
|
||||
# [DEPRECATED] Mod name replacement token.
|
||||
gradleTokenModName =
|
||||
|
||||
# [DEPRECATED] Mod Group replacement token.
|
||||
gradleTokenGroupName =
|
||||
|
||||
# [DEPRECATED]
|
||||
# Multiple source files can be defined here by providing a comma-separated list: Class1.java,Class2.java,Class3.java
|
||||
# public static final String VERSION = "GRADLETOKEN_VERSION";
|
||||
@@ -114,7 +117,7 @@ minimizeShadowedDependencies = true
|
||||
# If disabled, won't rename the shadowed classes.
|
||||
relocateShadowedDependencies = true
|
||||
|
||||
# Adds the GTNH maven, CurseMaven, IC2/Player maven, and some more well-known 1.7.10 repositories.
|
||||
# Adds the GTNH maven, CurseMaven, Modrinth, and some more well-known 1.7.10 repositories.
|
||||
includeWellKnownRepositories = true
|
||||
|
||||
# Change these to your Maven coordinates if you want to publish to a custom Maven repository instead of the default GTNH Maven.
|
||||
@@ -123,7 +126,7 @@ includeWellKnownRepositories = true
|
||||
usesMavenPublishing = true
|
||||
|
||||
# Maven repository to publish the mod to.
|
||||
# mavenPublishUrl = https://nexus.gtnewhorizons.com/repository/releases/
|
||||
# mavenPublishUrl = https\://nexus.gtnewhorizons.com/repository/releases/
|
||||
|
||||
# Publishing to Modrinth requires you to set the MODRINTH_TOKEN environment variable to your current Modrinth API token.
|
||||
#
|
||||
@@ -187,5 +190,3 @@ curseForgeRelations =
|
||||
# This is meant to be set in $HOME/.gradle/gradle.properties.
|
||||
# ideaCheckSpotlessOnBuild = true
|
||||
|
||||
# Non-GTNH properties
|
||||
gradleTokenGroupName =
|
||||
Vendored
BIN
Binary file not shown.
+1
-1
@@ -1,6 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ pluginManagement {
|
||||
}
|
||||
|
||||
plugins {
|
||||
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.8'
|
||||
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.22'
|
||||
}
|
||||
|
||||
|
||||
@@ -41,8 +41,8 @@ import codechicken.nei.recipe.RecipeInfo;
|
||||
public abstract class AbstractTreeGUIHandler implements ICraftingHandler, IUsageHandler {
|
||||
|
||||
public int cycleticks = Math.abs((int) System.currentTimeMillis());
|
||||
public LinkedList<CachedRecipe> arecipes = new LinkedList<CachedRecipe>();
|
||||
public LinkedList<RecipeTransferRect> transferRects = new LinkedList<RecipeTransferRect>();
|
||||
public LinkedList<CachedRecipe> arecipes = new LinkedList<>();
|
||||
public LinkedList<RecipeTransferRect> transferRects = new LinkedList<>();
|
||||
|
||||
public AbstractTreeGUIHandler() {
|
||||
loadTransferRects();
|
||||
@@ -86,7 +86,7 @@ public abstract class AbstractTreeGUIHandler implements ICraftingHandler, IUsage
|
||||
public List<Class<? extends GuiContainer>> getRecipeTransferRectGuis() {
|
||||
Class<? extends GuiContainer> clazz = getGuiClass();
|
||||
if (clazz != null) {
|
||||
LinkedList<Class<? extends GuiContainer>> list = new LinkedList<Class<? extends GuiContainer>>();
|
||||
LinkedList<Class<? extends GuiContainer>> list = new LinkedList<>();
|
||||
list.add(clazz);
|
||||
return list;
|
||||
}
|
||||
@@ -192,9 +192,9 @@ public abstract class AbstractTreeGUIHandler implements ICraftingHandler, IUsage
|
||||
|
||||
@Override
|
||||
public List<String> handleTooltip(GuiRecipe<?> gui, List<String> currenttip, int recipe) {
|
||||
if ((GuiContainerManager.shouldShowTooltip(gui)) && (currenttip.size() == 0)) {
|
||||
if (GuiContainerManager.shouldShowTooltip(gui) && currenttip.isEmpty()) {
|
||||
Point offset = gui.getRecipePosition(recipe);
|
||||
currenttip = transferRectTooltip(gui, this.transferRects, offset.x, offset.y, currenttip);
|
||||
return transferRectTooltip(gui, this.transferRects, offset.x, offset.y, currenttip);
|
||||
}
|
||||
return currenttip;
|
||||
}
|
||||
@@ -265,7 +265,7 @@ public abstract class AbstractTreeGUIHandler implements ICraftingHandler, IUsage
|
||||
|
||||
public static class RecipeTransferRectHandler implements IContainerInputHandler, IContainerTooltipHandler {
|
||||
|
||||
private static HashMap<Class<? extends GuiContainer>, HashSet<RecipeTransferRect>> guiMap = new HashMap<Class<? extends GuiContainer>, HashSet<RecipeTransferRect>>();
|
||||
private static final HashMap<Class<? extends GuiContainer>, HashSet<RecipeTransferRect>> guiMap = new HashMap<>();
|
||||
|
||||
public static void registerRectsToGuis(List<Class<? extends GuiContainer>> classes,
|
||||
List<RecipeTransferRect> rects) {
|
||||
@@ -273,11 +273,7 @@ public abstract class AbstractTreeGUIHandler implements ICraftingHandler, IUsage
|
||||
return;
|
||||
}
|
||||
for (Class<? extends GuiContainer> clazz : classes) {
|
||||
HashSet<RecipeTransferRect> set = guiMap.get(clazz);
|
||||
if (set == null) {
|
||||
set = new HashSet<RecipeTransferRect>();
|
||||
guiMap.put(clazz, set);
|
||||
}
|
||||
HashSet<RecipeTransferRect> set = guiMap.computeIfAbsent(clazz, k -> new HashSet<>());
|
||||
set.addAll(rects);
|
||||
}
|
||||
}
|
||||
@@ -346,10 +342,9 @@ public abstract class AbstractTreeGUIHandler implements ICraftingHandler, IUsage
|
||||
if (!canHandle(gui)) {
|
||||
return currenttip;
|
||||
}
|
||||
if ((GuiContainerManager.shouldShowTooltip(gui)) && (currenttip.size() == 0)) {
|
||||
if (GuiContainerManager.shouldShowTooltip(gui) && currenttip.isEmpty()) {
|
||||
int[] offset = RecipeInfo.getGuiOffset(gui);
|
||||
currenttip = AbstractTreeGUIHandler
|
||||
.transferRectTooltip(gui, guiMap.get(gui.getClass()), offset[0], offset[1], currenttip);
|
||||
return transferRectTooltip(gui, guiMap.get(gui.getClass()), offset[0], offset[1], currenttip);
|
||||
}
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package hellfirepvp.beebetteratbees.client.gui;
|
||||
import java.awt.Color;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
@@ -13,7 +12,6 @@ import java.util.Map;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
@@ -24,7 +22,6 @@ import org.lwjgl.opengl.GL11;
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
import codechicken.nei.recipe.GuiRecipe;
|
||||
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
import forestry.api.apiculture.IBeeMutation;
|
||||
import forestry.api.apiculture.IBeeRoot;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
@@ -49,8 +46,8 @@ public class BBABGuiRecipeTreeHandler extends AbstractTreeGUIHandler {
|
||||
private static IBeeRoot speciesRoot;
|
||||
|
||||
public static List<IBeeMutation> getMutationsWithResult(IAllele allele) {
|
||||
if (speciesRoot == null) return new LinkedList<IBeeMutation>();
|
||||
LinkedList<IBeeMutation> out = new LinkedList<IBeeMutation>();
|
||||
if (speciesRoot == null) return new LinkedList<>();
|
||||
LinkedList<IBeeMutation> out = new LinkedList<>();
|
||||
for (IBeeMutation mutation : speciesRoot.getMutations(false)) {
|
||||
if (mutation.getTemplate()[0].equals(allele)) out.add(mutation);
|
||||
}
|
||||
@@ -114,14 +111,14 @@ public class BBABGuiRecipeTreeHandler extends AbstractTreeGUIHandler {
|
||||
cleanupDuplicateRecipes();
|
||||
}
|
||||
|
||||
private Map<Rectangle, Collection<String>> tipBoxes = new HashMap<Rectangle, Collection<String>>();
|
||||
private Map<Rectangle, Collection<String>> tipBoxes = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void drawExtras(int recipe) {
|
||||
CachedRecipe rec = this.arecipes.get(recipe);
|
||||
if (rec instanceof CachedBeeMutationTree) {
|
||||
Map<Rectangle, Collection<String>> boxes = new HashMap<Rectangle, Collection<String>>(4);
|
||||
CachedBeeMutationTree.PositionedMutationNodeStack root = ((CachedBeeMutationTree) rec).getRootStack();
|
||||
if (rec instanceof CachedBeeMutationTree cachedTree) {
|
||||
Map<Rectangle, Collection<String>> boxes = new HashMap<>(4);
|
||||
CachedBeeMutationTree.PositionedMutationNodeStack root = cachedTree.getRootStack();
|
||||
drawExtrasFrom(root, boxes);
|
||||
this.tipBoxes = boxes;
|
||||
}
|
||||
@@ -224,36 +221,22 @@ public class BBABGuiRecipeTreeHandler extends AbstractTreeGUIHandler {
|
||||
|
||||
@Override
|
||||
public List<String> handleTooltip(GuiRecipe<?> gui, List<String> currenttip, int recipe) {
|
||||
if (GuiContainerManager.shouldShowTooltip(gui) && currenttip.size() == 0) {
|
||||
if (GuiContainerManager.shouldShowTooltip(gui) && currenttip.isEmpty()) {
|
||||
Point pos = GuiDraw.getMousePosition();
|
||||
Point guiOffset = getGuiOffset(gui);
|
||||
Point guiOffset = new Point(gui.guiLeft, gui.guiTop);
|
||||
Point relMouse = new Point(pos.x - guiOffset.x - 5, pos.y - guiOffset.y - 16);
|
||||
for (Rectangle rec : tipBoxes.keySet()) {
|
||||
if (rec.contains(relMouse)) {
|
||||
return new LinkedList<String>(tipBoxes.get(rec));
|
||||
return new LinkedList<>(tipBoxes.get(rec));
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.handleTooltip(gui, currenttip, recipe);
|
||||
}
|
||||
|
||||
private Point getGuiOffset(GuiContainer ct) {
|
||||
try {
|
||||
Field fP = ReflectionHelper.findField(GuiContainer.class, "guiLeft", "field_147003_i");
|
||||
fP.setAccessible(true);
|
||||
int left = (Integer) fP.get(ct);
|
||||
fP = ReflectionHelper.findField(GuiContainer.class, "guiTop", "field_147009_r");
|
||||
fP.setAccessible(true);
|
||||
int top = (Integer) fP.get(ct);
|
||||
return new Point(left, top);
|
||||
} catch (Exception e) {}
|
||||
return new Point(0, 0);
|
||||
}
|
||||
|
||||
private static void drawLine(double lx, double ly, double hx, double hy, Color color) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
GL11.glDepthMask(true);
|
||||
GL11.glLineWidth(3.0F);
|
||||
GL11.glEnable(GL11.GL_LINE_SMOOTH);
|
||||
GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST);
|
||||
@@ -267,7 +250,6 @@ public class BBABGuiRecipeTreeHandler extends AbstractTreeGUIHandler {
|
||||
tes.draw();
|
||||
|
||||
GL11.glDisable(GL11.GL_LINE_SMOOTH);
|
||||
GL11.glDepthMask(false);
|
||||
GL11.glLineWidth(2.0F);
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
|
||||
@@ -6,6 +6,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import codechicken.nei.PositionedStack;
|
||||
import forestry.api.apiculture.IBeeMutation;
|
||||
@@ -30,8 +31,8 @@ public class CachedBeeMutationTree extends CachedRecipe {
|
||||
private static final int X_SEPERATION_THRESHOLD = 7;
|
||||
private static final int Y_OFFSET = 0;
|
||||
|
||||
private SimpleBinaryTree<IAllele> mutationTree;
|
||||
private List<PositionedMutationNodeStack> evaluatedBeePositions;
|
||||
private final SimpleBinaryTree<IAllele> mutationTree;
|
||||
private final List<PositionedMutationNodeStack> evaluatedBeePositions;
|
||||
private int evaluatedMaxX;
|
||||
public final boolean oversized;
|
||||
private PositionedMutationNodeStack rootStack;
|
||||
@@ -39,15 +40,15 @@ public class CachedBeeMutationTree extends CachedRecipe {
|
||||
public CachedBeeMutationTree(IBeeMutation parentMutation) {
|
||||
// parentMutation.getTemplate() Gets results primary at array[0], secondary at array[1]
|
||||
// parentMutation.getAllele0() or getAllele1() Gets bees needed for mutation.
|
||||
this.mutationTree = new SimpleBinaryTree<IAllele>(
|
||||
this.mutationTree = new SimpleBinaryTree<>(
|
||||
4,
|
||||
parentMutation.getTemplate()[0],
|
||||
new SimpleBinaryTree.RootProvider<IAllele>() {
|
||||
new SimpleBinaryTree.RootProvider<>() {
|
||||
|
||||
@Override
|
||||
public IAllele[] provideSubNodes(IAllele superNode) {
|
||||
List<IBeeMutation> mutations = BBABGuiRecipeTreeHandler.getMutationsWithResult(superNode);
|
||||
if (mutations.size() > 0) {
|
||||
if (!mutations.isEmpty()) {
|
||||
IBeeMutation mutation = mutations.get(0);
|
||||
|
||||
return new IAllele[] { mutation.getAllele0(), mutation.getAllele1() };
|
||||
@@ -58,12 +59,12 @@ public class CachedBeeMutationTree extends CachedRecipe {
|
||||
});
|
||||
|
||||
if (!ModConfig.showDuplicateTrees) {
|
||||
List<IAllele> foundMutationTrees = new ArrayList<IAllele>();
|
||||
List<IAllele> foundMutationTrees = new ArrayList<>();
|
||||
removeAndReplaceDuplicates(this.mutationTree.getRoot(), foundMutationTrees);
|
||||
}
|
||||
|
||||
// Important: We don't need to buffer root, because that's the "result"
|
||||
this.evaluatedBeePositions = new LinkedList<PositionedMutationNodeStack>();
|
||||
this.evaluatedBeePositions = new LinkedList<>();
|
||||
int iterationDepth = 3;
|
||||
int maxTotalDepth = Math.min(
|
||||
iterationDepth,
|
||||
@@ -76,7 +77,7 @@ public class CachedBeeMutationTree extends CachedRecipe {
|
||||
int yStep = 110 / maxTotalDepth;
|
||||
|
||||
this.oversized = checkSeparationWidth(maxTotalDepth, X_SEPERATION_THRESHOLD);
|
||||
this.evaluatedMaxX = /* this.oversized ? buildNewMaxX(maxTotalDepth, X_SEPERATION_THRESHOLD) : */ MAX_X;
|
||||
this.evaluatedMaxX = MAX_X;
|
||||
|
||||
int center = (MIN_X + this.evaluatedMaxX) / 2;
|
||||
PositionedMutationNodeStack leftChild = placeInRenderBuffer(
|
||||
@@ -100,13 +101,13 @@ public class CachedBeeMutationTree extends CachedRecipe {
|
||||
mutationTree.getRoot()
|
||||
.getValue());
|
||||
float ch = -1;
|
||||
Collection<String> requirements = new LinkedList<String>();
|
||||
if (mutationsToRoot.size() > 0) {
|
||||
Collection<String> requirements = new LinkedList<>();
|
||||
if (!mutationsToRoot.isEmpty()) {
|
||||
IBeeMutation mut = mutationsToRoot.get(0);
|
||||
ch = mut.getBaseChance();
|
||||
try {
|
||||
requirements = mut.getSpecialConditions();
|
||||
} catch (Throwable tr) {}
|
||||
} catch (Throwable ignored) {}
|
||||
}
|
||||
|
||||
this.rootStack = new PositionedMutationNodeStack(
|
||||
@@ -129,7 +130,7 @@ public class CachedBeeMutationTree extends CachedRecipe {
|
||||
// lines.
|
||||
if (discoveredMutations.contains(node.getValue())) {
|
||||
List<IBeeMutation> mutations = getMutationsWithResult(node.getValue());
|
||||
if (mutations.size() > 0) node.removeDuplicate(); // Only if it actually has mutations that has this node as
|
||||
if (!mutations.isEmpty()) node.removeDuplicate(); // Only if it actually has mutations that has this node as
|
||||
// result.
|
||||
} else {
|
||||
discoveredMutations.add(node.getValue());
|
||||
@@ -140,13 +141,6 @@ public class CachedBeeMutationTree extends CachedRecipe {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* private int buildNewMaxX(int maxTotalDepth, int xSeparationThreshold) {
|
||||
* int maxDivision = (int) Math.pow(2, maxTotalDepth + 1);
|
||||
* return MIN_X + (maxDivision * xSeparationThreshold);
|
||||
* }
|
||||
*/
|
||||
|
||||
private boolean checkSeparationWidth(int maxTotalDepth, int xSeparationThreshold) {
|
||||
double maxDivision = Math.pow(2, maxTotalDepth + 1);
|
||||
int resultingLLWidth = (int) (120 / maxDivision); // LowestLevelWidth
|
||||
@@ -160,14 +154,14 @@ public class CachedBeeMutationTree extends CachedRecipe {
|
||||
if (iterationMaxCount < 0 || node.getMaxFollowingDepth() <= 0) {
|
||||
List<IBeeMutation> mutationsToRoot = getMutationsWithResult(node.getValue());
|
||||
float ch = -1;
|
||||
Collection<String> requirements = new LinkedList<String>();
|
||||
if (mutationsToRoot.size() > 0) {
|
||||
Collection<String> requirements = new LinkedList<>();
|
||||
if (!mutationsToRoot.isEmpty()) {
|
||||
IBeeMutation mut = mutationsToRoot.get(0);
|
||||
ch = mut.getBaseChance();
|
||||
try {
|
||||
requirements = mut.getSpecialConditions();
|
||||
} catch (Throwable tr) {
|
||||
requirements = new LinkedList<String>();
|
||||
requirements = new LinkedList<>();
|
||||
}
|
||||
}
|
||||
PositionedMutationNodeStack leaf = new PositionedMutationNodeStack( // Leaf
|
||||
@@ -185,14 +179,14 @@ public class CachedBeeMutationTree extends CachedRecipe {
|
||||
|
||||
List<IBeeMutation> mutations = getMutationsWithResult(node.getValue());
|
||||
float ch = -1;
|
||||
Collection<String> requirements = new LinkedList<String>();
|
||||
if (mutations.size() > 0) {
|
||||
Collection<String> requirements = new LinkedList<>();
|
||||
if (!mutations.isEmpty()) {
|
||||
IBeeMutation mut = mutations.get(0);
|
||||
ch = mut.getBaseChance();
|
||||
try {
|
||||
requirements = mut.getSpecialConditions();
|
||||
} catch (Throwable tr) {
|
||||
requirements = new LinkedList<String>();
|
||||
requirements = new LinkedList<>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -218,7 +212,7 @@ public class CachedBeeMutationTree extends CachedRecipe {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
CachedBeeMutationTree that = (CachedBeeMutationTree) o;
|
||||
return !(mutationTree != null ? !mutationTree.equals(that.mutationTree) : that.mutationTree != null);
|
||||
return Objects.equals(mutationTree, that.mutationTree);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -237,7 +231,7 @@ public class CachedBeeMutationTree extends CachedRecipe {
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getIngredients() {
|
||||
return new ArrayList<PositionedStack>(evaluatedBeePositions);
|
||||
return new ArrayList<>(evaluatedBeePositions);
|
||||
}
|
||||
|
||||
public static class PositionedMutationNodeStack extends PositionedStack {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package hellfirepvp.beebetteratbees.client.util;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* HellFirePvP@Admin
|
||||
* Date: 29.04.2016 / 00:23
|
||||
@@ -8,8 +10,8 @@ package hellfirepvp.beebetteratbees.client.util;
|
||||
*/
|
||||
public class SimpleBinaryTree<E> {
|
||||
|
||||
private Node<E> root;
|
||||
private RootProvider<E> rootProvider;
|
||||
private final Node<E> root;
|
||||
private final RootProvider<E> rootProvider;
|
||||
|
||||
public SimpleBinaryTree(int maxDepth, E rootValue, RootProvider<E> provider) {
|
||||
this.rootProvider = provider;
|
||||
@@ -27,12 +29,12 @@ public class SimpleBinaryTree<E> {
|
||||
private Node<E> buildSubTree(E superNodeValue, int maxFollowingDepth) {
|
||||
E[] subNodes = rootProvider.provideSubNodes(superNodeValue);
|
||||
if (subNodes == null || subNodes.length == 0 || maxFollowingDepth <= 0) {
|
||||
return new Leaf<E>(superNodeValue);
|
||||
return new Leaf<>(superNodeValue);
|
||||
} else {
|
||||
Node<E> left = buildSubTree(subNodes[0], maxFollowingDepth - 1);
|
||||
Node<E> right = buildSubTree(subNodes[1], maxFollowingDepth - 1);
|
||||
int depth = Math.max(left.getMaxFollowingDepth(), right.getMaxFollowingDepth());
|
||||
return new Node<E>(superNodeValue, left, right, depth + 1);
|
||||
return new Node<>(superNodeValue, left, right, depth + 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +43,7 @@ public class SimpleBinaryTree<E> {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
SimpleBinaryTree<?> that = (SimpleBinaryTree<?>) o;
|
||||
return !(root != null ? !root.equals(that.root) : that.root != null);
|
||||
return Objects.equals(root, that.root);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -89,7 +91,7 @@ public class SimpleBinaryTree<E> {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
Node<?> node = (Node<?>) o;
|
||||
return !(value != null ? !value.equals(node.value) : node.value != null);
|
||||
return Objects.equals(value, node.value);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user