Skip to content

Commit

Permalink
add it to go to structure also
Browse files Browse the repository at this point in the history
  • Loading branch information
hube12 committed Jun 7, 2021
1 parent dd94366 commit 2165be4
Showing 1 changed file with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,33 @@

import kaptainwutax.biomeutils.source.BiomeSource;
import kaptainwutax.featureutils.Feature;
import kaptainwutax.featureutils.structure.EndCity;
import kaptainwutax.featureutils.structure.RegionStructure;
import kaptainwutax.featureutils.structure.Stronghold;
import kaptainwutax.featureutils.structure.Structure;
import kaptainwutax.featureutils.structure.generator.structure.EndCityGenerator;
import kaptainwutax.mcutils.rand.ChunkRand;
import kaptainwutax.mcutils.state.Dimension;
import kaptainwutax.mcutils.util.pos.BPos;
import kaptainwutax.minemap.MineMap;
import kaptainwutax.minemap.feature.OWBastionRemnant;
import kaptainwutax.minemap.feature.OWFortress;
import kaptainwutax.minemap.feature.StructureHelper;
import kaptainwutax.minemap.init.Features;
import kaptainwutax.minemap.listener.Events;
import kaptainwutax.minemap.ui.map.MapContext;
import kaptainwutax.minemap.ui.map.MapManager;
import kaptainwutax.minemap.ui.map.MapPanel;
import kaptainwutax.minemap.ui.map.MapSettings;
import kaptainwutax.minemap.util.data.Str;
import kaptainwutax.minemap.util.ui.interactive.Dropdown;
import kaptainwutax.terrainutils.TerrainGenerator;
import one.util.streamex.StreamEx;

import javax.swing.*;
import java.awt.*;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;

Expand Down Expand Up @@ -55,6 +60,18 @@ public void initComponents() {
.filter(e -> e instanceof RegionStructure || e instanceof Stronghold/**/)
.map(e -> new StructureItem((Structure<?, ?>) e))
.collect(Collectors.toList());
if (map.getContext().getDimension()==Dimension.END){
structureItems.add(new StructureItem((Structure<?, ?>) Features.getForVersion(map.getContext().getVersion()).get(EndCity.class), bPos -> {
EndCityGenerator endCityGenerator = new EndCityGenerator(map.getContext().getVersion());
if (!endCityGenerator.generate(map.getContext().getTerrainGenerator(), bPos.toChunkPos())) return false;
return endCityGenerator.hasShip();
}) {
@Override
public String toString() {
return "End city with Elytra";
}
});
}

this.structureItemDropdown = new Dropdown<>(structureItems);
this.continueButton = new JButton();
Expand All @@ -69,6 +86,7 @@ public void initComponents() {
protected void create() {
if (!this.continueButton.isEnabled()) return;
Structure<?, ?> feature = this.structureItemDropdown.getSelected().getFeature();
Function<BPos, Boolean> filter = this.structureItemDropdown.getSelected().getFilter();
if (!(feature instanceof RegionStructure || feature instanceof Stronghold)) return;
BPos centerPos = manager.getCenterPos();
BiomeSource biomeSource = context.getBiomeSource();
Expand All @@ -84,6 +102,7 @@ protected void create() {
assert stream != null;
List<BPos> bPosList = StreamEx.of(stream)
.sequential()
.filter(e -> filter != null ? filter.apply(e) : true)
.limit(1)
.collect(Collectors.toList());
if (!bPosList.isEmpty()) {
Expand All @@ -103,9 +122,19 @@ protected void cancel() {
static class StructureItem {

private final Structure<?, ?> feature;
private final Function<BPos, Boolean> filter;

StructureItem(Structure<?, ?> feature) {
this(feature, null);
}

StructureItem(Structure<?, ?> feature, Function<BPos, Boolean> filter) {
this.feature = feature;
this.filter = filter;
}

public Function<BPos, Boolean> getFilter() {
return filter;
}

public Structure<?, ?> getFeature() {
Expand All @@ -114,7 +143,7 @@ static class StructureItem {

@Override
public String toString() {
return feature.getName();
return Str.prettifyDashed(feature.getName());
}
}

Expand Down

0 comments on commit 2165be4

Please sign in to comment.