com.yungnickyoung.minecraft.yungsapi.world.structure.jigsaw.PieceEntry Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of YungsApi-1.21-Fabric Show documentation
Show all versions of YungsApi-1.21-Fabric Show documentation
A common API for YUNG's Minecraft mods
The newest version!
package com.yungnickyoung.minecraft.yungsapi.world.structure.jigsaw;
import com.yungnickyoung.minecraft.yungsapi.util.BoxOctree;
import com.yungnickyoung.minecraft.yungsapi.world.structure.jigsaw.assembler.PieceContext;
import com.yungnickyoung.minecraft.yungsapi.world.structure.jigsaw.element.YungJigsawSinglePoolElement;
import org.apache.commons.lang3.mutable.MutableObject;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import net.minecraft.class_238;
import net.minecraft.class_2960;
import net.minecraft.class_3780;
import net.minecraft.class_3790;
public class PieceEntry {
private class_3790 piece;
private final MutableObject boxOctree;
private final class_238 pieceAabb;
private final int depth;
private final List childEntries = new ArrayList<>();
private final PieceEntry parentEntry;
private final PieceContext sourcePieceContext;
private final class_3780 parentJunction;
private boolean delayGeneration = false;
public PieceEntry(class_3790 piece, MutableObject boxOctree, class_238 pieceAabb, int depth,
PieceEntry parentEntry, PieceContext sourcePieceContext, class_3780 parentJunction) {
this.piece = piece;
this.boxOctree = boxOctree;
this.pieceAabb = pieceAabb;
this.depth = depth;
this.parentEntry = parentEntry;
this.sourcePieceContext = sourcePieceContext;
this.parentJunction = parentJunction;
}
public void addChildEntry(PieceEntry childEntry) {
this.childEntries.add(childEntry);
}
public boolean hasChildren() {
return this.childEntries.size() > 0;
}
public class_3790 getPiece() {
return piece;
}
public void setPiece(class_3790 newPiece) {
this.piece = newPiece;
}
public MutableObject getBoxOctree() {
return boxOctree;
}
public int getDepth() {
return depth;
}
public PieceEntry getParentEntry() {
return parentEntry;
}
public PieceContext getSourcePieceContext() {
return sourcePieceContext;
}
public class_238 getPieceAabb() {
return pieceAabb;
}
public class_3780 getParentJunction() {
return parentJunction;
}
public Optional getDeadendPool() {
if (this.piece.method_16644() instanceof YungJigsawSinglePoolElement yungSingleElement) {
return yungSingleElement.getDeadendPool();
}
return Optional.empty();
}
public void setDelayGeneration(boolean delayGeneration) {
this.delayGeneration = delayGeneration;
}
public boolean isDelayGeneration() {
return this.delayGeneration;
}
@Override
public boolean equals(Object obj) {
if (obj == this) return true;
if (obj == null || obj.getClass() != this.getClass()) return false;
var that = (PieceEntry) obj;
return Objects.equals(this.piece, that.piece) &&
Objects.equals(this.boxOctree, that.boxOctree) &&
this.depth == that.depth;
}
@Override
public int hashCode() {
return Objects.hash(piece, boxOctree, depth);
}
@Override
public String toString() {
return "PieceEntry[" +
"piece=" + piece + ", " +
"boxOctree=" + boxOctree + ", " +
"depth=" + depth + ']';
}
}