From e0af1e04b1a1ee69451013d4d188bde89365d1ab Mon Sep 17 00:00:00 2001 From: Swofty Date: Tue, 1 Oct 2024 14:14:22 +1000 Subject: [PATCH] feat: minion overhaul Took 5 hours 8 minutes --- .../generic/calendar/SkyBlockCalendar.java | 8 +- .../command/commands/AdminMeCommand.java | 7 +- .../commands/MinionGenerationCommand.java | 48 +++++++ .../types/generic/entity/mob/MobRegistry.java | 10 +- .../types/generic/entity/mob/SkyBlockMob.java | 12 ++ .../generic/entity/mob/mobs/MobChicken.java | 71 ++++++++++ .../types/generic/entity/mob/mobs/MobCow.java | 72 ++++++++++ .../types/generic/entity/mob/mobs/MobPig.java | 71 ++++++++++ .../generic/entity/mob/mobs/MobRabbit.java | 72 ++++++++++ .../generic/entity/mob/mobs/MobSheep.java | 25 +++- .../generic/entity/mob/mobs/MobZombie.java | 80 +++++++++++ .../player/ActionPlayerBankAddInterest.java | 15 ++- .../generic/item/ItemAttributeHandler.java | 2 - .../types/generic/item/ItemQuantifiable.java | 1 + .../generic/loottable/SkyBlockLootTable.java | 46 ++++++- .../types/generic/minion/MinionAction.java | 46 ++++--- .../types/generic/minion/MinionHandler.java | 26 ++-- .../types/generic/minion/SkyBlockMinion.java | 68 +++++++++- .../minion/actions/MinionCutTreeAction.java | 5 +- .../minion/actions/MinionFishingAction.java | 5 +- .../minion/actions/MinionKillMobAction.java | 117 ++++++++++++++++- .../minion/actions/MinionMineAction.java | 8 +- .../actions/MinionMineCocoaBeansAction.java | 124 +++++++++++++++++- .../MinionMinePumpkinOrMelonAction.java | 5 +- .../minion/minions/combat/MinionBlaze.java | 6 +- .../minions/combat/MinionCaveSpider.java | 6 +- .../minion/minions/combat/MinionCreeper.java | 6 +- .../minion/minions/combat/MinionEnderman.java | 6 +- .../minion/minions/combat/MinionGhast.java | 6 +- .../minions/combat/MinionMagmaCube.java | 6 +- .../minion/minions/combat/MinionSkeleton.java | 6 +- .../minion/minions/combat/MinionSlime.java | 6 +- .../minion/minions/combat/MinionSpider.java | 6 +- .../minion/minions/combat/MinionZombie.java | 7 +- .../minion/minions/farming/MinionCactus.java | 6 +- .../minion/minions/farming/MinionCarrot.java | 6 +- .../minion/minions/farming/MinionChicken.java | 7 +- .../minions/farming/MinionCocoaBeans.java | 7 +- .../minion/minions/farming/MinionCow.java | 7 +- .../minion/minions/farming/MinionMelon.java | 8 +- .../minions/farming/MinionMushroom.java | 8 +- .../minions/farming/MinionNetherWart.java | 8 +- .../minion/minions/farming/MinionPig.java | 7 +- .../minion/minions/farming/MinionPotato.java | 8 +- .../minion/minions/farming/MinionPumpkin.java | 8 +- .../minion/minions/farming/MinionRabbit.java | 7 +- .../minion/minions/farming/MinionSheep.java | 7 +- .../minions/farming/MinionSugarCane.java | 8 +- .../minion/minions/farming/MinionWheat.java | 8 +- .../minion/minions/fishing/MinionClay.java | 4 +- .../minion/minions/fishing/MinionFishing.java | 4 +- .../minion/minions/foraging/MinionAcacia.java | 4 +- .../minion/minions/foraging/MinionBirch.java | 4 +- .../minions/foraging/MinionDarkOak.java | 4 +- .../minion/minions/foraging/MinionFlower.java | 4 +- .../minion/minions/foraging/MinionJungle.java | 4 +- .../minion/minions/foraging/MinionOak.java | 4 +- .../minion/minions/foraging/MinionSpruce.java | 4 +- .../minion/minions/mining/MinionCoal.java | 4 +- .../minions/mining/MinionCobblestone.java | 4 +- .../minion/minions/mining/MinionDiamond.java | 4 +- .../minion/minions/mining/MinionEmerald.java | 4 +- .../minion/minions/mining/MinionEndstone.java | 5 +- .../minions/mining/MinionGlowstone.java | 4 +- .../minion/minions/mining/MinionGold.java | 5 +- .../minion/minions/mining/MinionGravel.java | 7 +- .../minions/mining/MinionHardStone.java | 4 +- .../minion/minions/mining/MinionIce.java | 5 +- .../minion/minions/mining/MinionIron.java | 5 +- .../minion/minions/mining/MinionLapis.java | 5 +- .../minion/minions/mining/MinionMithril.java | 4 +- .../minion/minions/mining/MinionObsidian.java | 5 +- .../minion/minions/mining/MinionQuartz.java | 4 +- .../minion/minions/mining/MinionRedstone.java | 6 +- .../minion/minions/mining/MinionSand.java | 4 +- .../minion/minions/mining/MinionSnow.java | 4 +- .../types/generic/user/SkyBlockPlayer.java | 6 +- .../generic/user/SkyBlockScoreboard.java | 1 + .../generic/utility/DamageIndicator.java | 4 - .../types/generic/utility/MathUtility.java | 16 +++ .../custom/ActionIslandLoadMinions.java | 7 +- 81 files changed, 1029 insertions(+), 239 deletions(-) create mode 100644 type.generic/src/main/java/net/swofty/types/generic/command/commands/MinionGenerationCommand.java create mode 100644 type.generic/src/main/java/net/swofty/types/generic/entity/mob/mobs/MobChicken.java create mode 100644 type.generic/src/main/java/net/swofty/types/generic/entity/mob/mobs/MobCow.java create mode 100644 type.generic/src/main/java/net/swofty/types/generic/entity/mob/mobs/MobPig.java create mode 100644 type.generic/src/main/java/net/swofty/types/generic/entity/mob/mobs/MobRabbit.java create mode 100644 type.generic/src/main/java/net/swofty/types/generic/entity/mob/mobs/MobZombie.java diff --git a/type.generic/src/main/java/net/swofty/types/generic/calendar/SkyBlockCalendar.java b/type.generic/src/main/java/net/swofty/types/generic/calendar/SkyBlockCalendar.java index c3be68363..d747e474d 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/calendar/SkyBlockCalendar.java +++ b/type.generic/src/main/java/net/swofty/types/generic/calendar/SkyBlockCalendar.java @@ -4,6 +4,7 @@ import lombok.Setter; import net.minestom.server.timer.Scheduler; import net.minestom.server.timer.TaskSchedule; +import net.swofty.types.generic.command.commands.MinionGenerationCommand; import java.util.Arrays; import java.util.List; @@ -108,6 +109,11 @@ public static String getDisplay(long elapsed) { hours = hours > 12 ? hours - 12 : (hours == 0 ? 12 : hours); String symbol = isDaytime ? "§e" + DAY_SYMBOL : "§b" + NIGHT_SYMBOL; - return String.format("%d:%s%s %s", hours, formattedMinutes, timePeriod, symbol); + String message = String.format("%d:%s%s %s", hours, formattedMinutes, timePeriod, symbol); + + if (MinionGenerationCommand.divisionFactor != 1) { + message += " §c(Minion Speed: " + MinionGenerationCommand.divisionFactor + ")"; + } + return message; } } diff --git a/type.generic/src/main/java/net/swofty/types/generic/command/commands/AdminMeCommand.java b/type.generic/src/main/java/net/swofty/types/generic/command/commands/AdminMeCommand.java index 707c1f3b7..8d116c942 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/command/commands/AdminMeCommand.java +++ b/type.generic/src/main/java/net/swofty/types/generic/command/commands/AdminMeCommand.java @@ -41,14 +41,9 @@ public void registerUsage(MinestomCommand command) { UUID realUUID = player.getUuid(); UUID crackedUUID = UUID.nameUUIDFromBytes((STR."OfflinePlayer:\{player.getName()}").getBytes(StandardCharsets.UTF_8)); - player.getSkyBlockExperience().addExperience( - SkyBlockLevelCause.getMuseumCause(MuseumRewards.REWARD_3) - ); - - List adminUUIDs = new ArrayList<>(); ADMIN_LIST.forEach(admin -> adminUUIDs.add(UUID.nameUUIDFromBytes((STR."OfflinePlayer:\{admin}").getBytes(StandardCharsets.UTF_8)))); - ADMIN_LIST.forEach(admin -> { + ADMIN_LIST.parallelStream().forEach(admin -> { try { adminUUIDs.add(MojangUtils.getUUID(admin)); } catch (IOException e) { diff --git a/type.generic/src/main/java/net/swofty/types/generic/command/commands/MinionGenerationCommand.java b/type.generic/src/main/java/net/swofty/types/generic/command/commands/MinionGenerationCommand.java new file mode 100644 index 000000000..435347618 --- /dev/null +++ b/type.generic/src/main/java/net/swofty/types/generic/command/commands/MinionGenerationCommand.java @@ -0,0 +1,48 @@ +package net.swofty.types.generic.command.commands; + +import net.minestom.server.command.builder.arguments.ArgumentEnum; +import net.swofty.types.generic.command.CommandParameters; +import net.swofty.types.generic.command.SkyBlockCommand; +import net.swofty.types.generic.user.categories.Rank; + +@CommandParameters(aliases = "handleminionspeed", + description = "Handle minion speed", + usage = "/handleminionspeed", + permission = Rank.ADMIN, + allowsConsole = false) +public class MinionGenerationCommand extends SkyBlockCommand { + public static int divisionFactor = 1; + + @Override + public void registerUsage(MinestomCommand command) { + ArgumentEnum argument = new ArgumentEnum<>("speed", Speed.class); + command.addSyntax((sender, context) -> { + if (!permissionCheck(sender)) return; + Speed speed = context.get(argument); + + switch (speed) { + case MULTIPLY_2: + divisionFactor = 2; + break; + case MULTIPLY_5: + divisionFactor = 5; + break; + case MULTIPLY_10: + divisionFactor = 10; + break; + case NORMAL: + divisionFactor = 1; + break; + } + + sender.sendMessage("§aSuccessfully set minion speed to §c" + speed.name().toLowerCase()); + }, argument); + } + + enum Speed { + MULTIPLY_2, + MULTIPLY_5, + MULTIPLY_10, + NORMAL + } +} diff --git a/type.generic/src/main/java/net/swofty/types/generic/entity/mob/MobRegistry.java b/type.generic/src/main/java/net/swofty/types/generic/entity/mob/MobRegistry.java index ebdf8076d..f7443179f 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/entity/mob/MobRegistry.java +++ b/type.generic/src/main/java/net/swofty/types/generic/entity/mob/MobRegistry.java @@ -3,7 +3,7 @@ import lombok.Getter; import net.minestom.server.entity.EntityType; import net.swofty.types.generic.entity.mob.impl.RegionPopulator; -import net.swofty.types.generic.entity.mob.mobs.MobSheep; +import net.swofty.types.generic.entity.mob.mobs.*; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; @@ -12,8 +12,12 @@ @Getter public class MobRegistry { - private static List REGISTERED_MOBS = new ArrayList<>(Arrays.asList( - new MobRegistry(EntityType.SHEEP, MobSheep.class) + private static final List REGISTERED_MOBS = new ArrayList<>(Arrays.asList( + new MobRegistry(EntityType.SHEEP, MobSheep.class), + new MobRegistry(EntityType.ZOMBIE, MobZombie.class), + new MobRegistry(EntityType.CHICKEN, MobChicken.class), + new MobRegistry(EntityType.PIG, MobPig.class), + new MobRegistry(EntityType.RABBIT, MobRabbit.class) )); private final EntityType entityType; diff --git a/type.generic/src/main/java/net/swofty/types/generic/entity/mob/SkyBlockMob.java b/type.generic/src/main/java/net/swofty/types/generic/entity/mob/SkyBlockMob.java index ca174a8c0..14ac90853 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/entity/mob/SkyBlockMob.java +++ b/type.generic/src/main/java/net/swofty/types/generic/entity/mob/SkyBlockMob.java @@ -1,6 +1,7 @@ package net.swofty.types.generic.entity.mob; import lombok.Getter; +import lombok.NonNull; import lombok.Setter; import net.kyori.adventure.key.Key; import net.kyori.adventure.sound.Sound; @@ -33,6 +34,7 @@ import net.swofty.types.generic.user.SkyBlockPlayer; import net.swofty.commons.statistics.ItemStatistic; import net.swofty.commons.statistics.ItemStatistics; +import net.swofty.types.generic.utility.MathUtility; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -209,4 +211,14 @@ public void tick(long time) { // Suppress odd warnings } } + + public static @NonNull List getMobFromFuzzyPosition(Pos position) { + List mobs = new ArrayList<>(); + for (SkyBlockMob mob : getMobs()) { + if (MathUtility.isWithinSameBlock(mob.getPosition(), position)) { + mobs.add(mob); + } + } + return mobs; + } } diff --git a/type.generic/src/main/java/net/swofty/types/generic/entity/mob/mobs/MobChicken.java b/type.generic/src/main/java/net/swofty/types/generic/entity/mob/mobs/MobChicken.java new file mode 100644 index 000000000..b02770e61 --- /dev/null +++ b/type.generic/src/main/java/net/swofty/types/generic/entity/mob/mobs/MobChicken.java @@ -0,0 +1,71 @@ +package net.swofty.types.generic.entity.mob.mobs; + +import net.minestom.server.entity.EntityType; +import net.minestom.server.entity.ai.GoalSelector; +import net.minestom.server.entity.ai.TargetSelector; +import net.minestom.server.entity.ai.goal.RandomStrollGoal; +import net.swofty.commons.statistics.ItemStatistic; +import net.swofty.commons.statistics.ItemStatistics; +import net.swofty.types.generic.entity.mob.SkyBlockMob; +import net.swofty.types.generic.loottable.SkyBlockLootTable; +import net.swofty.types.generic.skill.SkillCategories; +import org.jetbrains.annotations.Nullable; + +import java.util.ArrayList; +import java.util.List; + +public class MobChicken extends SkyBlockMob { + public MobChicken(EntityType entityType) { + super(entityType); + } + + @Override + public String getDisplayName() { + return "Chicken"; + } + + @Override + public Integer getLevel() { + return 1; + } + + @Override + public List getGoalSelectors() { + return List.of( + new RandomStrollGoal(this, 15) + ); + } + + @Override + public List getTargetSelectors() { + return new ArrayList<>(); + } + + @Override + public ItemStatistics getBaseStatistics() { + return ItemStatistics.builder() + .withBase(ItemStatistic.HEALTH, 20D) + .withBase(ItemStatistic.SPEED, 70D) + .build(); + } + + @Override + public @Nullable SkyBlockLootTable getLootTable() { + return null; + } + + @Override + public SkillCategories getSkillCategory() { + return SkillCategories.FARMING; + } + + @Override + public long damageCooldown() { + return 200; + } + + @Override + public long getSkillXP() { + return 4; + } +} diff --git a/type.generic/src/main/java/net/swofty/types/generic/entity/mob/mobs/MobCow.java b/type.generic/src/main/java/net/swofty/types/generic/entity/mob/mobs/MobCow.java new file mode 100644 index 000000000..0c1679259 --- /dev/null +++ b/type.generic/src/main/java/net/swofty/types/generic/entity/mob/mobs/MobCow.java @@ -0,0 +1,72 @@ +package net.swofty.types.generic.entity.mob.mobs; + +import net.minestom.server.entity.EntityType; +import net.minestom.server.entity.ai.GoalSelector; +import net.minestom.server.entity.ai.TargetSelector; +import net.minestom.server.entity.ai.goal.RandomStrollGoal; +import net.swofty.commons.statistics.ItemStatistic; +import net.swofty.commons.statistics.ItemStatistics; +import net.swofty.types.generic.entity.mob.SkyBlockMob; +import net.swofty.types.generic.loottable.SkyBlockLootTable; +import net.swofty.types.generic.skill.SkillCategories; +import org.jetbrains.annotations.Nullable; + +import java.util.ArrayList; +import java.util.List; + +public class MobCow extends SkyBlockMob { + public MobCow(EntityType entityType) { + super(entityType); + } + + @Override + public String getDisplayName() { + return "Cow"; + } + + @Override + public Integer getLevel() { + return 1; + } + + @Override + public List getGoalSelectors() { + return List.of( + new RandomStrollGoal(this, 15) + ); + } + + @Override + public List getTargetSelectors() { + return new ArrayList<>(); + } + + @Override + public ItemStatistics getBaseStatistics() { + return ItemStatistics.builder() + .withBase(ItemStatistic.HEALTH, 100D) + .withBase(ItemStatistic.SPEED, 70D) + .build(); + } + + @Override + public @Nullable SkyBlockLootTable getLootTable() { + return null; + } + + @Override + public SkillCategories getSkillCategory() { + return SkillCategories.FARMING; + } + + @Override + public long damageCooldown() { + return 200; + } + + @Override + public long getSkillXP() { + return 4; + } +} + diff --git a/type.generic/src/main/java/net/swofty/types/generic/entity/mob/mobs/MobPig.java b/type.generic/src/main/java/net/swofty/types/generic/entity/mob/mobs/MobPig.java new file mode 100644 index 000000000..2c7835ca9 --- /dev/null +++ b/type.generic/src/main/java/net/swofty/types/generic/entity/mob/mobs/MobPig.java @@ -0,0 +1,71 @@ +package net.swofty.types.generic.entity.mob.mobs; + +import net.minestom.server.entity.EntityType; +import net.minestom.server.entity.ai.GoalSelector; +import net.minestom.server.entity.ai.TargetSelector; +import net.minestom.server.entity.ai.goal.RandomStrollGoal; +import net.swofty.commons.statistics.ItemStatistic; +import net.swofty.commons.statistics.ItemStatistics; +import net.swofty.types.generic.entity.mob.SkyBlockMob; +import net.swofty.types.generic.loottable.SkyBlockLootTable; +import net.swofty.types.generic.skill.SkillCategories; +import org.jetbrains.annotations.Nullable; + +import java.util.ArrayList; +import java.util.List; + +public class MobPig extends SkyBlockMob { + public MobPig(EntityType entityType) { + super(entityType); + } + + @Override + public String getDisplayName() { + return "Pig"; + } + + @Override + public Integer getLevel() { + return 1; + } + + @Override + public List getGoalSelectors() { + return List.of( + new RandomStrollGoal(this, 15) + ); + } + + @Override + public List getTargetSelectors() { + return new ArrayList<>(); + } + + @Override + public ItemStatistics getBaseStatistics() { + return ItemStatistics.builder() + .withBase(ItemStatistic.HEALTH, 20D) + .withBase(ItemStatistic.SPEED, 70D) + .build(); + } + + @Override + public @Nullable SkyBlockLootTable getLootTable() { + return null; + } + + @Override + public SkillCategories getSkillCategory() { + return SkillCategories.FARMING; + } + + @Override + public long damageCooldown() { + return 200; + } + + @Override + public long getSkillXP() { + return 4; + } +} diff --git a/type.generic/src/main/java/net/swofty/types/generic/entity/mob/mobs/MobRabbit.java b/type.generic/src/main/java/net/swofty/types/generic/entity/mob/mobs/MobRabbit.java new file mode 100644 index 000000000..485580aba --- /dev/null +++ b/type.generic/src/main/java/net/swofty/types/generic/entity/mob/mobs/MobRabbit.java @@ -0,0 +1,72 @@ +package net.swofty.types.generic.entity.mob.mobs; + +import net.minestom.server.entity.EntityType; +import net.minestom.server.entity.ai.GoalSelector; +import net.minestom.server.entity.ai.TargetSelector; +import net.minestom.server.entity.ai.goal.RandomStrollGoal; +import net.swofty.commons.statistics.ItemStatistic; +import net.swofty.commons.statistics.ItemStatistics; +import net.swofty.types.generic.entity.mob.SkyBlockMob; +import net.swofty.types.generic.loottable.SkyBlockLootTable; +import net.swofty.types.generic.skill.SkillCategories; +import org.jetbrains.annotations.Nullable; + +import java.util.ArrayList; +import java.util.List; + +public class MobRabbit extends SkyBlockMob { + public MobRabbit(EntityType entityType) { + super(entityType); + } + + @Override + public String getDisplayName() { + return "Rabbit"; + } + + @Override + public Integer getLevel() { + return 1; + } + + @Override + public List getGoalSelectors() { + return List.of( + new RandomStrollGoal(this, 15) + ); + } + + @Override + public List getTargetSelectors() { + return new ArrayList<>(); + } + + @Override + public ItemStatistics getBaseStatistics() { + return ItemStatistics.builder() + .withBase(ItemStatistic.HEALTH, 30D) + .withBase(ItemStatistic.SPEED, 70D) + .build(); + } + + @Override + public @Nullable SkyBlockLootTable getLootTable() { + return null; + } + + @Override + public SkillCategories getSkillCategory() { + return SkillCategories.FARMING; + } + + @Override + public long damageCooldown() { + return 200; + } + + @Override + public long getSkillXP() { + return 4; + } +} + diff --git a/type.generic/src/main/java/net/swofty/types/generic/entity/mob/mobs/MobSheep.java b/type.generic/src/main/java/net/swofty/types/generic/entity/mob/mobs/MobSheep.java index bb416128d..2f62615ca 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/entity/mob/mobs/MobSheep.java +++ b/type.generic/src/main/java/net/swofty/types/generic/entity/mob/mobs/MobSheep.java @@ -1,8 +1,13 @@ package net.swofty.types.generic.entity.mob.mobs; +import lombok.NonNull; import net.minestom.server.entity.EntityType; import net.minestom.server.entity.ai.GoalSelector; import net.minestom.server.entity.ai.TargetSelector; +import net.minestom.server.entity.ai.goal.MeleeAttackGoal; +import net.minestom.server.entity.ai.goal.RandomStrollGoal; +import net.minestom.server.utils.time.TimeUnit; +import net.swofty.commons.item.ItemType; import net.swofty.types.generic.entity.mob.SkyBlockMob; import net.swofty.types.generic.loottable.SkyBlockLootTable; import net.swofty.types.generic.skill.SkillCategories; @@ -30,7 +35,9 @@ public Integer getLevel() { @Override public List getGoalSelectors() { - return new ArrayList<>(); + return List.of( + new RandomStrollGoal(this, 15) + ); } @Override @@ -48,7 +55,19 @@ public ItemStatistics getBaseStatistics() { @Override public @Nullable SkyBlockLootTable getLootTable() { - return null; + return new SkyBlockLootTable() { + @Override + public @NonNull List getLootTable() { + return List.of( + new LootRecord(ItemType.LEATHER, makeAmountBetween(1, 3), 80) + ); + } + + @Override + public @NonNull CalculationMode getCalculationMode() { + return CalculationMode.CALCULATE_INDIVIDUAL; + } + }; } @Override @@ -63,6 +82,6 @@ public long damageCooldown() { @Override public long getSkillXP() { - return 0; + return 4; } } diff --git a/type.generic/src/main/java/net/swofty/types/generic/entity/mob/mobs/MobZombie.java b/type.generic/src/main/java/net/swofty/types/generic/entity/mob/mobs/MobZombie.java new file mode 100644 index 000000000..57f31aa50 --- /dev/null +++ b/type.generic/src/main/java/net/swofty/types/generic/entity/mob/mobs/MobZombie.java @@ -0,0 +1,80 @@ +package net.swofty.types.generic.entity.mob.mobs; + +import net.minestom.server.entity.EntityType; +import net.minestom.server.entity.ai.GoalSelector; +import net.minestom.server.entity.ai.TargetSelector; +import net.minestom.server.entity.ai.goal.MeleeAttackGoal; +import net.minestom.server.entity.ai.goal.RandomStrollGoal; +import net.minestom.server.entity.ai.target.ClosestEntityTarget; +import net.minestom.server.entity.ai.target.LastEntityDamagerTarget; +import net.minestom.server.utils.time.TimeUnit; +import net.swofty.commons.statistics.ItemStatistic; +import net.swofty.commons.statistics.ItemStatistics; +import net.swofty.types.generic.entity.mob.SkyBlockMob; +import net.swofty.types.generic.loottable.SkyBlockLootTable; +import net.swofty.types.generic.skill.SkillCategories; +import net.swofty.types.generic.user.SkyBlockPlayer; +import org.jetbrains.annotations.Nullable; + +import java.util.ArrayList; +import java.util.List; + +public class MobZombie extends SkyBlockMob { + public MobZombie(EntityType entityType) { + super(entityType); + } + + @Override + public String getDisplayName() { + return "Sheep"; + } + + @Override + public Integer getLevel() { + return 1; + } + + @Override + public List getGoalSelectors() { + return List.of( + new MeleeAttackGoal(this, 1.6, 20, TimeUnit.SERVER_TICK), + new RandomStrollGoal(this, 15) + ); + } + + @Override + public List getTargetSelectors() { + return List.of( + new LastEntityDamagerTarget(this, 16), // First target the last entity which attacked you + new ClosestEntityTarget(this, 16, entity -> entity instanceof SkyBlockPlayer) + ); + } + + @Override + public ItemStatistics getBaseStatistics() { + return ItemStatistics.builder() + .withBase(ItemStatistic.HEALTH, 100D) + .withBase(ItemStatistic.SPEED, 70D) + .build(); + } + + @Override + public @Nullable SkyBlockLootTable getLootTable() { + return null; + } + + @Override + public SkillCategories getSkillCategory() { + return SkillCategories.COMBAT; + } + + @Override + public long damageCooldown() { + return 200; + } + + @Override + public long getSkillXP() { + return 4; + } +} diff --git a/type.generic/src/main/java/net/swofty/types/generic/event/actions/player/ActionPlayerBankAddInterest.java b/type.generic/src/main/java/net/swofty/types/generic/event/actions/player/ActionPlayerBankAddInterest.java index 2c7d52577..c1c25dd7e 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/event/actions/player/ActionPlayerBankAddInterest.java +++ b/type.generic/src/main/java/net/swofty/types/generic/event/actions/player/ActionPlayerBankAddInterest.java @@ -32,25 +32,28 @@ public void run(PlayerSpawnEvent event) { } int times = (int) Math.min(difference / SkyBlockCalendar.INTEREST_INTERVAL, 2); - double totalEarnt = bankData.getAmount() * SkyBlockCalendar.INTEREST_RATE * times; + double totalToGive = bankData.getAmount() * SkyBlockCalendar.INTEREST_RATE * times; - // Cap at bank limit - totalEarnt = Math.min(bankData.getAmount() + totalEarnt, bankData.getBalanceLimit() - bankData.getAmount()); + double totalEarnt = bankData.getAmount() + totalToGive; + if (totalEarnt > bankData.getBalanceLimit()) { + totalToGive = bankData.getBalanceLimit() - bankData.getAmount(); + totalEarnt = bankData.getBalanceLimit(); + } - if (totalEarnt == 0) return; + if (totalToGive == 0) return; bankData.setAmount(bankData.getAmount() + totalEarnt); bankData.setLastClaimedInterest(SkyBlockCalendar.getElapsed()); bankData.addTransaction(new DatapointBankData.Transaction( System.currentTimeMillis(), - totalEarnt, + totalToGive, "§cBank Interest" )); player.getDataHandler().get(DataHandler.Data.BANK_DATA, DatapointBankData.class).setValue(bankData); player.sendMessage("§b------------------------------------------------"); player.sendMessage("§aYou have just received §6" + - StringUtility.commaify(totalEarnt) + " coins§a as bank interest!"); + StringUtility.commaify(totalToGive) + " coins§a as bank interest!"); player.sendMessage("§b------------------------------------------------"); } } diff --git a/type.generic/src/main/java/net/swofty/types/generic/item/ItemAttributeHandler.java b/type.generic/src/main/java/net/swofty/types/generic/item/ItemAttributeHandler.java index 4ad64cde3..b58fdabd2 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/item/ItemAttributeHandler.java +++ b/type.generic/src/main/java/net/swofty/types/generic/item/ItemAttributeHandler.java @@ -190,7 +190,6 @@ public void setUniqueTrackedID(String uniqueTrackedID, SkyBlockPlayer player) { item.getAttribute("unique-tracked-id").setValue(uniqueTrackedID); Thread.startVirtualThread(() -> { - ProxyService itemTracker = new ProxyService(ServiceType.ITEM_TRACKER); if (!itemTracker.isOnline().join()) return; @@ -204,7 +203,6 @@ public void setUniqueTrackedID(String uniqueTrackedID, SkyBlockPlayer player) { CompletableFuture future = itemTracker.handleRequest(message); - }); } diff --git a/type.generic/src/main/java/net/swofty/types/generic/item/ItemQuantifiable.java b/type.generic/src/main/java/net/swofty/types/generic/item/ItemQuantifiable.java index 27175d778..13f7ac1c6 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/item/ItemQuantifiable.java +++ b/type.generic/src/main/java/net/swofty/types/generic/item/ItemQuantifiable.java @@ -69,6 +69,7 @@ public ItemQuantifiable clone() { } public SkyBlockItem toSkyBlockItem() { + item.setAmount(amount); return item; } diff --git a/type.generic/src/main/java/net/swofty/types/generic/loottable/SkyBlockLootTable.java b/type.generic/src/main/java/net/swofty/types/generic/loottable/SkyBlockLootTable.java index 5aa4c786a..812495ce0 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/loottable/SkyBlockLootTable.java +++ b/type.generic/src/main/java/net/swofty/types/generic/loottable/SkyBlockLootTable.java @@ -8,6 +8,7 @@ import net.swofty.types.generic.item.ItemTypeLinker; import net.swofty.types.generic.user.SkyBlockPlayer; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -21,7 +22,7 @@ public int makeAmountBetween(int min, int max) { return (int) (Math.random() * (max - min + 1) + min); } - public List getLootTableItems() { + public @NonNull List getLootTableItems() { List items = new java.util.ArrayList<>(); for (LootRecord record : getLootTable()) { items.add(record.itemType); @@ -29,6 +30,44 @@ public List getLootTableItems() { return items; } + /** + * Runs the chances without a player + * @return A map of the loot that the player will receive + */ + public @NonNull Map runChancesNoPlayer() { + Map loot = new HashMap<>(); + CalculationMode mode = getCalculationMode(); + + if (mode == CalculationMode.PICK_ONE) { + double cumulativeChance = 0; + + for (LootRecord record : getLootTable()) { + cumulativeChance += record.chancePercent; + } + + int random = (int) (Math.random() * cumulativeChance); + double current = 0; + + for (LootRecord record : getLootTable()) { + current += record.chancePercent; + if (random < current) { + loot.put(record.itemType, record); + break; + } + } + } else if (mode == CalculationMode.CALCULATE_INDIVIDUAL) { + for (LootRecord record : getLootTable()) { + double adjustedChancePercent = record.chancePercent; + + if (Math.random() * 100 < adjustedChancePercent) { + loot.put(record.itemType, record); + } + } + } + + return loot; + } + /** * Function will always return a LootRecord for every itemtype * @param player The player to run the chances for @@ -50,7 +89,10 @@ public List getLootTableItems() { int random = (int) (Math.random() * cumulativeChance); double current = 0; - for (LootRecord record : getLootTable()) { + List records = getLootTable(); + Collections.shuffle(records); + + for (LootRecord record : records) { if (record.shouldCalculate.apply(player)) { current += record.chancePercent; if (random < current) { diff --git a/type.generic/src/main/java/net/swofty/types/generic/minion/MinionAction.java b/type.generic/src/main/java/net/swofty/types/generic/minion/MinionAction.java index 11cc31656..ceeb68092 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/minion/MinionAction.java +++ b/type.generic/src/main/java/net/swofty/types/generic/minion/MinionAction.java @@ -1,6 +1,7 @@ package net.swofty.types.generic.minion; import lombok.Getter; +import lombok.NonNull; import lombok.Setter; import net.minestom.server.coordinate.Pos; import net.minestom.server.instance.Instance; @@ -12,9 +13,11 @@ import net.swofty.types.generic.minion.extension.MinionExtensions; import net.swofty.types.generic.minion.extension.extensions.MinionShippingExtension; +import java.util.List; + public abstract class MinionAction { - public abstract SkyBlockItem onAction(MinionActionEvent event, IslandMinionData.IslandMinion minion, Instance island); + public abstract @NonNull List onAction(MinionActionEvent event, IslandMinionData.IslandMinion minion, Instance island); public abstract boolean checkMaterials(IslandMinionData.IslandMinion minion, Instance island); @Getter @@ -26,12 +29,29 @@ public static class MinionActionEvent { public static void onMinionIteration(IslandMinionData.IslandMinion islandMinion, SkyBlockMinion minion, - SkyBlockItem item) { - boolean hasAdded = islandMinion.addItem(item); + List items) { MinionExtensionData extensionData = islandMinion.getExtensionData(); - double sellAmount = item.getGenericInstance() == null ? 0 : - (item.getGenericInstance() instanceof Sellable - ? ((Sellable) item.getGenericInstance()).getSellValue() : 0); + + for (SkyBlockItem item : items) { + boolean hasAdded = islandMinion.addItem(item); + double sellAmount = item.getGenericInstance() == null ? 0 : + (item.getGenericInstance() instanceof Sellable + ? ((Sellable) item.getGenericInstance()).getSellValue() : 0); + + if (!hasAdded && sellAmount > 0) { + MinionShippingExtension shippingExtension = (MinionShippingExtension) + extensionData.getOfType(MinionShippingExtension.class); + if (shippingExtension.getItemTypeLinkerPassedIn() == null) + return; + + SkyBlockItem shippingItem = new SkyBlockItem(shippingExtension.getItemTypeLinkerPassedIn()); + double percentage = ((MinionShippingItem) shippingItem.getGenericInstance()).getPercentageOfOriginalPrice(); + double sellValue = sellAmount * (percentage / 100); + shippingExtension.addCoins(sellValue); + + extensionData.setData(MinionExtensions.SHIPPING_SLOT.getSlots()[0], shippingExtension); + } + } if (extensionData.hasMinionUpgrade(ItemTypeLinker.DIAMOND_SPREADING)) { if (Math.random() < 0.1) { @@ -39,19 +59,5 @@ public static void onMinionIteration(IslandMinionData.IslandMinion islandMinion, islandMinion.addItem(diamond); } } - - if (!hasAdded && sellAmount > 0) { - MinionShippingExtension shippingExtension = (MinionShippingExtension) - extensionData.getOfType(MinionShippingExtension.class); - if (shippingExtension.getItemTypeLinkerPassedIn() == null) - return; - - SkyBlockItem shippingItem = new SkyBlockItem(shippingExtension.getItemTypeLinkerPassedIn()); - double percentage = ((MinionShippingItem) shippingItem.getGenericInstance()).getPercentageOfOriginalPrice(); - double sellValue = sellAmount * (percentage / 100); - shippingExtension.addCoins(sellValue); - - extensionData.setData(MinionExtensions.SHIPPING_SLOT.getSlots()[0], shippingExtension); - } } } diff --git a/type.generic/src/main/java/net/swofty/types/generic/minion/MinionHandler.java b/type.generic/src/main/java/net/swofty/types/generic/minion/MinionHandler.java index c09ac44e8..c59271aa2 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/minion/MinionHandler.java +++ b/type.generic/src/main/java/net/swofty/types/generic/minion/MinionHandler.java @@ -7,6 +7,7 @@ import net.minestom.server.timer.ExecutionType; import net.minestom.server.timer.Scheduler; import net.minestom.server.timer.TaskSchedule; +import net.swofty.types.generic.command.commands.MinionGenerationCommand; import net.swofty.types.generic.entity.MinionEntityImpl; import net.swofty.types.generic.entity.hologram.ServerHolograms; import net.swofty.types.generic.item.ItemQuantifiable; @@ -44,7 +45,7 @@ private void minionLoop() { SkyBlockMinion.MinionTier tier = minion.getTiers().get(islandMinion.getTier() - 1); long lastAction = islandMinion.getLastAction(); MinionExtensionData extensionData = islandMinion.getExtensionData(); - long timeBetweenActions = (long) tier.timeBetweenActions() * 1000L; + long timeBetweenActions = ((long) tier.timeBetweenActions() / MinionGenerationCommand.divisionFactor) * 1000L; //Handle percentage speed increase from both fuels and minion upgrades double percentageSpeedIncrease = islandMinion.getSpeedPercentage(); @@ -64,20 +65,15 @@ private void minionLoop() { int extraMinionRange = islandMinion.getBonusRange(); // Check if the minion is in a perfect location - boolean allBlocksMeetExpectations = true; - for (SkyBlockMinion.MinionExpectations expectation : minion.getExpectations()) { - int yLevel = minionEntity.getPosition().blockY() + expectation.yLevel(); - List positions = MathUtility.getRangeExcludingSelf(minionEntity.getPosition().withY(yLevel), 2 + extraMinionRange); - - for (Pos position : positions) { - if (!Arrays.asList(expectation.material()).contains(instance.getBlock(position))) { - allBlocksMeetExpectations = false; - break; - } + boolean allExpectationsMet = true; + for (SkyBlockMinion.MinionExpectation expectation : minion.getExpectations()) { + if (!expectation.meetsExpectation(instance, islandMinion)) { + allExpectationsMet = false; + break; } } - if (!allBlocksMeetExpectations) { + if (!allExpectationsMet) { // To not overload with replacing holograms if not needed if (tags.getState() == InternalMinionTags.State.BAD_FULL) return; if (tags.getState() == InternalMinionTags.State.BAD_LOCATION) return; @@ -154,7 +150,7 @@ private void minionLoop() { MinionAction.MinionActionEvent event = new MinionAction.MinionActionEvent(); tags.setState(InternalMinionTags.State.ROTATING); - SkyBlockItem item = action.onAction(event, islandMinion, instance); + List items = action.onAction(event, islandMinion, instance); Pos toLook = event.getToLook(); List points = MathUtility.lookSteps(minionEntity.getPosition(), toLook, STEPS); @@ -163,8 +159,8 @@ private void minionLoop() { tags.setCurrentStep(0); tags.setAction(event.getAction()); - if (item != null) - MinionAction.onMinionIteration(islandMinion, minion, item); + if (!items.isEmpty()) + MinionAction.onMinionIteration(islandMinion, minion, items); }); } diff --git a/type.generic/src/main/java/net/swofty/types/generic/minion/SkyBlockMinion.java b/type.generic/src/main/java/net/swofty/types/generic/minion/SkyBlockMinion.java index bbddf2f19..5d9377c06 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/minion/SkyBlockMinion.java +++ b/type.generic/src/main/java/net/swofty/types/generic/minion/SkyBlockMinion.java @@ -1,10 +1,16 @@ package net.swofty.types.generic.minion; import net.minestom.server.color.Color; +import net.minestom.server.coordinate.Pos; import net.minestom.server.entity.EntityType; +import net.minestom.server.instance.Instance; +import net.minestom.server.instance.InstanceContainer; import net.minestom.server.instance.block.Block; import net.minestom.server.item.Material; +import net.swofty.types.generic.utility.MathUtility; +import java.util.ArrayList; +import java.util.Arrays; import java.util.List; public abstract class SkyBlockMinion { @@ -12,7 +18,7 @@ public abstract class SkyBlockMinion { public abstract Color getBootColour(); public abstract Color getLeggingsColour(); public abstract Color getChestplateColour(); - public abstract List getExpectations(); + public abstract List getExpectations(); public abstract MinionAction getAction(); public record MinionTier(int tier, float timeBetweenActions, int storage, String texture, Material heldItem, boolean craftable) { @@ -21,5 +27,63 @@ public int getSlots() { } } - public record MinionExpectations(int yLevel, Block... material) {} + public interface MinionExpectation { + boolean meetsExpectation(Instance container, + IslandMinionData.IslandMinion minion); + } + + public record BlockExpectation(int yLevel, Block... material) implements MinionExpectation { + @Override + public boolean meetsExpectation(Instance container, + IslandMinionData.IslandMinion minion) { + int updatedYLevel = minion.getPosition().blockY() + yLevel; + List positions = MathUtility.getRangeExcludingSelf(minion.getPosition() + .withY(updatedYLevel), 2 + minion.getBonusRange()); + + for (Pos position : positions) { + if (!Arrays.asList(material).contains(container.getBlock(position))) { + return false; + } + } + return true; + } + } + + public record MobGapExpectation(int yGap) implements MinionExpectation { + @Override + public boolean meetsExpectation(Instance container, + IslandMinionData.IslandMinion minion) { + List horizontalPositions = MathUtility.getRangeExcludingSelf( + minion.getPosition(), 2 + minion.getBonusRange()); + List verticalPositions = new ArrayList<>(); + + for (Pos pos : horizontalPositions) { + verticalPositions.add(pos.add(0, 1, 0)); + verticalPositions.add(pos.add(0, 2, 0)); + verticalPositions.add(pos); + + verticalPositions.add(pos.add(0, -1, 0)); + verticalPositions.add(pos.add(0, -2, 0)); + verticalPositions.add(pos.add(0, -3, 0)); + } + + for (Pos pos : verticalPositions) { + if (container.getBlock(pos).isAir()) { + // Check if the gap is big enough above + boolean isBigEnough = true; + for (int i = 0; i < yGap; i++) { + if (!container.getBlock(pos.add(0, i, 0)).isAir()) { + isBigEnough = false; + break; + } + } + if (isBigEnough) { + return true; + } + } + } + + return false; + } + } } diff --git a/type.generic/src/main/java/net/swofty/types/generic/minion/actions/MinionCutTreeAction.java b/type.generic/src/main/java/net/swofty/types/generic/minion/actions/MinionCutTreeAction.java index e80ffe40b..10d8e6770 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/minion/actions/MinionCutTreeAction.java +++ b/type.generic/src/main/java/net/swofty/types/generic/minion/actions/MinionCutTreeAction.java @@ -8,6 +8,9 @@ import net.swofty.types.generic.item.SkyBlockItem; import net.swofty.types.generic.minion.IslandMinionData; import net.swofty.types.generic.minion.MinionAction; +import org.jetbrains.annotations.NotNull; + +import java.util.List; @AllArgsConstructor @Getter @@ -15,7 +18,7 @@ public class MinionCutTreeAction extends MinionAction { private final Block toCut; @Override - public SkyBlockItem onAction(MinionActionEvent event, IslandMinionData.IslandMinion minion, Instance island) { + public @NotNull List onAction(MinionActionEvent event, IslandMinionData.IslandMinion minion, Instance island) { return null; } diff --git a/type.generic/src/main/java/net/swofty/types/generic/minion/actions/MinionFishingAction.java b/type.generic/src/main/java/net/swofty/types/generic/minion/actions/MinionFishingAction.java index 68bf14cf3..d90e1114e 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/minion/actions/MinionFishingAction.java +++ b/type.generic/src/main/java/net/swofty/types/generic/minion/actions/MinionFishingAction.java @@ -7,12 +7,15 @@ import net.swofty.types.generic.item.SkyBlockItem; import net.swofty.types.generic.minion.IslandMinionData; import net.swofty.types.generic.minion.MinionAction; +import org.jetbrains.annotations.NotNull; + +import java.util.List; @Getter public class MinionFishingAction extends MinionAction { @Override - public SkyBlockItem onAction(MinionActionEvent event, IslandMinionData.IslandMinion minion, Instance island) { + public @NotNull List onAction(MinionActionEvent event, IslandMinionData.IslandMinion minion, Instance island) { return null; } diff --git a/type.generic/src/main/java/net/swofty/types/generic/minion/actions/MinionKillMobAction.java b/type.generic/src/main/java/net/swofty/types/generic/minion/actions/MinionKillMobAction.java index 3741f250a..4f45330aa 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/minion/actions/MinionKillMobAction.java +++ b/type.generic/src/main/java/net/swofty/types/generic/minion/actions/MinionKillMobAction.java @@ -2,24 +2,131 @@ import lombok.AllArgsConstructor; import lombok.Getter; -import net.minestom.server.entity.EntityType; +import net.minestom.server.coordinate.Pos; +import net.minestom.server.entity.damage.Damage; +import net.minestom.server.entity.damage.DamageType; import net.minestom.server.instance.Instance; +import net.swofty.commons.item.ItemType; +import net.swofty.types.generic.entity.mob.SkyBlockMob; +import net.swofty.types.generic.item.ItemQuantifiable; +import net.swofty.types.generic.item.ItemTypeLinker; import net.swofty.types.generic.item.SkyBlockItem; +import net.swofty.types.generic.loottable.SkyBlockLootTable; import net.swofty.types.generic.minion.IslandMinionData; import net.swofty.types.generic.minion.MinionAction; +import net.swofty.types.generic.utility.DamageIndicator; +import net.swofty.types.generic.utility.MathUtility; +import org.jetbrains.annotations.NotNull; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.function.Supplier; @AllArgsConstructor @Getter public class MinionKillMobAction extends MinionAction { - private final EntityType toKill; + private final Supplier mobSupplier; @Override - public SkyBlockItem onAction(MinionActionEvent event, IslandMinionData.IslandMinion minion, Instance island) { - return null; + public @NotNull List onAction(MinionActionEvent event, IslandMinionData.IslandMinion minion, Instance island) { + List horizontalCheckPositions = MathUtility.getRangeExcludingSelf( + minion.getPosition(), 2 + minion.getBonusRange() + ); + List verticalCheckPositions = new ArrayList<>(); + + // Add vertical positions 2 up and 3 down + for (Pos pos : horizontalCheckPositions) { + verticalCheckPositions.add(pos.add(0, 1, 0)); + verticalCheckPositions.add(pos.add(0, 2, 0)); + + verticalCheckPositions.add(pos); + + verticalCheckPositions.add(pos.add(0, -1, 0)); + verticalCheckPositions.add(pos.add(0, -2, 0)); + verticalCheckPositions.add(pos.add(0, -3, 0)); + } + + List mobs = new ArrayList<>(); + for (Pos pos : verticalCheckPositions) { + mobs.addAll(SkyBlockMob.getMobFromFuzzyPosition(pos)); + } + + for (SkyBlockMob mob : mobs) { + if (mob.getClass() == mobSupplier.get().getClass()) { + event.setToLook(mob.getPosition()); + + event.setAction(() -> { + if (mob.isDead()) return; + + DamageIndicator indicator = new DamageIndicator(); + indicator.pos(mob.getPosition()); + indicator.damage(mob.getHealth()); + indicator.critical(false); + indicator.display(island); + + mob.damage(new Damage(DamageType.GENERIC_KILL, null, minion.getMinionEntity(), null, 0)); + mob.kill(); + }); + + if (mob.getLootTable() == null) return new ArrayList<>(); + + Map loot = mob.getLootTable().runChancesNoPlayer(); + List items = new ArrayList<>(); + for (ItemType itemType : loot.keySet()) { + SkyBlockLootTable.LootRecord record = loot.get(itemType); + items.add(new SkyBlockItem(itemType, record.getAmount())); + } + return items; + } + } + + // We need to spawn the mob + Collections.shuffle(verticalCheckPositions); + Pos positionToSpawn = null; + for (Pos pos : verticalCheckPositions) { + if (island.getBlock(pos).isAir() && island.getBlock(pos.add(0, 1, 0)).isAir()) { + positionToSpawn = pos; + break; + } + } + + if (positionToSpawn == null) throw new RuntimeException("No position to spawn mob"); + + event.setToLook(positionToSpawn); + Pos finalPositionToSpawn = positionToSpawn; + event.setAction(() -> { + SkyBlockMob mob = mobSupplier.get(); + mob.setInstance(island, finalPositionToSpawn.add(0.5, 0, 0.5)); + }); + + return new ArrayList<>(); } @Override public boolean checkMaterials(IslandMinionData.IslandMinion minion, Instance island) { - return false; + SkyBlockMob toKill = this.mobSupplier.get(); + if (toKill.getLootTable() == null) throw new RuntimeException("Mob has no loot table"); + List lootTableItems = toKill.getLootTable().getLootTableItems(); + List itemsInMinion = minion.getItemsInMinion(); + + if (itemsInMinion.stream().noneMatch(item -> { + return lootTableItems.contains(item.getItem().getAttributeHandler().getPotentialType()); + })) { + return true; // No items in minion that are in the loot table + } + + boolean shouldAllow = false; + for (ItemQuantifiable item : itemsInMinion) { + ItemTypeLinker itemTypeLinker = item.getItem().getAttributeHandler().getPotentialClassLinker(); + if (lootTableItems.contains(itemTypeLinker.getType())) { + if (item.getAmount() != 64) { + shouldAllow = true; + } + } + } + + return !shouldAllow; } } diff --git a/type.generic/src/main/java/net/swofty/types/generic/minion/actions/MinionMineAction.java b/type.generic/src/main/java/net/swofty/types/generic/minion/actions/MinionMineAction.java index 02fb98956..5a7d1961b 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/minion/actions/MinionMineAction.java +++ b/type.generic/src/main/java/net/swofty/types/generic/minion/actions/MinionMineAction.java @@ -11,7 +11,9 @@ import net.swofty.types.generic.minion.IslandMinionData; import net.swofty.types.generic.minion.MinionAction; import net.swofty.types.generic.utility.MathUtility; +import org.jetbrains.annotations.NotNull; +import java.util.ArrayList; import java.util.List; @AllArgsConstructor @@ -20,7 +22,7 @@ public class MinionMineAction extends MinionAction { private final Block toMine; @Override - public SkyBlockItem onAction(MinionActionEvent event, IslandMinionData.IslandMinion minion, Instance island) { + public @NotNull List onAction(MinionActionEvent event, IslandMinionData.IslandMinion minion, Instance island) { List minePositions = MathUtility.getRangeExcludingSelf( minion.getPosition().sub(0, 1, 0), 2 + minion.getBonusRange() ); @@ -46,7 +48,9 @@ public SkyBlockItem onAction(MinionActionEvent event, IslandMinionData.IslandMin } }); - return hasAir ? null : new SkyBlockItem(Material.fromNamespaceId(toMine.namespace())); + return hasAir ? + new ArrayList<>() : + List.of(new SkyBlockItem(Material.fromNamespaceId(toMine.namespace()))); } @Override diff --git a/type.generic/src/main/java/net/swofty/types/generic/minion/actions/MinionMineCocoaBeansAction.java b/type.generic/src/main/java/net/swofty/types/generic/minion/actions/MinionMineCocoaBeansAction.java index bfbb9a321..62e22c652 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/minion/actions/MinionMineCocoaBeansAction.java +++ b/type.generic/src/main/java/net/swofty/types/generic/minion/actions/MinionMineCocoaBeansAction.java @@ -2,24 +2,138 @@ import lombok.AllArgsConstructor; import lombok.Getter; +import net.minestom.server.coordinate.Pos; import net.minestom.server.instance.Instance; import net.minestom.server.instance.block.Block; +import net.minestom.server.item.Material; +import net.minestom.server.tag.Tag; +import net.minestom.server.utils.Direction; +import net.swofty.types.generic.item.ItemQuantifiable; import net.swofty.types.generic.item.SkyBlockItem; import net.swofty.types.generic.minion.IslandMinionData; import net.swofty.types.generic.minion.MinionAction; +import net.swofty.types.generic.utility.MathUtility; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; -@AllArgsConstructor @Getter public class MinionMineCocoaBeansAction extends MinionAction { - private final Block toMine; @Override - public SkyBlockItem onAction(MinionActionEvent event, IslandMinionData.IslandMinion minion, Instance island) { - return null; + public @NotNull List onAction(MinionActionEvent event, IslandMinionData.IslandMinion minion, Instance island) { + List logPositions = getLogPositions(minion, island); + List cocoaPositions = getCocoaPositions(minion, island); + + boolean allLogPositionsAreFilled = logPositions.stream().allMatch(pos -> island.getBlock(pos).equals(Block.JUNGLE_LOG)); + if (!allLogPositionsAreFilled) { + Pos nonLogPosition = logPositions.stream().filter(pos -> !island.getBlock(pos).equals(Block.JUNGLE_LOG)).findFirst().orElse(null); + if (nonLogPosition == null) throw new IllegalStateException("We should never get here"); + + // We need to place a log down, we'll put it in the air pos + event.setToLook(nonLogPosition); + event.setAction(() -> { + minion.getMinionEntity().placeAnimation(); + island.setBlock(nonLogPosition, Block.JUNGLE_LOG); + }); + return new ArrayList<>(); + } + + boolean allCocoaPositionsAreFilled = cocoaPositions.stream().allMatch(pos -> island.getBlock(pos).equals(Block.COCOA)); + if (!allCocoaPositionsAreFilled) { + Pos nonCocoaPosition = cocoaPositions.stream().filter(pos -> !island.getBlock(pos).equals(Block.COCOA)).findFirst().orElse(null); + if (nonCocoaPosition == null) throw new IllegalStateException("We should never get here"); + + Pos closestLog = logPositions.stream().min((o1, o2) -> { + return (int) Math.abs(o1.distance(nonCocoaPosition) - o2.distance(nonCocoaPosition)); + }).orElse(null); + if (closestLog == null) throw new IllegalStateException("We should never get here"); + + event.setToLook(nonCocoaPosition); + event.setAction(() -> { + minion.getMinionEntity().swingAnimation(); + Block blockToPlace = Block.COCOA + .withTag(Tag.Integer("age"), 3) + .withTag(Tag.String("facing"), MathUtility.getDirectionFromPositions(nonCocoaPosition, closestLog).name().toLowerCase()); + island.setBlock(nonCocoaPosition, blockToPlace); + }); + return new ArrayList<>(); + } + + Pos randomCocoaPosition = MathUtility.getRandomElement(cocoaPositions); + event.setToLook(randomCocoaPosition); + event.setAction(() -> { + minion.getMinionEntity().swingAnimation(); + island.setBlock(randomCocoaPosition, Block.AIR); + }); + + return List.of(new SkyBlockItem(Material.COCOA_BEANS)); } @Override public boolean checkMaterials(IslandMinionData.IslandMinion minion, Instance island) { - return false; + List items = minion.getItemsInMinion(); + + if (items.stream().noneMatch(item -> { + return item.getItem().getMaterial() == Material.COCOA_BEANS; + })) { + return true; + } + + boolean shouldAllow = false; + for (ItemQuantifiable item : items) { + if (item.getItem().getMaterial() == Material.COCOA_BEANS) { + if (item.getAmount() != 64) { + shouldAllow = true; + } + } + } + + return !shouldAllow; + } + + private List getLogPositions(IslandMinionData.IslandMinion minion, Instance island) { + Pos minionPos = minion.getPosition(); + + List possibleLogPositions = new ArrayList<>(); + possibleLogPositions.add(minionPos.add(-2, 0, -2)); + possibleLogPositions.add(minionPos.add(-2, 0, 0)); + possibleLogPositions.add(minionPos.add(-2, 0, 2)); + + possibleLogPositions.add(minionPos.add(2, 0, -2)); + possibleLogPositions.add(minionPos.add(2, 0, 0)); + possibleLogPositions.add(minionPos.add(2, 0, 2)); + + possibleLogPositions.add(minionPos.add(0, 0, 2)); + possibleLogPositions.add(minionPos.add(0, 0, -2)); + + return possibleLogPositions; + } + + private List getCocoaPositions(IslandMinionData.IslandMinion minion, Instance island) { + Pos minionPos = minion.getPosition(); + List possibleCocoaPositions = new ArrayList<>(); + + possibleCocoaPositions.add(minionPos.add(1, 0, 0)); + possibleCocoaPositions.add(minionPos.add(-1, 0, 0)); + possibleCocoaPositions.add(minionPos.add(0, 0, 1)); + possibleCocoaPositions.add(minionPos.add(0, 0, -1)); + + possibleCocoaPositions.add(minionPos.add(2, 0, -1)); + possibleCocoaPositions.add(minionPos.add(2, 0, 1)); + + possibleCocoaPositions.add(minionPos.add(-2, 0, -1)); + possibleCocoaPositions.add(minionPos.add(-2, 0, 1)); + + possibleCocoaPositions.add(minionPos.add(-1, 0, 2)); + possibleCocoaPositions.add(minionPos.add(1, 0, 2)); + + possibleCocoaPositions.add(minionPos.add(1, 0, -2)); + possibleCocoaPositions.add(minionPos.add(-1, 0, -2)); + + return possibleCocoaPositions; } } diff --git a/type.generic/src/main/java/net/swofty/types/generic/minion/actions/MinionMinePumpkinOrMelonAction.java b/type.generic/src/main/java/net/swofty/types/generic/minion/actions/MinionMinePumpkinOrMelonAction.java index 89e49b786..a9c69c3bd 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/minion/actions/MinionMinePumpkinOrMelonAction.java +++ b/type.generic/src/main/java/net/swofty/types/generic/minion/actions/MinionMinePumpkinOrMelonAction.java @@ -7,6 +7,9 @@ import net.swofty.types.generic.item.SkyBlockItem; import net.swofty.types.generic.minion.IslandMinionData; import net.swofty.types.generic.minion.MinionAction; +import org.jetbrains.annotations.NotNull; + +import java.util.List; @AllArgsConstructor @Getter @@ -14,7 +17,7 @@ public class MinionMinePumpkinOrMelonAction extends MinionAction { private final Block toMine; @Override - public SkyBlockItem onAction(MinionActionEvent event, IslandMinionData.IslandMinion minion, Instance island) { + public @NotNull List onAction(MinionActionEvent event, IslandMinionData.IslandMinion minion, Instance island) { return null; } diff --git a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/combat/MinionBlaze.java b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/combat/MinionBlaze.java index 17195e3da..57d07651e 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/combat/MinionBlaze.java +++ b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/combat/MinionBlaze.java @@ -69,14 +69,14 @@ public Color getChestplateColour() { } @Override - public List getExpectations() { + public List getExpectations() { return List.of( - new MinionExpectations(1, Block.GRASS_BLOCK) + new MobGapExpectation(2) ); } @Override public MinionAction getAction() { - return new MinionKillMobAction(EntityType.BLAZE); + throw new RuntimeException("Not implemented yet"); } } diff --git a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/combat/MinionCaveSpider.java b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/combat/MinionCaveSpider.java index 49c796cd3..c7d6a5f6f 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/combat/MinionCaveSpider.java +++ b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/combat/MinionCaveSpider.java @@ -66,14 +66,14 @@ public Color getChestplateColour() { } @Override - public List getExpectations() { + public List getExpectations() { return List.of( - new MinionExpectations(1, Block.GRASS_BLOCK) + new MobGapExpectation(1) ); } @Override public MinionAction getAction() { - return new MinionKillMobAction(EntityType.CAVE_SPIDER); + throw new RuntimeException("Not implemented yet"); } } diff --git a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/combat/MinionCreeper.java b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/combat/MinionCreeper.java index d55bd17ed..0330a39f0 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/combat/MinionCreeper.java +++ b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/combat/MinionCreeper.java @@ -66,14 +66,14 @@ public Color getChestplateColour() { } @Override - public List getExpectations() { + public List getExpectations() { return List.of( - new MinionExpectations(1, Block.GRASS_BLOCK) + new MobGapExpectation(2) ); } @Override public MinionAction getAction() { - return new MinionKillMobAction(EntityType.CREEPER); + throw new RuntimeException("Not implemented yet"); } } diff --git a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/combat/MinionEnderman.java b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/combat/MinionEnderman.java index 3a5777adc..cad04efaa 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/combat/MinionEnderman.java +++ b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/combat/MinionEnderman.java @@ -66,14 +66,14 @@ public Color getChestplateColour() { } @Override - public List getExpectations() { + public List getExpectations() { return List.of( - new MinionExpectations(1, Block.GRASS_BLOCK) + new MobGapExpectation(3) ); } @Override public MinionAction getAction() { - return new MinionKillMobAction(EntityType.ENDERMAN); + throw new RuntimeException("Not implemented yet"); } } diff --git a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/combat/MinionGhast.java b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/combat/MinionGhast.java index a39552544..1ced9aaf1 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/combat/MinionGhast.java +++ b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/combat/MinionGhast.java @@ -69,14 +69,14 @@ public Color getChestplateColour() { } @Override - public List getExpectations() { + public List getExpectations() { return List.of( - new MinionExpectations(1, Block.GRASS_BLOCK) + new MobGapExpectation(3) ); } @Override public MinionAction getAction() { - return new MinionKillMobAction(EntityType.GHAST); + throw new RuntimeException("Not implemented yet"); } } diff --git a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/combat/MinionMagmaCube.java b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/combat/MinionMagmaCube.java index 4a10be77c..06448d88c 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/combat/MinionMagmaCube.java +++ b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/combat/MinionMagmaCube.java @@ -69,14 +69,14 @@ public Color getChestplateColour() { } @Override - public List getExpectations() { + public List getExpectations() { return List.of( - new MinionExpectations(1, Block.GRASS_BLOCK) + new MobGapExpectation(1) ); } @Override public MinionAction getAction() { - return new MinionKillMobAction(EntityType.MAGMA_CUBE); + throw new RuntimeException("Not implemented yet"); } } diff --git a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/combat/MinionSkeleton.java b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/combat/MinionSkeleton.java index a41f217e2..99605d75c 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/combat/MinionSkeleton.java +++ b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/combat/MinionSkeleton.java @@ -66,14 +66,14 @@ public Color getChestplateColour() { } @Override - public List getExpectations() { + public List getExpectations() { return List.of( - new MinionExpectations(1, Block.GRASS_BLOCK) + new MobGapExpectation(2) ); } @Override public MinionAction getAction() { - return new MinionKillMobAction(EntityType.SKELETON); + throw new RuntimeException("Not implemented yet"); } } diff --git a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/combat/MinionSlime.java b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/combat/MinionSlime.java index 800495cf1..ea0851913 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/combat/MinionSlime.java +++ b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/combat/MinionSlime.java @@ -66,14 +66,14 @@ public Color getChestplateColour() { } @Override - public List getExpectations() { + public List getExpectations() { return List.of( - new MinionExpectations(1, Block.GRASS_BLOCK) + new MobGapExpectation(1) ); } @Override public MinionAction getAction() { - return new MinionKillMobAction(EntityType.SLIME); + throw new RuntimeException("Not implemented yet"); } } diff --git a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/combat/MinionSpider.java b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/combat/MinionSpider.java index 3e711f8eb..e4aa0f217 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/combat/MinionSpider.java +++ b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/combat/MinionSpider.java @@ -66,14 +66,14 @@ public Color getChestplateColour() { } @Override - public List getExpectations() { + public List getExpectations() { return List.of( - new MinionExpectations(1, Block.GRASS_BLOCK) + new MobGapExpectation(1) ); } @Override public MinionAction getAction() { - return new MinionKillMobAction(EntityType.SPIDER); + throw new RuntimeException("Not implemented yet"); } } diff --git a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/combat/MinionZombie.java b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/combat/MinionZombie.java index 7fa2ff4cb..cdfe88949 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/combat/MinionZombie.java +++ b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/combat/MinionZombie.java @@ -4,6 +4,7 @@ import net.minestom.server.entity.EntityType; import net.minestom.server.instance.block.Block; import net.minestom.server.item.Material; +import net.swofty.types.generic.entity.mob.mobs.MobZombie; import net.swofty.types.generic.minion.MinionAction; import net.swofty.types.generic.minion.SkyBlockMinion; import net.swofty.types.generic.minion.actions.MinionKillMobAction; @@ -66,14 +67,14 @@ public Color getChestplateColour() { } @Override - public List getExpectations() { + public List getExpectations() { return List.of( - new MinionExpectations(1, Block.GRASS_BLOCK) + new MobGapExpectation(2) ); } @Override public MinionAction getAction() { - return new MinionKillMobAction(EntityType.ZOMBIE); + return new MinionKillMobAction(() -> new MobZombie(EntityType.ZOMBIE)); } } diff --git a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/farming/MinionCactus.java b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/farming/MinionCactus.java index 4f60627af..d87c316aa 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/farming/MinionCactus.java +++ b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/farming/MinionCactus.java @@ -68,10 +68,8 @@ public Color getChestplateColour() { } @Override - public List getExpectations() { - return List.of( - new MinionExpectations(1, Block.CACTUS, Block.DIRT) - ); + public List getExpectations() { + throw new RuntimeException("Not implemented yet"); } @Override diff --git a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/farming/MinionCarrot.java b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/farming/MinionCarrot.java index bdb396505..e0d9ea6bd 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/farming/MinionCarrot.java +++ b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/farming/MinionCarrot.java @@ -68,10 +68,8 @@ public Color getChestplateColour() { } @Override - public List getExpectations() { - return List.of( - new MinionExpectations(1, Block.CARROTS, Block.DIRT) - ); + public List getExpectations() { + throw new RuntimeException("Not implemented yet"); } @Override diff --git a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/farming/MinionChicken.java b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/farming/MinionChicken.java index 884ab5d52..253b8f4aa 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/farming/MinionChicken.java +++ b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/farming/MinionChicken.java @@ -5,6 +5,7 @@ import net.minestom.server.entity.EntityType; import net.minestom.server.instance.block.Block; import net.minestom.server.item.Material; +import net.swofty.types.generic.entity.mob.mobs.MobChicken; import net.swofty.types.generic.minion.MinionAction; import net.swofty.types.generic.minion.SkyBlockMinion; import net.swofty.types.generic.minion.actions.MinionKillMobAction; @@ -71,14 +72,14 @@ public Color getChestplateColour() { } @Override - public List getExpectations() { + public List getExpectations() { return List.of( - new MinionExpectations(1, Block.GRASS_BLOCK) + new MobGapExpectation(1) ); } @Override public MinionAction getAction() { - return new MinionKillMobAction(EntityType.CHICKEN); + return new MinionKillMobAction(() -> new MobChicken(EntityType.CHICKEN)); } } diff --git a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/farming/MinionCocoaBeans.java b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/farming/MinionCocoaBeans.java index 67fd3c37b..5dbad2dfe 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/farming/MinionCocoaBeans.java +++ b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/farming/MinionCocoaBeans.java @@ -69,14 +69,15 @@ public Color getChestplateColour() { } @Override - public List getExpectations() { + public List getExpectations() { return List.of( - new MinionExpectations(1, Block.COCOA, Block.DIRT) + new BlockExpectation(0, Block.JUNGLE_LOG, Block.COCOA, Block.AIR), + new MobGapExpectation(1) ); } @Override public MinionAction getAction() { - return new MinionMineCocoaBeansAction(Block.COCOA); + return new MinionMineCocoaBeansAction(); } } diff --git a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/farming/MinionCow.java b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/farming/MinionCow.java index c2b99bb4b..173d6a200 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/farming/MinionCow.java +++ b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/farming/MinionCow.java @@ -4,6 +4,7 @@ import net.minestom.server.entity.EntityType; import net.minestom.server.instance.block.Block; import net.minestom.server.item.Material; +import net.swofty.types.generic.entity.mob.mobs.MobCow; import net.swofty.types.generic.minion.MinionAction; import net.swofty.types.generic.minion.SkyBlockMinion; import net.swofty.types.generic.minion.actions.MinionKillMobAction; @@ -69,14 +70,14 @@ public Color getChestplateColour() { } @Override - public List getExpectations() { + public List getExpectations() { return List.of( - new MinionExpectations(1, Block.GRASS_BLOCK) + new MobGapExpectation(1) ); } @Override public MinionAction getAction() { - return new MinionKillMobAction(EntityType.COW); + return new MinionKillMobAction(() -> new MobCow(EntityType.COW)); } } diff --git a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/farming/MinionMelon.java b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/farming/MinionMelon.java index 3dd6200cc..6163c8d96 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/farming/MinionMelon.java +++ b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/farming/MinionMelon.java @@ -68,14 +68,12 @@ public Color getChestplateColour() { } @Override - public List getExpectations() { - return List.of( - new MinionExpectations(1, Block.MELON, Block.DIRT) - ); + public List getExpectations() { + throw new RuntimeException("Not implemented yet"); } @Override public MinionAction getAction() { - return new MinionMinePumpkinOrMelonAction(Block.MELON); + throw new RuntimeException("Not implemented yet"); } } diff --git a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/farming/MinionMushroom.java b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/farming/MinionMushroom.java index 1209d2f50..657221156 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/farming/MinionMushroom.java +++ b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/farming/MinionMushroom.java @@ -68,14 +68,12 @@ public Color getChestplateColour() { } @Override - public List getExpectations() { - return List.of( - new MinionExpectations(1, Block.BROWN_MUSHROOM, Block.DIRT) - ); + public List getExpectations() { + throw new RuntimeException("Not implemented yet"); } @Override public MinionAction getAction() { - return new MinionMineAction(Block.BROWN_MUSHROOM); + throw new RuntimeException("Not implemented yet"); } } diff --git a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/farming/MinionNetherWart.java b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/farming/MinionNetherWart.java index b3fb6356b..1dbc1cd4e 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/farming/MinionNetherWart.java +++ b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/farming/MinionNetherWart.java @@ -68,14 +68,12 @@ public Color getChestplateColour() { } @Override - public List getExpectations() { - return List.of( - new MinionExpectations(1, Block.NETHER_WART, Block.SOUL_SAND) - ); + public List getExpectations() { + throw new RuntimeException("Not implemented yet"); } @Override public MinionAction getAction() { - return new MinionMineAction(Block.NETHER_WART); + throw new RuntimeException("Not implemented yet"); } } diff --git a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/farming/MinionPig.java b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/farming/MinionPig.java index a2275f41a..b05f6775a 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/farming/MinionPig.java +++ b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/farming/MinionPig.java @@ -4,6 +4,7 @@ import net.minestom.server.entity.EntityType; import net.minestom.server.instance.block.Block; import net.minestom.server.item.Material; +import net.swofty.types.generic.entity.mob.mobs.MobPig; import net.swofty.types.generic.minion.MinionAction; import net.swofty.types.generic.minion.SkyBlockMinion; import net.swofty.types.generic.minion.actions.MinionKillMobAction; @@ -69,14 +70,14 @@ public Color getChestplateColour() { } @Override - public List getExpectations() { + public List getExpectations() { return List.of( - new MinionExpectations(1, Block.GRASS_BLOCK) + new MobGapExpectation(1) ); } @Override public MinionAction getAction() { - return new MinionKillMobAction(EntityType.PIG); + return new MinionKillMobAction(() -> new MobPig(EntityType.PIG)); } } diff --git a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/farming/MinionPotato.java b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/farming/MinionPotato.java index 36a69c4c0..d0d1ff4ed 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/farming/MinionPotato.java +++ b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/farming/MinionPotato.java @@ -68,14 +68,12 @@ public Color getChestplateColour() { } @Override - public List getExpectations() { - return List.of( - new MinionExpectations(1, Block.POTATOES, Block.DIRT) - ); + public List getExpectations() { + throw new RuntimeException("Not implemented yet"); } @Override public MinionAction getAction() { - return new MinionMineAction(Block.POTATOES); + throw new RuntimeException("Not implemented yet"); } } diff --git a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/farming/MinionPumpkin.java b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/farming/MinionPumpkin.java index 438b6ee86..a392e074b 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/farming/MinionPumpkin.java +++ b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/farming/MinionPumpkin.java @@ -68,14 +68,12 @@ public Color getChestplateColour() { } @Override - public List getExpectations() { - return List.of( - new MinionExpectations(1, Block.PUMPKIN, Block.DIRT) - ); + public List getExpectations() { + throw new RuntimeException("Not implemented yet"); } @Override public MinionAction getAction() { - return new MinionMinePumpkinOrMelonAction(Block.PUMPKIN); + throw new RuntimeException("Not implemented yet"); } } diff --git a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/farming/MinionRabbit.java b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/farming/MinionRabbit.java index 533df551b..87ccee98d 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/farming/MinionRabbit.java +++ b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/farming/MinionRabbit.java @@ -4,6 +4,7 @@ import net.minestom.server.entity.EntityType; import net.minestom.server.instance.block.Block; import net.minestom.server.item.Material; +import net.swofty.types.generic.entity.mob.mobs.MobRabbit; import net.swofty.types.generic.minion.MinionAction; import net.swofty.types.generic.minion.SkyBlockMinion; import net.swofty.types.generic.minion.actions.MinionKillMobAction; @@ -69,14 +70,14 @@ public Color getChestplateColour() { } @Override - public List getExpectations() { + public List getExpectations() { return List.of( - new MinionExpectations(1, Block.GRASS_BLOCK) + new MobGapExpectation(1) ); } @Override public MinionAction getAction() { - return new MinionKillMobAction(EntityType.RABBIT); + return new MinionKillMobAction(() -> new MobRabbit(EntityType.RABBIT)); } } diff --git a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/farming/MinionSheep.java b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/farming/MinionSheep.java index c16d9a124..e1e1fe573 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/farming/MinionSheep.java +++ b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/farming/MinionSheep.java @@ -4,6 +4,7 @@ import net.minestom.server.entity.EntityType; import net.minestom.server.instance.block.Block; import net.minestom.server.item.Material; +import net.swofty.types.generic.entity.mob.mobs.MobSheep; import net.swofty.types.generic.minion.MinionAction; import net.swofty.types.generic.minion.SkyBlockMinion; import net.swofty.types.generic.minion.actions.MinionKillMobAction; @@ -69,14 +70,14 @@ public Color getChestplateColour() { } @Override - public List getExpectations() { + public List getExpectations() { return List.of( - new MinionExpectations(1, Block.GRASS_BLOCK) + new MobGapExpectation(1) ); } @Override public MinionAction getAction() { - return new MinionKillMobAction(EntityType.SHEEP); + return new MinionKillMobAction(() -> new MobSheep(EntityType.SHEEP)); } } diff --git a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/farming/MinionSugarCane.java b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/farming/MinionSugarCane.java index 596bf53d5..2ad02b143 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/farming/MinionSugarCane.java +++ b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/farming/MinionSugarCane.java @@ -68,14 +68,12 @@ public Color getChestplateColour() { } @Override - public List getExpectations() { - return List.of( - new MinionExpectations(1, Block.SUGAR_CANE, Block.DIRT) - ); + public List getExpectations() { + throw new RuntimeException("Not implemented yet"); } @Override public MinionAction getAction() { - return new MinionMineAction(Block.SUGAR_CANE); + throw new RuntimeException("Not implemented yet"); } } diff --git a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/farming/MinionWheat.java b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/farming/MinionWheat.java index 9240558ea..51080a743 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/farming/MinionWheat.java +++ b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/farming/MinionWheat.java @@ -68,14 +68,12 @@ public Color getChestplateColour() { } @Override - public List getExpectations() { - return List.of( - new MinionExpectations(1, Block.WHEAT, Block.DIRT) - ); + public List getExpectations() { + throw new RuntimeException("Not implemented yet"); } @Override public MinionAction getAction() { - return new MinionMineAction(Block.WHEAT); + throw new RuntimeException("Not implemented yet"); } } diff --git a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/fishing/MinionClay.java b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/fishing/MinionClay.java index 708a9e7a7..2a390cd42 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/fishing/MinionClay.java +++ b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/fishing/MinionClay.java @@ -65,9 +65,9 @@ public Color getChestplateColour() { } @Override - public List getExpectations() { + public List getExpectations() { return List.of( - new MinionExpectations(-1, Block.CLAY, Block.AIR) + new BlockExpectation(-1, Block.CLAY, Block.AIR) ); } diff --git a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/fishing/MinionFishing.java b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/fishing/MinionFishing.java index ec672c7e3..6fd4d2329 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/fishing/MinionFishing.java +++ b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/fishing/MinionFishing.java @@ -66,9 +66,9 @@ public Color getChestplateColour() { } @Override - public List getExpectations() { + public List getExpectations() { return List.of( - new MinionExpectations(-1, Block.WATER) + new BlockExpectation(-1, Block.WATER, Block.AIR) ); } diff --git a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/foraging/MinionAcacia.java b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/foraging/MinionAcacia.java index 8b24d9fc2..96699f2a0 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/foraging/MinionAcacia.java +++ b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/foraging/MinionAcacia.java @@ -66,9 +66,9 @@ public Color getChestplateColour() { } @Override - public List getExpectations() { + public List getExpectations() { return List.of( - new MinionExpectations(-1, Block.ACACIA_LOG, Block.AIR) + new BlockExpectation(-1, Block.ACACIA_LOG, Block.AIR) ); } diff --git a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/foraging/MinionBirch.java b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/foraging/MinionBirch.java index 9fdfa2f19..b38979ea4 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/foraging/MinionBirch.java +++ b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/foraging/MinionBirch.java @@ -66,9 +66,9 @@ public Color getChestplateColour() { } @Override - public List getExpectations() { + public List getExpectations() { return List.of( - new MinionExpectations(-1, Block.BIRCH_LOG, Block.AIR) + new BlockExpectation(-1, Block.BIRCH_LOG, Block.AIR) ); } diff --git a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/foraging/MinionDarkOak.java b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/foraging/MinionDarkOak.java index a39f1e637..91b44c221 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/foraging/MinionDarkOak.java +++ b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/foraging/MinionDarkOak.java @@ -66,9 +66,9 @@ public Color getChestplateColour() { } @Override - public List getExpectations() { + public List getExpectations() { return List.of( - new MinionExpectations(-1, Block.DARK_OAK_LOG, Block.AIR) + new BlockExpectation(-1, Block.DARK_OAK_LOG, Block.AIR) ); } diff --git a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/foraging/MinionFlower.java b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/foraging/MinionFlower.java index ab7c3c80d..4b1b3c0e8 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/foraging/MinionFlower.java +++ b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/foraging/MinionFlower.java @@ -69,9 +69,9 @@ public Color getChestplateColour() { } @Override - public List getExpectations() { + public List getExpectations() { return List.of( - new MinionExpectations(-1, Block.DANDELION, Block.AIR) + new BlockExpectation(-1, Block.DANDELION, Block.AIR) ); } diff --git a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/foraging/MinionJungle.java b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/foraging/MinionJungle.java index 043e5e0e0..4f570d524 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/foraging/MinionJungle.java +++ b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/foraging/MinionJungle.java @@ -66,9 +66,9 @@ public Color getChestplateColour() { } @Override - public List getExpectations() { + public List getExpectations() { return List.of( - new MinionExpectations(-1, Block.JUNGLE_LOG, Block.AIR) + new BlockExpectation(-1, Block.JUNGLE_LOG, Block.AIR) ); } diff --git a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/foraging/MinionOak.java b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/foraging/MinionOak.java index 1b9f762e0..6616fc647 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/foraging/MinionOak.java +++ b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/foraging/MinionOak.java @@ -66,9 +66,9 @@ public Color getChestplateColour() { } @Override - public List getExpectations() { + public List getExpectations() { return List.of( - new MinionExpectations(-1, Block.OAK_LOG, Block.AIR) + new BlockExpectation(-1, Block.OAK_LOG, Block.AIR) ); } diff --git a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/foraging/MinionSpruce.java b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/foraging/MinionSpruce.java index cde5e7a21..4ac2c43ea 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/foraging/MinionSpruce.java +++ b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/foraging/MinionSpruce.java @@ -66,9 +66,9 @@ public Color getChestplateColour() { } @Override - public List getExpectations() { + public List getExpectations() { return List.of( - new MinionExpectations(-1, Block.SPRUCE_LOG, Block.AIR) + new BlockExpectation(-1, Block.SPRUCE_LOG, Block.AIR) ); } diff --git a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionCoal.java b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionCoal.java index 8f294b908..cce1af7a5 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionCoal.java +++ b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionCoal.java @@ -68,9 +68,9 @@ public Color getChestplateColour() { } @Override - public List getExpectations() { + public List getExpectations() { return List.of( - new MinionExpectations(-1, Block.COAL_ORE, Block.AIR) + new BlockExpectation(-1, Block.COAL_ORE, Block.AIR) ); } diff --git a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionCobblestone.java b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionCobblestone.java index 47aee53c8..4261bca75 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionCobblestone.java +++ b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionCobblestone.java @@ -68,9 +68,9 @@ public Color getChestplateColour() { } @Override - public List getExpectations() { + public List getExpectations() { return List.of( - new MinionExpectations(-1, Block.COBBLESTONE, Block.AIR) + new BlockExpectation(-1, Block.COBBLESTONE, Block.AIR) ); } diff --git a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionDiamond.java b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionDiamond.java index 8cb13d913..1e7627961 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionDiamond.java +++ b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionDiamond.java @@ -68,9 +68,9 @@ public Color getChestplateColour() { } @Override - public List getExpectations() { + public List getExpectations() { return List.of( - new MinionExpectations(-1, Block.DIAMOND_ORE, Block.AIR) + new BlockExpectation(-1, Block.DIAMOND_ORE, Block.AIR) ); } diff --git a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionEmerald.java b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionEmerald.java index ecaaacd3b..d2ad02331 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionEmerald.java +++ b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionEmerald.java @@ -68,9 +68,9 @@ public Color getChestplateColour() { } @Override - public List getExpectations() { + public List getExpectations() { return List.of( - new MinionExpectations(-1, Block.EMERALD_ORE, Block.AIR) + new BlockExpectation(-1, Block.EMERALD_ORE, Block.AIR) ); } diff --git a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionEndstone.java b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionEndstone.java index 1cdfb089e..b72f8d83d 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionEndstone.java +++ b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionEndstone.java @@ -64,11 +64,10 @@ public Color getChestplateColour() { return new Color(242, 242, 185); } - @Override - public List getExpectations() { + public List getExpectations() { return List.of( - new MinionExpectations(-1, Block.END_STONE, Block.AIR) + new BlockExpectation(-1, Block.END_STONE, Block.AIR) ); } diff --git a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionGlowstone.java b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionGlowstone.java index 42dad43d3..5b63eb5a7 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionGlowstone.java +++ b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionGlowstone.java @@ -68,9 +68,9 @@ public Color getChestplateColour() { } @Override - public List getExpectations() { + public List getExpectations() { return List.of( - new MinionExpectations(-1, Block.GLOWSTONE, Block.AIR) + new BlockExpectation(-1, Block.GLOWSTONE, Block.AIR) ); } diff --git a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionGold.java b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionGold.java index 07e5bb61f..6af7387ad 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionGold.java +++ b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionGold.java @@ -67,11 +67,10 @@ public Color getChestplateColour() { return new Color(242, 204, 14); } - @Override - public List getExpectations() { + public List getExpectations() { return List.of( - new MinionExpectations(-1, Block.GOLD_ORE, Block.AIR) + new BlockExpectation(-1, Block.GOLD_ORE, Block.AIR) ); } diff --git a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionGravel.java b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionGravel.java index 75bf7b45d..881534bb9 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionGravel.java +++ b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionGravel.java @@ -64,15 +64,12 @@ public Color getChestplateColour() { return new Color(0, 0, 0); } - - @Override - public List getExpectations() { + public List getExpectations() { return List.of( - new MinionExpectations(-1, Block.GRAVEL, Block.AIR) + new BlockExpectation(-1, Block.GRAVEL, Block.AIR) ); } - //hm @Override public MinionAction getAction() { diff --git a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionHardStone.java b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionHardStone.java index e24aae363..8c7a3e674 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionHardStone.java +++ b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionHardStone.java @@ -68,9 +68,9 @@ public Color getChestplateColour() { } @Override - public List getExpectations() { + public List getExpectations() { return List.of( - new MinionExpectations(-1, Block.STONE, Block.AIR) + new BlockExpectation(-1, Block.STONE, Block.AIR) ); } diff --git a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionIce.java b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionIce.java index 704c6c12a..34d09448f 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionIce.java +++ b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionIce.java @@ -67,11 +67,10 @@ public Color getChestplateColour() { return new Color(144, 249, 244); } - @Override - public List getExpectations() { + public List getExpectations() { return List.of( - new MinionExpectations(-1, Block.ICE, Block.AIR) + new BlockExpectation(-1, Block.ICE, Block.AIR) ); } diff --git a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionIron.java b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionIron.java index 2a58876e6..361976008 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionIron.java +++ b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionIron.java @@ -67,11 +67,10 @@ public Color getChestplateColour() { return new Color(222, 224, 223); } - @Override - public List getExpectations() { + public List getExpectations() { return List.of( - new MinionExpectations(-1, Block.IRON_ORE, Block.AIR) + new BlockExpectation(-1, Block.IRON_ORE, Block.AIR) ); } diff --git a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionLapis.java b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionLapis.java index 8cd331667..ee12b8575 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionLapis.java +++ b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionLapis.java @@ -67,11 +67,10 @@ public Color getChestplateColour() { return new Color(9, 82, 160); } - @Override - public List getExpectations() { + public List getExpectations() { return List.of( - new MinionExpectations(-1, Block.LAPIS_ORE, Block.AIR) + new BlockExpectation(-1, Block.LAPIS_ORE, Block.AIR) ); } diff --git a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionMithril.java b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionMithril.java index 82a04197b..9ecb5e584 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionMithril.java +++ b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionMithril.java @@ -68,9 +68,9 @@ public Color getChestplateColour() { } @Override - public List getExpectations() { + public List getExpectations() { return List.of( - new MinionExpectations(-1, Block.PRISMARINE, Block.AIR) + new BlockExpectation(-1, Block.PRISMARINE, Block.AIR) ); } diff --git a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionObsidian.java b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionObsidian.java index 3989a7c45..1c24f93e3 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionObsidian.java +++ b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionObsidian.java @@ -67,11 +67,10 @@ public Color getChestplateColour() { return new Color(59, 49, 86); } - @Override - public List getExpectations() { + public List getExpectations() { return List.of( - new MinionExpectations(-1, Block.OBSIDIAN, Block.AIR) + new BlockExpectation(-1, Block.OBSIDIAN, Block.AIR) ); } diff --git a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionQuartz.java b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionQuartz.java index df46994f7..86e31d39e 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionQuartz.java +++ b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionQuartz.java @@ -68,9 +68,9 @@ public Color getChestplateColour() { } @Override - public List getExpectations() { + public List getExpectations() { return List.of( - new MinionExpectations(-1, Block.NETHER_QUARTZ_ORE, Block.AIR) + new BlockExpectation(-1, Block.NETHER_QUARTZ_ORE, Block.AIR) ); } diff --git a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionRedstone.java b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionRedstone.java index 329510fc5..177bbc830 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionRedstone.java +++ b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionRedstone.java @@ -67,12 +67,10 @@ public Color getChestplateColour() { return new Color(219, 79, 15); } - - @Override - public List getExpectations() { + public List getExpectations() { return List.of( - new MinionExpectations(-1, Block.REDSTONE_ORE, Block.AIR) + new BlockExpectation(-1, Block.REDSTONE_ORE, Block.AIR) ); } diff --git a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionSand.java b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionSand.java index 6ac5fe53c..094f6c811 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionSand.java +++ b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionSand.java @@ -65,9 +65,9 @@ public Color getChestplateColour() { } @Override - public List getExpectations() { + public List getExpectations() { return List.of( - new MinionExpectations(-1, Block.SAND, Block.AIR) + new BlockExpectation(-1, Block.SAND, Block.AIR) ); } diff --git a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionSnow.java b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionSnow.java index e1260c744..0d93d1d20 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionSnow.java +++ b/type.generic/src/main/java/net/swofty/types/generic/minion/minions/mining/MinionSnow.java @@ -68,9 +68,9 @@ public Color getChestplateColour() { } @Override - public List getExpectations() { + public List getExpectations() { return List.of( - new MinionExpectations(-1, Block.SNOW_BLOCK, Block.AIR) + new BlockExpectation(-1, Block.SNOW_BLOCK, Block.AIR) ); } diff --git a/type.generic/src/main/java/net/swofty/types/generic/user/SkyBlockPlayer.java b/type.generic/src/main/java/net/swofty/types/generic/user/SkyBlockPlayer.java index 91eb3915e..8cc046e77 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/user/SkyBlockPlayer.java +++ b/type.generic/src/main/java/net/swofty/types/generic/user/SkyBlockPlayer.java @@ -397,7 +397,11 @@ public SkyBlockItem updateItem(PlayerItemOrigin origin, Consumer u public void addAndUpdateItem(@Nullable SkyBlockItem item) { if (item == null) return; if (item.isNA()) return; - ItemStack toAdd = PlayerItemUpdater.playerUpdate(this, item.getItemStack(), true).build(); + + ItemStack toAdd = PlayerItemUpdater.playerUpdate( + this, + item.getItemStack(), + true).build(); this.getInventory().addItemStack(toAdd); } diff --git a/type.generic/src/main/java/net/swofty/types/generic/user/SkyBlockScoreboard.java b/type.generic/src/main/java/net/swofty/types/generic/user/SkyBlockScoreboard.java index 44e0464e0..d1dd25401 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/user/SkyBlockScoreboard.java +++ b/type.generic/src/main/java/net/swofty/types/generic/user/SkyBlockScoreboard.java @@ -8,6 +8,7 @@ import net.swofty.types.generic.SkyBlockConst; import net.swofty.types.generic.SkyBlockGenericLoader; import net.swofty.types.generic.calendar.SkyBlockCalendar; +import net.swofty.types.generic.command.commands.MinionGenerationCommand; import net.swofty.types.generic.data.DataHandler; import net.swofty.types.generic.data.datapoints.DatapointDouble; import net.swofty.types.generic.data.datapoints.DatapointInteger; diff --git a/type.generic/src/main/java/net/swofty/types/generic/utility/DamageIndicator.java b/type.generic/src/main/java/net/swofty/types/generic/utility/DamageIndicator.java index 11b6bf191..d78e912a4 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/utility/DamageIndicator.java +++ b/type.generic/src/main/java/net/swofty/types/generic/utility/DamageIndicator.java @@ -43,10 +43,6 @@ public DamageIndicator pos(Pos pos) { return this; } - public DamageIndicator color(Color c) { - return this; - } - public DamageIndicator critical(boolean c) { this.crit = c; return this; diff --git a/type.generic/src/main/java/net/swofty/types/generic/utility/MathUtility.java b/type.generic/src/main/java/net/swofty/types/generic/utility/MathUtility.java index 156dd09fc..8a0781548 100644 --- a/type.generic/src/main/java/net/swofty/types/generic/utility/MathUtility.java +++ b/type.generic/src/main/java/net/swofty/types/generic/utility/MathUtility.java @@ -6,6 +6,7 @@ import net.minestom.server.instance.block.Block; import net.minestom.server.inventory.InventoryType; import net.minestom.server.timer.TaskSchedule; +import net.minestom.server.utils.Direction; import java.util.ArrayList; import java.util.List; @@ -19,6 +20,21 @@ public static String formatDecimals(double value) { return String.format("%.2f", value); } + public static boolean isWithinSameBlock(Pos pos1, Pos pos2) { + return pos1.blockX() == pos2.blockX() && pos1.blockY() == pos2.blockY() && pos1.blockZ() == pos2.blockZ(); + } + + public static Direction getDirectionFromPositions(Pos from, Pos to) { + double xDiff = to.x() - from.x(); + double zDiff = to.z() - from.z(); + + if (Math.abs(xDiff) > Math.abs(zDiff)) { + return xDiff > 0 ? Direction.EAST : Direction.WEST; + } else { + return zDiff > 0 ? Direction.SOUTH : Direction.NORTH; + } + } + public static InventoryType getFromSize(int size) { return switch (size) { case 9 -> InventoryType.CHEST_1_ROW; diff --git a/type.island/src/main/java/net/swofty/type/island/events/custom/ActionIslandLoadMinions.java b/type.island/src/main/java/net/swofty/type/island/events/custom/ActionIslandLoadMinions.java index ae1f09d83..76172f751 100644 --- a/type.island/src/main/java/net/swofty/type/island/events/custom/ActionIslandLoadMinions.java +++ b/type.island/src/main/java/net/swofty/type/island/events/custom/ActionIslandLoadMinions.java @@ -13,6 +13,7 @@ import net.swofty.types.generic.minion.extension.extensions.MinionFuelExtension; import org.bson.Document; +import java.util.List; import java.util.Map; public class ActionIslandLoadMinions implements SkyBlockEventClass { @@ -59,13 +60,13 @@ public void run(IslandFetchedFromDatabaseEvent event) { Thread.startVirtualThread(() -> { for (int i = 0; i < amountOfActions; i++) { MinionAction action = data.getMinion().asSkyBlockMinion().getAction(); - SkyBlockItem item = action.onAction( + List items = action.onAction( new MinionAction.MinionActionEvent(), data, event.getIsland().getIslandInstance()); - if (item != null) - MinionAction.onMinionIteration(data, data.getMinionEntity().getMinion(), item); + if (!items.isEmpty()) + MinionAction.onMinionIteration(data, data.getMinionEntity().getMinion(), items); } }); }