diff options
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions')
16 files changed, 0 insertions, 1286 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/AbstractAction.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/AbstractAction.java deleted file mode 100644 index 4fd4056d..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/AbstractAction.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <https://www.gnu.org/licenses/>. - */ - -package kr.syeyoung.dungeonsguide.dungeon.actions; - -import kr.syeyoung.dungeonsguide.dungeon.actions.tree.ActionRoute; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.events.PlayerInteractEntityEvent; -import net.minecraftforge.event.entity.living.LivingDeathEvent; -import net.minecraftforge.event.entity.player.PlayerInteractEvent; - -public abstract class AbstractAction implements Action { - @Override - public void onPlayerInteract(DungeonRoom dungeonRoom, PlayerInteractEvent event, ActionRoute.ActionRouteProperties actionRouteProperties) { - - } - - @Override - public void onRenderWorld(DungeonRoom dungeonRoom, float partialTicks, ActionRoute.ActionRouteProperties actionRouteProperties, boolean flag) { - - } - - @Override - public void onLivingDeath(DungeonRoom dungeonRoom, LivingDeathEvent event, ActionRoute.ActionRouteProperties actionRouteProperties) { - - } - - @Override - public void onRenderScreen(DungeonRoom dungeonRoom, float partialTicks, ActionRoute.ActionRouteProperties actionRouteProperties) { - - } - - @Override - public void onLivingInteract(DungeonRoom dungeonRoom, PlayerInteractEntityEvent event, ActionRoute.ActionRouteProperties actionRouteProperties) { - - } - - @Override - public void onTick(DungeonRoom dungeonRoom, ActionRoute.ActionRouteProperties actionRouteProperties) { - - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/Action.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/Action.java deleted file mode 100755 index 1a4ad682..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/Action.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <https://www.gnu.org/licenses/>. - */ - -package kr.syeyoung.dungeonsguide.dungeon.actions; - -import kr.syeyoung.dungeonsguide.dungeon.actions.tree.ActionRoute; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.events.PlayerInteractEntityEvent; -import net.minecraftforge.event.entity.living.LivingDeathEvent; -import net.minecraftforge.event.entity.player.PlayerInteractEvent; - -import java.util.Set; - -public interface Action { - Set<Action> getPreRequisites(DungeonRoom dungeonRoom); - - void onPlayerInteract(DungeonRoom dungeonRoom, PlayerInteractEvent event, ActionRoute.ActionRouteProperties actionRouteProperties); - void onLivingInteract(DungeonRoom dungeonRoom, PlayerInteractEntityEvent event, ActionRoute.ActionRouteProperties actionRouteProperties); - void onLivingDeath(DungeonRoom dungeonRoom, LivingDeathEvent event, ActionRoute.ActionRouteProperties actionRouteProperties); - void onRenderWorld(DungeonRoom dungeonRoom, float partialTicks, ActionRoute.ActionRouteProperties actionRouteProperties, boolean flag); - void onRenderScreen(DungeonRoom dungeonRoom, float partialTicks, ActionRoute.ActionRouteProperties actionRouteProperties); - void onTick(DungeonRoom dungeonRoom, ActionRoute.ActionRouteProperties actionRouteProperties); - - boolean isComplete(DungeonRoom dungeonRoom); -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionBreakWithSuperBoom.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionBreakWithSuperBoom.java deleted file mode 100755 index 39d3e7ef..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionBreakWithSuperBoom.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <https://www.gnu.org/licenses/>. - */ - -package kr.syeyoung.dungeonsguide.dungeon.actions; - -import kr.syeyoung.dungeonsguide.dungeon.actions.tree.ActionRoute; -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import lombok.Data; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.BlockRendererDispatcher; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.WorldRenderer; -import net.minecraft.client.renderer.texture.TextureMap; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.entity.Entity; -import net.minecraft.init.Blocks; -import net.minecraft.util.BlockPos; - -import java.awt.*; -import java.util.HashSet; -import java.util.Set; - -@Data -public class ActionBreakWithSuperBoom extends AbstractAction { - private Set<Action> preRequisite = new HashSet<Action>(); - private OffsetPoint target; - - public ActionBreakWithSuperBoom(OffsetPoint target) { - this.target = target; - } - - @Override - public Set<Action> getPreRequisites(DungeonRoom dungeonRoom) { - return preRequisite; - } - - @Override - public boolean isComplete(DungeonRoom dungeonRoom) { - return target.getBlock(dungeonRoom) == Blocks.air; - } - - @Override - public void onRenderWorld(DungeonRoom dungeonRoom, float partialTicks, ActionRoute.ActionRouteProperties actionRouteProperties, boolean flag) { - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); - - BlockPos blockpos = target.getBlockPos(dungeonRoom); - - Entity viewing_from = Minecraft.getMinecraft().getRenderViewEntity(); - - double x_fix = viewing_from.lastTickPosX + ((viewing_from.posX - viewing_from.lastTickPosX) * partialTicks); - double y_fix = viewing_from.lastTickPosY + ((viewing_from.posY - viewing_from.lastTickPosY) * partialTicks); - double z_fix = viewing_from.lastTickPosZ + ((viewing_from.posZ - viewing_from.lastTickPosZ) * partialTicks); - - GlStateManager.pushMatrix(); - GlStateManager.translate(-x_fix, -y_fix, -z_fix); - GlStateManager.disableLighting(); - GlStateManager.enableAlpha(); - GlStateManager.disableDepth(); - GlStateManager.depthMask(false); - GlStateManager.enableBlend(); - - Tessellator tessellator = Tessellator.getInstance(); - WorldRenderer vertexbuffer = tessellator.getWorldRenderer(); - vertexbuffer.begin(7, DefaultVertexFormats.BLOCK); - - BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher(); - blockrendererdispatcher.getBlockModelRenderer().renderModel(Minecraft.getMinecraft().theWorld, - blockrendererdispatcher.getBlockModelShapes().getModelForState(Blocks.tnt.getDefaultState()), - Blocks.tnt.getDefaultState(), blockpos, vertexbuffer, false); - tessellator.draw(); - - GlStateManager.enableLighting(); - GlStateManager.popMatrix(); - - RenderUtils.highlightBlock(blockpos, new Color(0, 255,255,50), partialTicks, true); - RenderUtils.drawTextAtWorld("Superboom", blockpos.getX() + 0.5f, blockpos.getY() + 0.5f, blockpos.getZ() + 0.5f, 0xFFFFFF00, 0.03f, false, false, partialTicks); - } - - @Override - public String toString() { - return "BreakWithSuperboom\n- target: "+target.toString(); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionChangeState.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionChangeState.java deleted file mode 100755 index 56b27528..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionChangeState.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <https://www.gnu.org/licenses/>. - */ - -package kr.syeyoung.dungeonsguide.dungeon.actions; - -import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonDummy; -import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonFairySoul; -import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonMechanic; -import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonSecret; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.util.HashSet; -import java.util.Set; - -@Data -public class ActionChangeState extends AbstractAction{ - @EqualsAndHashCode.Exclude - private Set<Action> preRequisite2 = new HashSet<Action>(); - - private String mechanicName; - private String state; - - public ActionChangeState(String mechanicName, String state) { - this.mechanicName = mechanicName; - this.state = state; - } - - @Override - public Set<Action> getPreRequisites(DungeonRoom dungeonRoom) { - Set<Action> set = new HashSet<Action>(); - set.addAll(preRequisite2); - DungeonMechanic mechanic = dungeonRoom.getMechanics().get(mechanicName); - if (mechanic!= null) - set.addAll(mechanic.getAction(state, dungeonRoom)); - return set; - } - @Override - public String toString() { - return "ChangeState\n- target: "+mechanicName+"\n- state: "+state; - } - - @Override - public boolean isComplete(DungeonRoom dungeonRoom) { - DungeonMechanic mechanic = dungeonRoom.getMechanics().get(mechanicName); - if (state.equalsIgnoreCase("navigate")) - return true; - if (mechanic== null) - return false; - if (mechanic instanceof DungeonSecret && ((DungeonSecret) mechanic).getSecretType() != DungeonSecret.SecretType.CHEST) - return true; - if (mechanic instanceof DungeonDummy) - return true; - return mechanic.getCurrentState(dungeonRoom).equalsIgnoreCase(state); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClick.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClick.java deleted file mode 100755 index 1b463f2e..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClick.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <https://www.gnu.org/licenses/>. - */ - -package kr.syeyoung.dungeonsguide.dungeon.actions; - -import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import kr.syeyoung.dungeonsguide.dungeon.actions.tree.ActionRoute; -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import lombok.Data; -import net.minecraft.item.ItemStack; -import net.minecraft.util.BlockPos; -import net.minecraftforge.event.entity.player.PlayerInteractEvent; - -import java.awt.*; -import java.util.HashSet; -import java.util.Set; - -@Data -public class ActionClick extends AbstractAction { - private Set<Action> preRequisite = new HashSet<Action>(); - private OffsetPoint target; - private Predicate<ItemStack> predicate = Predicates.alwaysTrue(); - - private boolean clicked = false; - - public ActionClick(OffsetPoint target) { - this.target = target; - } - - @Override - public Set<Action> getPreRequisites(DungeonRoom dungeonRoom) { - return preRequisite; - } - - @Override - public boolean isComplete(DungeonRoom dungeonRoom) { - return clicked; - } - - @Override - public void onPlayerInteract(DungeonRoom dungeonRoom, PlayerInteractEvent event, ActionRoute.ActionRouteProperties actionRouteProperties) { - if (clicked) return; - if (target.getBlockPos(dungeonRoom).equals(event.pos) && - (predicate == null || predicate.apply(event.entityLiving.getHeldItem()))) { - clicked = true; - } - } - @Override - public void onRenderWorld(DungeonRoom dungeonRoom, float partialTicks, ActionRoute.ActionRouteProperties actionRouteProperties, boolean flag) { - BlockPos pos = target.getBlockPos(dungeonRoom); - RenderUtils.highlightBlock(pos, new Color(0, 255,255,50),partialTicks, true); - RenderUtils.drawTextAtWorld("Click", pos.getX() + 0.5f, pos.getY() + 0.3f, pos.getZ() + 0.5f, 0xFFFFFF00, 0.02f, false, false, partialTicks); - } - - - @Override - public String toString() { - return "Click\n- target: "+target.toString()+"\n- predicate: "+predicate.getClass().getSimpleName(); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClickSet.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClickSet.java deleted file mode 100755 index 975c19e9..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClickSet.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <https://www.gnu.org/licenses/>. - */ - -package kr.syeyoung.dungeonsguide.dungeon.actions; - -import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import kr.syeyoung.dungeonsguide.dungeon.actions.tree.ActionRoute; -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import lombok.Data; -import net.minecraft.item.ItemStack; -import net.minecraft.util.BlockPos; -import net.minecraftforge.event.entity.player.PlayerInteractEvent; - -import java.awt.*; -import java.util.HashSet; -import java.util.Set; - -@Data -public class ActionClickSet extends AbstractAction { - private Set<Action> preRequisite = new HashSet<Action>(); - private OffsetPointSet target; - private Predicate<ItemStack> predicate = Predicates.alwaysTrue(); - - public ActionClickSet(OffsetPointSet target) { - this.target = target; - } - - @Override - public Set<Action> getPreRequisites(DungeonRoom dungeonRoom) { - return preRequisite; - } - - @Override - public String toString() { - return "ClickSet\n- targets size: "+target.getOffsetPointList().size()+"\n- predicate: "+predicate.getClass().getSimpleName(); - } - - private boolean clicked = false; - @Override - public void onPlayerInteract(DungeonRoom dungeonRoom, PlayerInteractEvent event, ActionRoute.ActionRouteProperties actionRouteProperties) { - if (clicked) return; - for (OffsetPoint pt2: target.getOffsetPointList()) { - if (pt2.getBlockPos(dungeonRoom).equals(event.pos) && - (predicate == null || predicate.apply(event.entityLiving.getHeldItem()))) { - clicked = true; - } - } - - } - - @Override - public void onRenderWorld(DungeonRoom dungeonRoom, float partialTicks, ActionRoute.ActionRouteProperties actionRouteProperties, boolean flag) { - float xAcc = 0; - float yAcc = 0; - float zAcc = 0; - int size = target.getOffsetPointList().size(); - for (OffsetPoint offsetPoint : target.getOffsetPointList()) { - BlockPos pos = offsetPoint.getBlockPos(dungeonRoom); - xAcc += pos.getX() + 0.5f; - yAcc += pos.getY()+ 0.5f; - zAcc += pos.getZ()+ 0.5f; - RenderUtils.highlightBlock(offsetPoint.getBlockPos(dungeonRoom), new Color(0, 255,255,50),partialTicks, true); - } - - RenderUtils.drawTextAtWorld("Click", xAcc / size, yAcc / size, zAcc / size, 0xFFFFFF00, 0.02f, false, false, partialTicks); - } - - @Override - public boolean isComplete(DungeonRoom dungeonRoom) { - return clicked; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionComplete.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionComplete.java deleted file mode 100644 index 3389ed62..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionComplete.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <https://www.gnu.org/licenses/>. - */ - -package kr.syeyoung.dungeonsguide.dungeon.actions; - -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; - -import java.util.Collections; -import java.util.Set; - -public class ActionComplete extends AbstractAction { - @Override - public Set<Action> getPreRequisites(DungeonRoom dungeonRoom) { - return Collections.emptySet(); - } - - @Override - public boolean isComplete(DungeonRoom dungeonRoom) { - return false; - } - - @Override - public String toString() { - return "Completed"; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionDropItem.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionDropItem.java deleted file mode 100755 index 2e90d3a3..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionDropItem.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <https://www.gnu.org/licenses/>. - */ - -package kr.syeyoung.dungeonsguide.dungeon.actions; - -import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import kr.syeyoung.dungeonsguide.dungeon.actions.tree.ActionRoute; -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import lombok.Data; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.BlockPos; - -import java.awt.*; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -@Data -public class ActionDropItem extends AbstractAction { - private Set<Action> preRequisite = new HashSet<Action>(); - private OffsetPoint target; - private Predicate<EntityItem> predicate = Predicates.alwaysTrue(); - - public ActionDropItem(OffsetPoint target) { - this.target = target; - } - - @Override - public Set<Action> getPreRequisites(DungeonRoom dungeonRoom) { - return preRequisite; - } - - @Override - public boolean isComplete(DungeonRoom dungeonRoom) { - BlockPos pos = target.getBlockPos(dungeonRoom); - List<EntityItem> item = dungeonRoom.getContext().getWorld().getEntitiesWithinAABB(EntityItem.class, - AxisAlignedBB.fromBounds(pos.getX(), pos.getY(), pos.getZ(), pos.getX()+1, pos.getY() + 1, pos.getZ() + 1)); - if (item.size() == 0) return false; - return (predicate == null || predicate.apply(item.get(0))); - } - @Override - public void onRenderWorld(DungeonRoom dungeonRoom, float partialTicks, ActionRoute.ActionRouteProperties actionRouteProperties, boolean flag) { - BlockPos pos = target.getBlockPos(dungeonRoom); - RenderUtils.highlightBlock(pos, new Color(0, 255,255,50),partialTicks, true); - RenderUtils.drawTextAtWorld("Drop Item", pos.getX() + 0.5f, pos.getY() + 0.3f, pos.getZ() + 0.5f, 0xFFFFFF00, 0.02f, false, false, partialTicks); - } - - @Override - public String toString() { - return "DropItem\n- target: "+target.toString()+"\n- predicate: "+predicate.getClass().getSimpleName(); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionInteract.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionInteract.java deleted file mode 100755 index 3033754c..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionInteract.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <https://www.gnu.org/licenses/>. - */ - -package kr.syeyoung.dungeonsguide.dungeon.actions; - -import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import kr.syeyoung.dungeonsguide.dungeon.DungeonActionManager; -import kr.syeyoung.dungeonsguide.dungeon.actions.tree.ActionRoute; -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.events.PlayerInteractEntityEvent; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import lombok.Data; -import net.minecraft.entity.Entity; -import net.minecraft.util.BlockPos; -import net.minecraft.util.Vec3; - -import java.awt.*; -import java.util.HashSet; -import java.util.Set; - -@Data -public class ActionInteract extends AbstractAction { - private Set<Action> preRequisite = new HashSet<Action>(); - private OffsetPoint target; - private Predicate<Entity> predicate = Predicates.alwaysFalse(); - private int radius; - - public ActionInteract(OffsetPoint target) { - this.target = target; - } - - @Override - public Set<Action> getPreRequisites(DungeonRoom dungeonRoom) { - return preRequisite; - } - - @Override - public boolean isComplete(DungeonRoom dungeonRoom) { - return interacted; - } - - private boolean interacted = false; - @Override - public void onLivingInteract(DungeonRoom dungeonRoom, PlayerInteractEntityEvent event, ActionRoute.ActionRouteProperties actionRouteProperties) { - if (interacted) return; - - Vec3 spawnLoc = DungeonActionManager.getSpawnLocation().get(event.getEntity().getEntityId()); - if (spawnLoc == null) return; - if (target.getBlockPos(dungeonRoom).distanceSq(spawnLoc.xCoord, spawnLoc.yCoord, spawnLoc.zCoord) > radius * radius) return; - if (!predicate.apply(event.getEntity())) return; - interacted = true; - } - @Override - public void onRenderWorld(DungeonRoom dungeonRoom, float partialTicks, ActionRoute.ActionRouteProperties actionRouteProperties, boolean flag) { - BlockPos pos = target.getBlockPos(dungeonRoom); - RenderUtils.highlightBlock(pos, new Color(0, 255,255,50),partialTicks, true); - RenderUtils.drawTextAtWorld("Interact", pos.getX() + 0.5f, pos.getY() + 0.3f, pos.getZ() + 0.5f, 0xFFFFFF00, 0.02f, false, false, partialTicks); - } - - @Override - public String toString() { - return "InteractEntity\n- target: "+target.toString()+"\n- radius: "+radius+"\n- predicate: "+(predicate == null ? "null" : predicate.getClass().getSimpleName()); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionKill.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionKill.java deleted file mode 100755 index a08b81f0..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionKill.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <https://www.gnu.org/licenses/>. - */ - -package kr.syeyoung.dungeonsguide.dungeon.actions; - -import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import kr.syeyoung.dungeonsguide.dungeon.DungeonActionManager; -import kr.syeyoung.dungeonsguide.dungeon.actions.tree.ActionRoute; -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import lombok.Data; -import net.minecraft.entity.Entity; -import net.minecraft.util.BlockPos; -import net.minecraft.util.Vec3; -import net.minecraftforge.event.entity.living.LivingDeathEvent; - -import java.awt.*; -import java.util.HashSet; -import java.util.Set; - -@Data -public class ActionKill extends AbstractAction { - private Set<Action> preRequisite = new HashSet<Action>(); - private OffsetPoint target; - private Predicate<Entity> predicate = Predicates.alwaysFalse(); - private int radius; - - public ActionKill(OffsetPoint target) { - this.target = target; - } - - @Override - public Set<Action> getPreRequisites(DungeonRoom dungeonRoom) { - return preRequisite; - } - - @Override - public boolean isComplete(DungeonRoom dungeonRoom) { - Vec3 spawn = new Vec3(target.getBlockPos(dungeonRoom)); - for (Integer killed : DungeonActionManager.getKilleds()) { - if (DungeonActionManager.getSpawnLocation().get(killed) == null) continue; - if (DungeonActionManager.getSpawnLocation().get(killed).squareDistanceTo(spawn) < 100) { - return true; - } - } - - return killed; - } - - private boolean killed = false; - @Override - public void onLivingDeath(DungeonRoom dungeonRoom, LivingDeathEvent event, ActionRoute.ActionRouteProperties actionRouteProperties) { - if (killed) return; - - Vec3 spawnLoc = DungeonActionManager.getSpawnLocation().get(event.entity.getEntityId()); - if (spawnLoc == null) return; - if (target.getBlockPos(dungeonRoom).distanceSq(spawnLoc.xCoord, spawnLoc.yCoord, spawnLoc.zCoord) > radius * radius) return; - if (!predicate.apply(event.entity)) return; - killed = true; - } - @Override - public void onRenderWorld(DungeonRoom dungeonRoom, float partialTicks, ActionRoute.ActionRouteProperties actionRouteProperties, boolean flag) { - BlockPos pos = target.getBlockPos(dungeonRoom); - RenderUtils.highlightBlock(pos, new Color(0, 255,255,50),partialTicks, true); - RenderUtils.drawTextAtWorld("Spawn", pos.getX() + 0.5f, pos.getY() + 0.3f, pos.getZ() + 0.5f, 0xFFFFFF00, 0.02f, false, false, partialTicks); - } - - @Override - public String toString() { - return "KillEntity\n- target: "+target.toString()+"\n- radius: "+radius+"\n- predicate: "+(predicate == null ? "null" : predicate.getClass().getSimpleName()); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMove.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMove.java deleted file mode 100755 index ec790489..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMove.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <https://www.gnu.org/licenses/>. - */ - -package kr.syeyoung.dungeonsguide.dungeon.actions; - -import kr.syeyoung.dungeonsguide.Keybinds; -import kr.syeyoung.dungeonsguide.dungeon.actions.tree.ActionRoute; -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.features.impl.secret.FeatureTogglePathfind; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import lombok.Data; -import net.minecraft.client.Minecraft; -import net.minecraft.util.BlockPos; -import net.minecraft.util.MathHelper; -import net.minecraft.util.Vec3; - -import java.util.HashSet; -import java.util.Set; -import java.util.List; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.Future; - -@Data -public class ActionMove extends AbstractAction { - private Set<Action> preRequisite = new HashSet<Action>(); - private OffsetPoint target; - - public ActionMove(OffsetPoint target) { - this.target = target; - } - - @Override - public Set<Action> getPreRequisites(DungeonRoom dungeonRoom) { - return preRequisite; - } - - @Override - public boolean isComplete(DungeonRoom dungeonRoom) { - return target.getBlockPos(dungeonRoom).distanceSq(Minecraft.getMinecraft().thePlayer.getPosition()) < 25; - } - - @Override - public void onRenderWorld(DungeonRoom dungeonRoom, float partialTicks, ActionRoute.ActionRouteProperties actionRouteProperties, boolean flag) { - BlockPos pos = target.getBlockPos(dungeonRoom); - - float distance = MathHelper.sqrt_double(pos.distanceSq(Minecraft.getMinecraft().thePlayer.getPosition())); - float multiplier = distance / 120f; //mobs only render ~120 blocks away - if (flag) multiplier *= 2.0f; - float scale = 0.45f * multiplier; - scale *= 25.0 / 6.0; - if (actionRouteProperties.isBeacon()) { - RenderUtils.renderBeaconBeam(pos.getX(), pos.getY(), pos.getZ(), actionRouteProperties.getBeaconBeamColor(), partialTicks); - RenderUtils.highlightBlock(pos, actionRouteProperties.getBeaconColor(), partialTicks); - } - RenderUtils.drawTextAtWorld("Destination", pos.getX() + 0.5f, pos.getY() + 0.5f + scale, pos.getZ() + 0.5f, 0xFF00FF00, flag ? 2f : 1f, true, false, partialTicks); - RenderUtils.drawTextAtWorld(String.format("%.2f",MathHelper.sqrt_double(pos.distanceSq(Minecraft.getMinecraft().thePlayer.getPosition())))+"m", pos.getX() + 0.5f, pos.getY() + 0.5f - scale, pos.getZ() + 0.5f, 0xFFFFFF00, flag ? 2f : 1f, true, false, partialTicks); - - if (!FeatureRegistry.SECRET_TOGGLE_KEY.isEnabled() || !FeatureRegistry.SECRET_TOGGLE_KEY.togglePathfindStatus) { - if (poses != null){ - RenderUtils.drawLinesVec3(poses, actionRouteProperties.getLineColor(), actionRouteProperties.getLineWidth(), partialTicks, true); - } - } - } - - private int tick = -1; - private List<Vec3> poses; - private Future<List<Vec3>> latestFuture; - - @Override - public void onTick(DungeonRoom dungeonRoom, ActionRoute.ActionRouteProperties actionRouteProperties) { - tick = (tick+1) % Math.max(1, actionRouteProperties.getLineRefreshRate()); - if (latestFuture != null && latestFuture.isDone()) { - try { - poses = latestFuture.get(); - latestFuture = null; - } catch (InterruptedException | ExecutionException e) { - e.printStackTrace(); - } - } - - if (tick == 0 && actionRouteProperties.isPathfind() && latestFuture == null) { - if (!FeatureRegistry.SECRET_FREEZE_LINES.isEnabled() || poses == null) - latestFuture = dungeonRoom.createEntityPathTo(dungeonRoom.getContext().getWorld(), Minecraft.getMinecraft().thePlayer, target.getBlockPos(dungeonRoom), Integer.MAX_VALUE, 10000); - } - } - - public void forceRefresh(DungeonRoom dungeonRoom) { - try { - if (latestFuture != null) return; - } catch (Exception ignored) {} - latestFuture = dungeonRoom.createEntityPathTo(dungeonRoom.getContext().getWorld(), Minecraft.getMinecraft().thePlayer, target.getBlockPos(dungeonRoom), Integer.MAX_VALUE, 10000); - } - @Override - public String toString() { - return "Move\n- target: "+target.toString(); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMoveNearestAir.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMoveNearestAir.java deleted file mode 100755 index 14897147..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMoveNearestAir.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <https://www.gnu.org/licenses/>. - */ - -package kr.syeyoung.dungeonsguide.dungeon.actions; - -import kr.syeyoung.dungeonsguide.Keybinds; -import kr.syeyoung.dungeonsguide.dungeon.actions.tree.ActionRoute; -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import lombok.Data; -import net.minecraft.client.Minecraft; -import net.minecraft.util.BlockPos; -import net.minecraft.util.MathHelper; -import net.minecraft.util.Vec3; - -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.Future; - -@Data -public class ActionMoveNearestAir extends AbstractAction { - private Set<Action> preRequisite = new HashSet<Action>(); - private OffsetPoint target; - - public ActionMoveNearestAir(OffsetPoint target) { - this.target = target; - } - - @Override - public Set<Action> getPreRequisites(DungeonRoom dungeonRoom) { - return preRequisite; - } - - @Override - public boolean isComplete(DungeonRoom dungeonRoom) { - return target.getBlockPos(dungeonRoom).distanceSq(Minecraft.getMinecraft().thePlayer.getPosition()) < 25; - } - - @Override - public void onRenderWorld(DungeonRoom dungeonRoom, float partialTicks, ActionRoute.ActionRouteProperties actionRouteProperties, boolean flag) { - BlockPos pos = target.getBlockPos(dungeonRoom); - - float distance = MathHelper.sqrt_double(pos.distanceSq(Minecraft.getMinecraft().thePlayer.getPosition())); - float multiplier = distance / 120f; //mobs only render ~120 blocks away - if (flag) multiplier *= 2.0f; - float scale = 0.45f * multiplier; - scale *= 25.0 / 6.0; - if (actionRouteProperties.isBeacon()) { - RenderUtils.renderBeaconBeam(pos.getX(), pos.getY(), pos.getZ(), actionRouteProperties.getBeaconBeamColor(), partialTicks); - RenderUtils.highlightBlock(pos, actionRouteProperties.getBeaconColor(), partialTicks); - } - RenderUtils.drawTextAtWorld("Destination", pos.getX() + 0.5f, pos.getY() + 0.5f + scale, pos.getZ() + 0.5f, 0xFF00FF00, flag ? 2f : 1f, true, false, partialTicks); - RenderUtils.drawTextAtWorld(String.format("%.2f",MathHelper.sqrt_double(pos.distanceSq(Minecraft.getMinecraft().thePlayer.getPosition())))+"m", pos.getX() + 0.5f, pos.getY() + 0.5f - scale, pos.getZ() + 0.5f, 0xFFFFFF00, flag ? 2f : 1f, true, false, partialTicks); - - if (!FeatureRegistry.SECRET_TOGGLE_KEY.isEnabled() || !FeatureRegistry.SECRET_TOGGLE_KEY.togglePathfindStatus) { - if (poses != null){ - RenderUtils.drawLinesVec3(poses, actionRouteProperties.getLineColor(), actionRouteProperties.getLineWidth(), partialTicks, true); - } - } - } - - private int tick = -1; - private List<Vec3> poses; - private Future<List<Vec3>> latestFuture; - @Override - public void onTick(DungeonRoom dungeonRoom, ActionRoute.ActionRouteProperties actionRouteProperties) { - tick = (tick+1) % Math.max(1, actionRouteProperties.getLineRefreshRate()); - if (latestFuture != null && latestFuture.isDone()) { - try { - poses = latestFuture.get(); - latestFuture = null; - } catch (InterruptedException | ExecutionException e) { - e.printStackTrace(); - } - } - - if (tick == 0 && actionRouteProperties.isPathfind() && latestFuture == null) { - if (!FeatureRegistry.SECRET_FREEZE_LINES.isEnabled() || poses == null) - latestFuture = dungeonRoom.createEntityPathTo(dungeonRoom.getContext().getWorld(), Minecraft.getMinecraft().thePlayer, target.getBlockPos(dungeonRoom), Integer.MAX_VALUE, 10000); - } - } - - - public void forceRefresh(DungeonRoom dungeonRoom) { - try { - if (latestFuture != null) return; - } catch (Exception ignored) {} - latestFuture = dungeonRoom.createEntityPathTo(dungeonRoom.getContext().getWorld(), Minecraft.getMinecraft().thePlayer, target.getBlockPos(dungeonRoom), Integer.MAX_VALUE, 10000); - } - @Override - public String toString() { - return "MoveNearestAir\n- target: "+target.toString(); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionRoot.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionRoot.java deleted file mode 100755 index 39c7fa6c..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionRoot.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <https://www.gnu.org/licenses/>. - */ - -package kr.syeyoung.dungeonsguide.dungeon.actions; - -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import lombok.Data; - -import java.util.HashSet; -import java.util.Set; - -@Data -public class ActionRoot extends AbstractAction { - private Set<Action> preRequisite = new HashSet<Action>(); - - public ActionRoot() { - } - - @Override - public Set<Action> getPreRequisites(DungeonRoom dungeonRoom) { - return preRequisite; - } - - @Override - public boolean isComplete(DungeonRoom dungeonRoom) { - return true; - } - - @Override - public String toString() { - return "Action Root"; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/tree/ActionRoute.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/tree/ActionRoute.java deleted file mode 100644 index 3580dd03..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/tree/ActionRoute.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <https://www.gnu.org/licenses/>. - */ - -package kr.syeyoung.dungeonsguide.dungeon.actions.tree; - -import kr.syeyoung.dungeonsguide.config.types.AColor; -import kr.syeyoung.dungeonsguide.dungeon.actions.*; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.events.PlayerInteractEntityEvent; -import lombok.Data; -import lombok.Getter; -import net.minecraft.client.Minecraft; -import net.minecraftforge.event.entity.living.LivingDeathEvent; -import net.minecraftforge.event.entity.player.PlayerInteractEvent; - -import java.util.List; - -public class ActionRoute { - @Getter - private final String mechanic; - @Getter - private final String state; - - @Getter - private int current; - @Getter - private final List<Action> actions; - - private final DungeonRoom dungeonRoom; - - @Getter - private final ActionRouteProperties actionRouteProperties; - - public ActionRoute(DungeonRoom dungeonRoom, String mechanic, String state, ActionRouteProperties actionRouteProperties) { - this.mechanic = mechanic; - this.state = state; - this.actionRouteProperties = actionRouteProperties; - - ActionChangeState actionChangeState = new ActionChangeState(mechanic, state); - ActionTree tree= ActionTree.buildActionTree(actionChangeState, dungeonRoom); - actions = ActionTreeUtil.linearifyActionTree(tree); - actions.add(new ActionComplete()); - current = 0; - this.dungeonRoom = dungeonRoom; - } - - public Action next() { - current ++; - if (current >= actions.size()) current = actions.size() - 1; - return actions.get(current); - } - - public Action prev() { - current --; - if (current < 0) current = 0; - return actions.get(current); - } - - public Action getCurrentAction() { - return actions.get(current); - } - - - - public void onPlayerInteract(PlayerInteractEvent event) { - getCurrentAction().onPlayerInteract(dungeonRoom, event, actionRouteProperties ); - } - public void onLivingDeath(LivingDeathEvent event) { - getCurrentAction().onLivingDeath(dungeonRoom, event, actionRouteProperties ); - } - public void onRenderWorld(float partialTicks, boolean flag) { - if (current -1 >= 0 && ( - (actions.get(current-1) instanceof ActionMove && ((ActionMove) actions.get(current-1)).getTarget().getBlockPos(dungeonRoom).distanceSq(Minecraft.getMinecraft().thePlayer.getPosition()) >= 25) - || (actions.get(current-1) instanceof ActionMoveNearestAir && ((ActionMoveNearestAir) actions.get(current-1)).getTarget().getBlockPos(dungeonRoom).distanceSq(Minecraft.getMinecraft().thePlayer.getPosition()) >= 25))) actions.get(current-1).onRenderWorld(dungeonRoom, partialTicks, actionRouteProperties, flag ); - getCurrentAction().onRenderWorld(dungeonRoom, partialTicks, actionRouteProperties, flag); - } - - public void onRenderScreen(float partialTicks) { - getCurrentAction().onRenderScreen(dungeonRoom, partialTicks, actionRouteProperties); - } - - public void onTick() { - Action current = getCurrentAction(); - - current.onTick(dungeonRoom, actionRouteProperties); - if (this.current -1 >= 0 && (actions.get(this.current-1) instanceof ActionMove || actions.get(this.current-1) instanceof ActionMoveNearestAir)) actions.get(this.current-1).onTick(dungeonRoom, actionRouteProperties ); - - if (dungeonRoom.getMechanics().get(mechanic).getCurrentState(dungeonRoom).equals(state)) { - this.current = actions.size() - 1; - } - - if (current.isComplete(dungeonRoom)) - next(); - } - - public void onLivingInteract(PlayerInteractEntityEvent event) { getCurrentAction().onLivingInteract(dungeonRoom, event, actionRouteProperties ); } - - @Data - public static class ActionRouteProperties { - private boolean pathfind; - private int lineRefreshRate; - private AColor lineColor; - private float lineWidth; - - private boolean beacon; - private AColor beaconColor; - private AColor beaconBeamColor; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/tree/ActionTree.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/tree/ActionTree.java deleted file mode 100755 index 3139ce73..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/tree/ActionTree.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <https://www.gnu.org/licenses/>. - */ - -package kr.syeyoung.dungeonsguide.dungeon.actions.tree; - -import kr.syeyoung.dungeonsguide.dungeon.actions.Action; -import kr.syeyoung.dungeonsguide.dungeon.actions.ActionRoot; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -@Data -public class ActionTree implements Cloneable { - @EqualsAndHashCode.Exclude - private Set<ActionTree> parent; - private Action current; - private Set<ActionTree> children; - - @Override - public int hashCode() { return current == null ? 0 : current.hashCode(); } - - - public static ActionTree buildActionTree(Set<Action> actions, DungeonRoom dungeonRoom) { - ActionRoot root = new ActionRoot(); - root.setPreRequisite(actions); - ActionTree tree = new ActionTree(); - tree.setParent(new HashSet<ActionTree>()); - tree.setCurrent(root); - HashSet<ActionTree> set = new HashSet(); - for (Action action : actions) { - set.add(buildActionTree(tree, action, dungeonRoom, new HashMap<Action, ActionTree>())); - } - tree.setChildren(set); - return tree; - } - public static ActionTree buildActionTree(Action actions, DungeonRoom dungeonRoom) { - return buildActionTree(null, actions, dungeonRoom, new HashMap<Action, ActionTree>()); - } - - - - private static ActionTree buildActionTree(ActionTree parent, Action action, DungeonRoom dungeonRoom, Map<Action, ActionTree> alreadyBuilt) { - if (action == null) return null; - if (alreadyBuilt.containsKey(action)) { - ActionTree tree = alreadyBuilt.get(action); - tree.getParent().add(parent); - return tree; - } - - ActionTree tree = new ActionTree(); - alreadyBuilt.put(action, tree); - tree.setParent(new HashSet<ActionTree>()); - if (parent != null) - tree.getParent().add(parent); - tree.setCurrent(action); - HashSet<ActionTree> set = new HashSet(); - for (Action action2 : action.getPreRequisites(dungeonRoom)) { - set.add(buildActionTree(tree, action2, dungeonRoom, alreadyBuilt)); - } - tree.setChildren(set); - return tree; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/tree/ActionTreeUtil.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/tree/ActionTreeUtil.java deleted file mode 100644 index b0ffd2dc..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/tree/ActionTreeUtil.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <https://www.gnu.org/licenses/>. - */ - -package kr.syeyoung.dungeonsguide.dungeon.actions.tree; - -import kr.syeyoung.dungeonsguide.dungeon.actions.Action; - -import java.util.*; - -public class ActionTreeUtil { - public static List<Action> linearifyActionTree(ActionTree input) { - ActionTree tree = copyActionTree(input); - - List<Action> actions = new ArrayList<Action>(); - - int plsHalt = 0; - while (tree.getChildren().size() != 0) { - plsHalt ++; - if (plsHalt > 1000000) throw new IllegalStateException("Linearifying process ran for 1 million cycle"); - Set<ActionTree> visited = new HashSet<ActionTree>(); - ActionTree curr = tree; - - int plsHalt2 = 0; - while (curr.getChildren().size() != 0) { - plsHalt2 ++; - if (plsHalt2 > 1000000) throw new IllegalStateException("Finding the leaf of tree ran for 1 million cycles"); - if (visited.contains(curr)) throw new IllegalStateException("Circular Reference Detected"); - visited.add(curr); - curr = curr.getChildren().iterator().next(); - } - - plsHalt2 =0; - while(curr.getChildren().size() == 0) { - plsHalt2 ++; - if (plsHalt2 > 1000000) throw new IllegalStateException("Building of array ran for 1 million cycles"); - - actions.add(curr.getCurrent()); - if (curr.getParent().size() == 0) break; - for (ActionTree parentTree:curr.getParent()) - parentTree.getChildren().remove(curr); - curr = curr.getParent().iterator().next(); - } - } - return actions; - } - - public static ActionTree copyActionTree(ActionTree tree) { - Map<ActionTree, ActionTree> built = new HashMap<ActionTree, ActionTree>(); - if (tree.getParent().size() != 0) throw new IllegalArgumentException("that is not head of tree"); - return copyActionTree(tree, built); - } - private static ActionTree copyActionTree(ActionTree tree, Map<ActionTree, ActionTree> preBuilts) { - if (preBuilts.containsKey(tree)) return preBuilts.get(tree); - - ActionTree clone = new ActionTree(); - preBuilts.put(tree, clone); - - clone.setCurrent(tree.getCurrent()); - clone.setParent(new HashSet<ActionTree>()); - clone.setChildren(new HashSet<ActionTree>()); - for (ActionTree tree3 : tree.getChildren()) { - ActionTree clone3 = copyActionTree(tree3, preBuilts); - clone3.getParent().add(clone); - clone.getChildren().add(clone3); - } - return clone; - } -} |