reorganized finder types and profiles
This commit is contained in:
@@ -15,8 +15,8 @@ public abstract class ClientCommand {
|
|||||||
|
|
||||||
public abstract void build(LiteralArgumentBuilder<ServerCommandSource> builder);
|
public abstract void build(LiteralArgumentBuilder<ServerCommandSource> builder);
|
||||||
|
|
||||||
protected final void sendFeedback(String message, boolean overlay) {
|
protected final void sendFeedback(String message, Formatting color, boolean overlay) {
|
||||||
MinecraftClient.getInstance().player.addChatMessage(new LiteralText(message).formatted(Formatting.AQUA), overlay);
|
MinecraftClient.getInstance().player.addChatMessage(new LiteralText(message).formatted(color), overlay);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void register(CommandDispatcher<ServerCommandSource> dispatcher) {
|
public final void register(CommandDispatcher<ServerCommandSource> dispatcher) {
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
package kaptainwutax.seedcracker.command;
|
package kaptainwutax.seedcracker.command;
|
||||||
|
|
||||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||||
import kaptainwutax.seedcracker.finder.FinderConfig;
|
import kaptainwutax.seedcracker.finder.Finder;
|
||||||
import kaptainwutax.seedcracker.finder.FinderQueue;
|
import kaptainwutax.seedcracker.finder.FinderQueue;
|
||||||
import net.minecraft.server.command.ServerCommandSource;
|
import net.minecraft.server.command.ServerCommandSource;
|
||||||
|
import net.minecraft.util.Formatting;
|
||||||
|
|
||||||
import static net.minecraft.server.command.CommandManager.literal;
|
import static net.minecraft.server.command.CommandManager.literal;
|
||||||
|
|
||||||
@@ -16,7 +17,7 @@ public class FinderCommand extends ClientCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void build(LiteralArgumentBuilder<ServerCommandSource> builder) {
|
public void build(LiteralArgumentBuilder<ServerCommandSource> builder) {
|
||||||
for(FinderConfig.Type finderType: FinderConfig.Type.values()) {
|
for(Finder.Type finderType: Finder.Type.values()) {
|
||||||
builder.then(literal("type")
|
builder.then(literal("type")
|
||||||
.executes(context -> this.printFinderType(finderType))
|
.executes(context -> this.printFinderType(finderType))
|
||||||
.then(literal(finderType.toString())
|
.then(literal(finderType.toString())
|
||||||
@@ -25,7 +26,7 @@ public class FinderCommand extends ClientCommand {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(FinderConfig.Category finderCategory: FinderConfig.Category.values()) {
|
for(Finder.Category finderCategory: Finder.Category.values()) {
|
||||||
builder.then(literal("category")
|
builder.then(literal("category")
|
||||||
.executes(context -> this.printFinderCategory(finderCategory))
|
.executes(context -> this.printFinderCategory(finderCategory))
|
||||||
.then(literal(finderCategory.toString())
|
.then(literal(finderCategory.toString())
|
||||||
@@ -35,24 +36,28 @@ public class FinderCommand extends ClientCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int printFinderCategory(FinderConfig.Category finderCategory) {
|
private int printFinderCategory(Finder.Category finderCategory) {
|
||||||
FinderConfig.Type.getForCategory(finderCategory).forEach(this::printFinderType);
|
Finder.Type.getForCategory(finderCategory).forEach(this::printFinderType);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int printFinderType(FinderConfig.Type finderType) {
|
private int printFinderType(Finder.Type finderType) {
|
||||||
this.sendFeedback("Finder " + finderType + " is set to [" + String.valueOf(FinderQueue.get().finderProfile.getTypeState(finderType)).toUpperCase() + "].", false);
|
this.sendFeedback("Finder " + finderType + " is set to [" + String.valueOf(FinderQueue.get().finderProfile.getTypeState(finderType)).toUpperCase() + "].", Formatting.AQUA,false);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int setFinderCategory(FinderConfig.Category finderCategory, boolean flag) {
|
private int setFinderCategory(Finder.Category finderCategory, boolean flag) {
|
||||||
FinderConfig.Type.getForCategory(finderCategory).forEach(finderType -> this.setFinderType(finderType, flag));
|
Finder.Type.getForCategory(finderCategory).forEach(finderType -> this.setFinderType(finderType, flag));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int setFinderType(FinderConfig.Type finderType, boolean flag) {
|
private int setFinderType(Finder.Type finderType, boolean flag) {
|
||||||
FinderQueue.get().finderProfile.setTypeState(finderType, flag);
|
if(FinderQueue.get().finderProfile.setTypeState(finderType, flag)) {
|
||||||
this.sendFeedback("Finder " + finderType + " has been set to [" + String.valueOf(flag).toUpperCase() + "].", false);
|
this.sendFeedback("Finder " + finderType + " has been set to [" + String.valueOf(flag).toUpperCase() + "].", Formatting.AQUA, false);
|
||||||
|
} else {
|
||||||
|
this.sendFeedback("Your current finder profile is locked and cannot be modified. Please make a copy first.", Formatting.RED, false);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package kaptainwutax.seedcracker.command;
|
|||||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||||
import kaptainwutax.seedcracker.finder.FinderQueue;
|
import kaptainwutax.seedcracker.finder.FinderQueue;
|
||||||
import net.minecraft.server.command.ServerCommandSource;
|
import net.minecraft.server.command.ServerCommandSource;
|
||||||
|
import net.minecraft.util.Formatting;
|
||||||
|
|
||||||
import static net.minecraft.server.command.CommandManager.literal;
|
import static net.minecraft.server.command.CommandManager.literal;
|
||||||
|
|
||||||
@@ -27,13 +28,13 @@ public class RenderCommand extends ClientCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private int printRenderMode() {
|
private int printRenderMode() {
|
||||||
this.sendFeedback("Current render mode is set to [" + FinderQueue.get().renderType + "].", false);
|
this.sendFeedback("Current render mode is set to [" + FinderQueue.get().renderType + "].", Formatting.AQUA, false);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int setRenderMode(FinderQueue.RenderType renderType) {
|
private int setRenderMode(FinderQueue.RenderType renderType) {
|
||||||
FinderQueue.get().renderType = renderType;
|
FinderQueue.get().renderType = renderType;
|
||||||
this.sendFeedback("Set render mode to [" + FinderQueue.get().renderType + "].", false);
|
this.sendFeedback("Set render mode to [" + FinderQueue.get().renderType + "].", Formatting.AQUA, false);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,13 @@
|
|||||||
package kaptainwutax.seedcracker.finder;
|
package kaptainwutax.seedcracker.finder;
|
||||||
|
|
||||||
|
import kaptainwutax.seedcracker.finder.population.DesertWellFinder;
|
||||||
|
import kaptainwutax.seedcracker.finder.population.DungeonFinder;
|
||||||
|
import kaptainwutax.seedcracker.finder.population.EndGatewayFinder;
|
||||||
|
import kaptainwutax.seedcracker.finder.population.EndPillarsFinder;
|
||||||
|
import kaptainwutax.seedcracker.finder.population.ore.EmeraldOreFinder;
|
||||||
|
import kaptainwutax.seedcracker.finder.structure.*;
|
||||||
import kaptainwutax.seedcracker.render.Renderer;
|
import kaptainwutax.seedcracker.render.Renderer;
|
||||||
|
import kaptainwutax.seedcracker.util.FinderBuilder;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.ChunkPos;
|
import net.minecraft.util.math.ChunkPos;
|
||||||
@@ -9,8 +16,10 @@ import net.minecraft.world.World;
|
|||||||
import net.minecraft.world.dimension.DimensionType;
|
import net.minecraft.world.dimension.DimensionType;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public abstract class Finder {
|
public abstract class Finder {
|
||||||
|
|
||||||
@@ -89,4 +98,42 @@ public abstract class Finder {
|
|||||||
return newList;
|
return newList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum Category {
|
||||||
|
STRUCTURES,
|
||||||
|
BIOMES,
|
||||||
|
ORES,
|
||||||
|
OTHERS
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum Type {
|
||||||
|
BURIED_TREASURE(BuriedTreasureFinder::create, Category.STRUCTURES),
|
||||||
|
DESERT_TEMPLE(DesertTempleFinder::create, Category.STRUCTURES),
|
||||||
|
END_CITY(EndCityFinder::create, Category.STRUCTURES),
|
||||||
|
//IGLOO(IglooFinder::create, Category.STRUCTURES),
|
||||||
|
JUNGLE_TEMPLE(JungleTempleFinder::create, Category.STRUCTURES),
|
||||||
|
MONUMENT(OceanMonumentFinder::create, Category.STRUCTURES),
|
||||||
|
SWAMP_HUT(SwampHutFinder::create, Category.STRUCTURES),
|
||||||
|
//MANSION(MansionFinder::create, Category.STRUCTURES),
|
||||||
|
SHIPWRECK(ShipwreckFinder::create, Category.STRUCTURES),
|
||||||
|
|
||||||
|
END_PILLARS(EndPillarsFinder::create, Category.OTHERS),
|
||||||
|
END_GATEWAY(EndGatewayFinder::create, Category.OTHERS),
|
||||||
|
DUNGEON(DungeonFinder::create, Category.OTHERS),
|
||||||
|
EMERALD_ORE(EmeraldOreFinder::create, Category.ORES),
|
||||||
|
DESERT_WELL(DesertWellFinder::create, Category.OTHERS),
|
||||||
|
BIOME(BiomeFinder::create, Category.BIOMES);
|
||||||
|
|
||||||
|
public final FinderBuilder finderBuilder;
|
||||||
|
private final Category category;
|
||||||
|
|
||||||
|
Type(FinderBuilder finderBuilder, Category category) {
|
||||||
|
this.finderBuilder = finderBuilder;
|
||||||
|
this.category = category;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<Type> getForCategory(Category category) {
|
||||||
|
return Arrays.stream(values()).filter(type -> type.category == category).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,31 +1,26 @@
|
|||||||
package kaptainwutax.seedcracker.finder;
|
package kaptainwutax.seedcracker.finder;
|
||||||
|
|
||||||
import kaptainwutax.seedcracker.finder.population.DesertWellFinder;
|
import kaptainwutax.seedcracker.finder.profile.FinderProfile;
|
||||||
import kaptainwutax.seedcracker.finder.population.DungeonFinder;
|
import kaptainwutax.seedcracker.finder.profile.NopeProfile;
|
||||||
import kaptainwutax.seedcracker.finder.population.EndGatewayFinder;
|
|
||||||
import kaptainwutax.seedcracker.finder.population.EndPillarsFinder;
|
|
||||||
import kaptainwutax.seedcracker.finder.population.ore.EmeraldOreFinder;
|
|
||||||
import kaptainwutax.seedcracker.finder.structure.*;
|
|
||||||
import kaptainwutax.seedcracker.util.FinderBuilder;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Queue;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class FinderConfig {
|
public class FinderConfig {
|
||||||
|
|
||||||
protected Map<Type, Boolean> typeStates = new HashMap<>();
|
protected FinderProfile finderProfile = new NopeProfile();
|
||||||
protected Map<Type, ConcurrentLinkedQueue<Finder>> activeFinders = new ConcurrentHashMap<>();
|
protected Map<Finder.Type, ConcurrentLinkedQueue<Finder>> activeFinders = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
public FinderConfig() {
|
||||||
|
|
||||||
public FinderConfig(boolean defaultState) {
|
|
||||||
for(Type type: Type.values()) {
|
|
||||||
this.typeStates.put(type, defaultState);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Type> getActiveFinderTypes() {
|
public List<Finder.Type> getActiveFinderTypes() {
|
||||||
return this.typeStates.entrySet().stream()
|
return this.finderProfile.typeStates.entrySet().stream()
|
||||||
.filter(Map.Entry::getValue)
|
.filter(Map.Entry::getValue)
|
||||||
.map(Map.Entry::getKey)
|
.map(Map.Entry::getKey)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
@@ -40,7 +35,7 @@ public class FinderConfig {
|
|||||||
.flatMap(Queue::stream).collect(Collectors.toList());
|
.flatMap(Queue::stream).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addFinder(Type type, Finder finder) {
|
public void addFinder(Finder.Type type, Finder finder) {
|
||||||
if(finder.isUseless())return;
|
if(finder.isUseless())return;
|
||||||
|
|
||||||
if(!this.activeFinders.containsKey(type)) {
|
if(!this.activeFinders.containsKey(type)) {
|
||||||
@@ -50,50 +45,17 @@ public class FinderConfig {
|
|||||||
this.activeFinders.get(type).add(finder);
|
this.activeFinders.get(type).add(finder);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getTypeState(Type type) {
|
public boolean getTypeState(Finder.Type type) {
|
||||||
return this.typeStates.get(type);
|
return this.finderProfile.typeStates.get(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTypeState(Type type, boolean flag) {
|
public boolean setTypeState(Finder.Type type, boolean flag) {
|
||||||
this.typeStates.put(type, flag);
|
if(!this.finderProfile.getLocked()) {
|
||||||
}
|
this.finderProfile.typeStates.put(type, flag);
|
||||||
|
return true;
|
||||||
public enum Category {
|
|
||||||
STRUCTURES,
|
|
||||||
BIOMES,
|
|
||||||
ORES,
|
|
||||||
OTHERS
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum Type {
|
|
||||||
BURIED_TREASURE(BuriedTreasureFinder::create, Category.STRUCTURES),
|
|
||||||
DESERT_TEMPLE(DesertTempleFinder::create, Category.STRUCTURES),
|
|
||||||
END_CITY(EndCityFinder::create, Category.STRUCTURES),
|
|
||||||
//IGLOO(IglooFinder::create, Category.STRUCTURES),
|
|
||||||
JUNGLE_TEMPLE(JungleTempleFinder::create, Category.STRUCTURES),
|
|
||||||
MONUMENT(OceanMonumentFinder::create, Category.STRUCTURES),
|
|
||||||
SWAMP_HUT(SwampHutFinder::create, Category.STRUCTURES),
|
|
||||||
//MANSION(MansionFinder::create, Category.STRUCTURES),
|
|
||||||
SHIPWRECK(ShipwreckFinder::create, Category.STRUCTURES),
|
|
||||||
|
|
||||||
END_PILLARS(EndPillarsFinder::create, Category.OTHERS),
|
|
||||||
END_GATEWAY(EndGatewayFinder::create, Category.OTHERS),
|
|
||||||
DUNGEON(DungeonFinder::create, Category.OTHERS),
|
|
||||||
EMERALD_ORE(EmeraldOreFinder::create, Category.ORES),
|
|
||||||
DESERT_WELL(DesertWellFinder::create, Category.OTHERS),
|
|
||||||
BIOME(BiomeFinder::create, Category.BIOMES);
|
|
||||||
|
|
||||||
public final FinderBuilder finderBuilder;
|
|
||||||
private final Category category;
|
|
||||||
|
|
||||||
Type(FinderBuilder finderBuilder, Category category) {
|
|
||||||
this.finderBuilder = finderBuilder;
|
|
||||||
this.category = category;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<Type> getForCategory(Category category) {
|
return false;
|
||||||
return Arrays.stream(values()).filter(type -> type.category == category).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ public class FinderQueue {
|
|||||||
public static ExecutorService SERVICE = Executors.newFixedThreadPool(5);
|
public static ExecutorService SERVICE = Executors.newFixedThreadPool(5);
|
||||||
|
|
||||||
public RenderType renderType = RenderType.XRAY;
|
public RenderType renderType = RenderType.XRAY;
|
||||||
public FinderConfig finderProfile = new VanillaProfile();
|
public FinderConfig finderProfile = new FinderConfig();
|
||||||
|
|
||||||
private FinderQueue() {
|
private FinderQueue() {
|
||||||
this.clear();
|
this.clear();
|
||||||
@@ -70,7 +70,7 @@ public class FinderQueue {
|
|||||||
|
|
||||||
public void clear() {
|
public void clear() {
|
||||||
this.renderType = RenderType.XRAY;
|
this.renderType = RenderType.XRAY;
|
||||||
this.finderProfile = new VanillaProfile();
|
this.finderProfile = new FinderConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum RenderType {
|
public enum RenderType {
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package kaptainwutax.seedcracker.finder.profile;
|
||||||
|
|
||||||
|
public class CustomProfile extends FinderProfile {
|
||||||
|
|
||||||
|
public CustomProfile() {
|
||||||
|
super(false);
|
||||||
|
this.author = "";
|
||||||
|
this.locked = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAuthor(String author) {
|
||||||
|
this.author = author;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLocked(boolean locked) {
|
||||||
|
this.locked = locked;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,17 +1,28 @@
|
|||||||
package kaptainwutax.seedcracker.finder.profile;
|
package kaptainwutax.seedcracker.finder.profile;
|
||||||
|
|
||||||
import kaptainwutax.seedcracker.finder.FinderConfig;
|
import kaptainwutax.seedcracker.finder.Finder;
|
||||||
|
|
||||||
public abstract class FinderProfile extends FinderConfig {
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
public abstract class FinderProfile {
|
||||||
|
|
||||||
|
public final HashMap<Finder.Type, Boolean> typeStates = new HashMap<>();
|
||||||
|
|
||||||
|
protected String author;
|
||||||
|
protected boolean locked;
|
||||||
|
|
||||||
public FinderProfile(boolean defaultState) {
|
public FinderProfile(boolean defaultState) {
|
||||||
super(defaultState);
|
for(Finder.Type type: Finder.Type.values()) {
|
||||||
|
this.typeStates.put(type, defaultState);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract String getAuthor();
|
public String getAuthor() {
|
||||||
public abstract boolean getLocked();
|
return this.author;
|
||||||
|
}
|
||||||
|
|
||||||
public abstract void setAuthor(String author);
|
public boolean getLocked() {
|
||||||
public abstract void setLocked(boolean locked);
|
return this.locked;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package kaptainwutax.seedcracker.finder.profile;
|
||||||
|
|
||||||
|
public class NopeProfile extends FinderProfile {
|
||||||
|
|
||||||
|
public NopeProfile() {
|
||||||
|
super(false);
|
||||||
|
this.author = "KaptainWutax";
|
||||||
|
this.locked = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -4,24 +4,8 @@ public class VanillaProfile extends FinderProfile {
|
|||||||
|
|
||||||
public VanillaProfile() {
|
public VanillaProfile() {
|
||||||
super(true);
|
super(true);
|
||||||
}
|
this.author = "KaptainWutax";
|
||||||
|
this.locked = true;
|
||||||
@Override
|
|
||||||
public String getAuthor() {
|
|
||||||
return "KaptainWutax";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean getLocked() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setAuthor(String author) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setLocked(boolean locked) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user