/*
* Copyright (C) 2022 NotEnoughUpdates contributors
*
* This file is part of NotEnoughUpdates.
*
* NotEnoughUpdates is free software: you can redistribute it
* and/or modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* NotEnoughUpdates is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>.
*/
package io.github.moulberry.notenoughupdates.miscfeatures;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.autosubscribe.NEUAutoSubscribe;
import io.github.moulberry.notenoughupdates.core.util.Line;
import io.github.moulberry.notenoughupdates.core.util.StringUtils;
import io.github.moulberry.notenoughupdates.core.util.Vec3Comparable;
import io.github.moulberry.notenoughupdates.events.SpawnParticleEvent;
import io.github.moulberry.notenoughupdates.options.NEUConfig;
import io.github.moulberry.notenoughupdates.options.customtypes.NEUDebugFlag;
import io.github.moulberry.notenoughupdates.util.NEUDebugLogger;
import io.github.moulberry.notenoughupdates.util.SBInfo;
import io.github.moulberry.notenoughupdates.util.TabListUtils;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
import net.minecraft.event.ClickEvent;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.Vec3i;
import net.minecraftforge.client.ClientCommandHandler;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.event.world.WorldEvent;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Locale;
import java.util.function.BooleanSupplier;
import java.util.function.LongSupplier;
@NEUAutoSubscribe
public class CrystalWishingCompassSolver {
enum SolverState {
NOT_STARTED,
PROCESSING_FIRST_USE,
NEED_SECOND_COMPASS,
PROCESSING_SECOND_USE,
SOLVED,
FAILED_EXCEPTION,
FAILED_TIMEOUT_NO_REPEATING,
FAILED_TIMEOUT_NO_PARTICLES,
FAILED_INTERSECTION_CALCULATION,
FAILED_INVALID_SOLUTION,
}
enum CompassTarget {
GOBLIN_QUEEN,
GOBLIN_KING,
BAL,
JUNGLE_TEMPLE,
ODAWA,
PRECURSOR_CITY,
MINES_OF_DIVAN,
CRYSTAL_NUCLEUS,
}
enum Crystal {
AMBER,
AMETHYST,
JADE,
SAPPHIRE,
TOPAZ,
}
enum HollowsZone {
CRYSTAL_NUCLEUS,
JUNGLE,
MITHRIL_DEPOSITS,
GOBLIN_HOLDOUT,
PRECURSOR_REMNANTS,
MAGMA_FIELDS,
}
private static final CrystalWishingCompassSolver INSTANCE = new CrystalWishingCompassSolver();
public static CrystalWishingCompassSolver getInstance() {
return INSTANCE;
}
private static final Minecraft mc = Minecraft.getMinecraft();
private static boolean isSkytilsPresent = false;
private static final ArrayDeque<ParticleData> seenParticles = new ArrayDeque<>();
// There is a small set of breakable blocks above the nucleus at Y > 181. While this zone is reported
// as the Crystal Nucleus by Hypixel, for wishing compass purposes it is in the appropriate quadrant.
private static final AxisAlignedBB NUCLEUS_BB = new AxisAlignedBB(462, 63, 461, 564, 181, 565);
// Bounding box around all breakable blocks in the crystal hollows, appears as bedrock in-game
private static final AxisAlignedBB HOLLOWS_BB = new AxisAlignedBB(201, 30, 201, 824, 189, 824);
// Zone bounding boxes
private static final AxisAlignedBB PRECURSOR_REMNANTS_BB = new AxisAlignedBB(512, 63, 512, 824, 189, 824);
private static final AxisAlignedBB MITHRIL_DEPOSITS_BB = new AxisAlignedBB(512, 63, 201, 824, 189, 513);
private static final AxisAlignedBB GOBLIN_HOLDOUT_BB = new AxisAlignedBB(201, 63, 512, 513, 189, 824);
private static final AxisAlignedBB JUNGLE_BB = new AxisAlignedBB(201, 63, 201, 513, 189, 513);
private static final AxisAlignedBB