mirror of https://github.com/cabaletta/baritone
use mutatingattachment
This commit is contained in:
parent
da1a5c121f
commit
54e7473a6e
|
@ -18,29 +18,36 @@
|
|||
package baritone.builder;
|
||||
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.builder.utils.com.github.btrekkie.connectivity.MutatingAugmentation;
|
||||
|
||||
import java.util.OptionalInt;
|
||||
|
||||
public class CountingSurface extends NavigableSurface {
|
||||
public CountingSurface(int x, int y, int z) {
|
||||
super(x, y, z, Attachment::new, $ -> new Attachment());
|
||||
super(x, y, z, new MutatingAugmentation() {
|
||||
@Override
|
||||
public void combine(Object value1, Object value2, Object result) {
|
||||
((Attachment) result).combine((Attachment) value1, (Attachment) value2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object newAugmentation() {
|
||||
return new Attachment();
|
||||
}
|
||||
}, $ -> new Attachment());
|
||||
}
|
||||
|
||||
private static class Attachment {
|
||||
public final int surfaceSize;
|
||||
|
||||
public Attachment(Object a, Object b) {
|
||||
this((Attachment) a, (Attachment) b);
|
||||
}
|
||||
|
||||
public Attachment(Attachment a, Attachment b) {
|
||||
this.surfaceSize = a.surfaceSize + b.surfaceSize;
|
||||
}
|
||||
public int surfaceSize;
|
||||
|
||||
public Attachment() {
|
||||
this.surfaceSize = 1;
|
||||
}
|
||||
|
||||
public void combine(Attachment child1, Attachment child2) {
|
||||
surfaceSize = child1.surfaceSize + child2.surfaceSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) { // used as performance optimization in RedBlackNode to avoid augmenting unchanged attachments
|
||||
if (this == o) {
|
||||
|
|
|
@ -18,8 +18,8 @@
|
|||
package baritone.builder;
|
||||
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.builder.utils.com.github.btrekkie.connectivity.Augmentation;
|
||||
import baritone.builder.utils.com.github.btrekkie.connectivity.ConnGraph;
|
||||
import baritone.builder.utils.com.github.btrekkie.connectivity.MutatingAugmentation;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.function.Function;
|
||||
|
@ -37,7 +37,7 @@ public class NavigableSurface {
|
|||
private final Column col1 = new Column();
|
||||
private final Column col2 = new Column();
|
||||
|
||||
public NavigableSurface(int x, int y, int z, Augmentation augmentation, Function<BetterBlockPos, Object> genVertexAugmentation) {
|
||||
public NavigableSurface(int x, int y, int z, MutatingAugmentation augmentation, Function<BetterBlockPos, Object> genVertexAugmentation) {
|
||||
this.bounds = new CuboidBounds(x, y, z);
|
||||
this.blocks = new BlockStateCachedData[bounds.volume()];
|
||||
Arrays.fill(blocks, FakeStates.AIR);
|
||||
|
|
Loading…
Reference in New Issue