diff --git a/commons/src/main/java/net/swofty/commons/skyblock/item/ItemType.java b/commons/src/main/java/net/swofty/commons/skyblock/item/ItemType.java index d04fb46df..b5405fac8 100644 --- a/commons/src/main/java/net/swofty/commons/skyblock/item/ItemType.java +++ b/commons/src/main/java/net/swofty/commons/skyblock/item/ItemType.java @@ -34,6 +34,9 @@ public enum ItemType { NEW_YEAR_CAKE(Material.CAKE, Rarity.SPECIAL), NEW_YEAR_CAKE_BAG(Material.PLAYER_HEAD, Rarity.UNCOMMON), + RAW_SOULFLOW(Material.PLAYER_HEAD, Rarity.UNCOMMON), + SOULFLOW(Material.PLAYER_HEAD, Rarity.RARE), + /** * Accessories */ @@ -621,6 +624,8 @@ public enum ItemType { ASPECT_OF_THE_END(Material.DIAMOND_SWORD, Rarity.RARE), SQUIRE_SWORD(Material.IRON_SWORD, Rarity.UNCOMMON), MERCENARY_AXE(Material.IRON_AXE, Rarity.RARE), + ASPECT_OF_THE_DRAGON(Material.DIAMOND_SWORD, Rarity.LEGENDARY), + ASPECT_OF_THE_VOID(Material.DIAMOND_SHOVEL, Rarity.EPIC), /** * Shovels diff --git a/configuration/skyblock/items/miscellaneous/soulflow.yml b/configuration/skyblock/items/miscellaneous/soulflow.yml new file mode 100644 index 000000000..e9904b283 --- /dev/null +++ b/configuration/skyblock/items/miscellaneous/soulflow.yml @@ -0,0 +1,17 @@ +items: + - id: RAW_SOULFLOW + material: PLAYER_HEAD + rarity: UNCOMMON + components: + - id: SOULFLOW + amount: 1 + - id: SKULL_HEAD + texture: 84f0214329bb2575b8f4d7623376255d7ec4a439296e140ae9a2c6138a4270c1 + - id: SOULFLOW + material: PLAYER_HEAD + rarity: RARE + components: + - id: SOULFLOW + amount: 160 + - id: SKULL_HEAD + texture: bc85e2fdf9b1b020ac2827d11ae00d90f81c5c6bd361cbd1c8b8e9087757e4b0 \ No newline at end of file diff --git a/configuration/skyblock/items/weapons.yml b/configuration/skyblock/items/weapons.yml index 4a7368e4a..1822db943 100644 --- a/configuration/skyblock/items/weapons.yml +++ b/configuration/skyblock/items/weapons.yml @@ -46,6 +46,25 @@ items: type: ASPECT_OF_THE_JERRY amount: 1 + - id: ASPECT_OF_THE_DRAGON + material: DIAMOND_SWORD + rarity: LEGENDARY + abilities: + - DRAGON_RAGE + default_statistics: + damage: 225 + strength: 100 + components: + - id: ABILITY + abilities: + - DRAGON_RAGE + - id: SELLABLE + value: 100000 + - id: STANDARD_ITEM + standard_item_type: SWORD + - id: CUSTOM_DISPLAY_NAME + display_name: "Aspect of the Dragons" + - id: END_SWORD material: IRON_SWORD rarity: UNCOMMON @@ -58,6 +77,25 @@ items: - id: STANDARD_ITEM standard_item_type: SWORD + - id: ASPECT_OF_THE_VOID + material: DIAMOND_SHOVEL + rarity: EPIC + default_statistics: + damage: 120 + strength: 100 + abilities: + - INSTANT_TRANSMISSION + - ETHER_TRANSMISSION + components: + - id: ABILITY + abilities: + - INSTANT_TRANSMISSION + - ETHER_TRANSMISSION + - id: STANDARD_ITEM + standard_item_type: SWORD + - id: CUSTOM_DISPLAY_NAME + display_name: "Aspect of the Void" + - id: FANCY_SWORD material: GOLDEN_SWORD rarity: UNCOMMON diff --git a/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/data/SkyBlockDataHandler.java b/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/data/SkyBlockDataHandler.java index f969f681a..0d96d666f 100644 --- a/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/data/SkyBlockDataHandler.java +++ b/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/data/SkyBlockDataHandler.java @@ -434,6 +434,9 @@ DatapointInteger.class, new DatapointInteger("latest_new_year_cake_year", 0)), LATEST_YEAR_PRESENT_PICKUP("latest_year_pickup_present", false, false, false, DatapointPresentYear.class, new DatapointPresentYear("latest_year_pickup_present")), + SOULFLOW("soulflow", false, false, false, + DatapointInteger.class, new DatapointInteger("soulflow", 0)), + KAT("kat", false, false, false, DatapointKat.class, new DatapointKat("kat")), diff --git a/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/event/actions/item/ActionItemAbilityLeftUse.java b/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/event/actions/item/ActionItemAbilityLeftUse.java index 67a5ecb73..f5792a917 100644 --- a/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/event/actions/item/ActionItemAbilityLeftUse.java +++ b/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/event/actions/item/ActionItemAbilityLeftUse.java @@ -23,7 +23,15 @@ public void run(PlayerHandAnimationEvent event) { if (item.hasComponent(AbilityComponent.class)) { AbilityComponent abilityComponent = item.getComponent(AbilityComponent.class); - RegisteredAbility ability = abilityComponent.getAbility(RegisteredAbility.AbilityActivation.LEFT_CLICK); + + RegisteredAbility ability = null; + if(player.isSneaking()) { + ability = abilityComponent.getAbility(RegisteredAbility.AbilityActivation.SNEAK_LEFT_CLICK); + } + if (ability == null) { + abilityComponent.getAbility(RegisteredAbility.AbilityActivation.LEFT_CLICK); + } + if (ability != null) { if (!ability.getCost().canUse(player)) { ability.getCost().onFail(player); diff --git a/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/event/actions/item/ActionItemAbilityRightUse.java b/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/event/actions/item/ActionItemAbilityRightUse.java index fb999b748..c7d85b263 100644 --- a/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/event/actions/item/ActionItemAbilityRightUse.java +++ b/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/event/actions/item/ActionItemAbilityRightUse.java @@ -28,7 +28,15 @@ public void run(PlayerUseItemEvent event) { if (item.hasComponent(AbilityComponent.class)) { AbilityComponent abilityComponent = item.getComponent(AbilityComponent.class); - RegisteredAbility ability = abilityComponent.getAbility(RegisteredAbility.AbilityActivation.RIGHT_CLICK); + + RegisteredAbility ability = null; + if(player.isSneaking()) { + ability = abilityComponent.getAbility(RegisteredAbility.AbilityActivation.SNEAK_RIGHT_CLICK); + } + if (ability == null) { + abilityComponent.getAbility(RegisteredAbility.AbilityActivation.RIGHT_CLICK); + } + if (ability != null) { if (!ability.getCost().canUse(player)) { ability.getCost().onFail(player); diff --git a/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/gui/inventories/GUIConsumeSoulflow.java b/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/gui/inventories/GUIConsumeSoulflow.java new file mode 100644 index 000000000..b37c379a4 --- /dev/null +++ b/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/gui/inventories/GUIConsumeSoulflow.java @@ -0,0 +1,86 @@ +package net.swofty.type.skyblockgeneric.gui.inventories; + +import net.minestom.server.event.inventory.InventoryPreClickEvent; +import net.minestom.server.inventory.InventoryType; +import net.minestom.server.item.ItemStack; +import net.swofty.type.generic.data.datapoints.DatapointInteger; +import net.swofty.type.generic.gui.inventory.HypixelInventoryGUI; +import net.swofty.type.generic.gui.inventory.ItemStackCreator; +import net.swofty.type.generic.gui.inventory.item.GUIClickableItem; +import net.swofty.type.generic.user.HypixelPlayer; +import net.swofty.type.skyblockgeneric.data.SkyBlockDataHandler; +import net.swofty.type.skyblockgeneric.item.SkyBlockItem; +import net.swofty.type.skyblockgeneric.item.components.SoulflowComponent; +import net.swofty.type.skyblockgeneric.user.SkyBlockPlayer; + +public class GUIConsumeSoulflow extends HypixelInventoryGUI { + + private final SkyBlockItem item; + + public GUIConsumeSoulflow(SkyBlockItem item) { + super("Consume Soulflow?", InventoryType.CHEST_4_ROW); + this.item = item; + + if (!item.hasComponent(SoulflowComponent.class)) { + throw new IllegalArgumentException("Item does not have SoulflowComponent"); + } + } + + @Override + public void onOpen(InventoryGUIOpenEvent e) { + fill(FILLER_ITEM); + set(new GUIClickableItem(13) { + @Override + public void run(InventoryPreClickEvent e, HypixelPlayer p) { + SkyBlockPlayer player = (SkyBlockPlayer) p; + SkyBlockDataHandler data = player.getSkyblockDataHandler(); + int soulflow = data.get(SkyBlockDataHandler.Data.SOULFLOW, DatapointInteger.class).getValue(); + int itemSoulflow = item.getComponent(SoulflowComponent.class).getAmount(); + int addition = item.getAmount() * itemSoulflow; + + data.get(SkyBlockDataHandler.Data.SOULFLOW, DatapointInteger.class).setValue(soulflow + addition); + player.sendMessage("§bYou internalized §3+" + addition + "⸎ Soulflow §band have a total of §3" + (soulflow + addition) + "⸎§b!"); + + player.getInventory().setItemStack(player.getHeldSlot(), ItemStack.AIR); + player.closeInventory(); + } + + @Override + public ItemStack.Builder getItem(HypixelPlayer p) { + SkyBlockPlayer player = (SkyBlockPlayer) p; + SkyBlockDataHandler data = player.getSkyblockDataHandler(); + int soulflow = data.get(SkyBlockDataHandler.Data.SOULFLOW, DatapointInteger.class).getValue(); + + int itemSoulflow = item.getComponent(SoulflowComponent.class).getAmount(); + int addition = item.getAmount() * itemSoulflow; + + return ItemStackCreator.getStackHead( + "§aConsume Soulflow?", + "94f0c693b85658b0bae792c9f9b717eb024ab8c4b349455648ea08358b50ddc4", + 1, + "§7Takes all the §3⸎ Soulflow §7items in", + "§7your inventory and internalizes them", + "§7to be ready for use.", + "", + "§7Internalized: §3" + soulflow + "⸎", + "", + "§7Adding from inventory: §3+" + addition + "⸎ Soulflow", + "", + "§eClick to consume!" + ); + } + }); + set(GUIClickableItem.getCloseItem(31)); + updateItemStacks(getInventory(), getPlayer()); + } + + @Override + public boolean allowHotkeying() { + return false; + } + + @Override + public void onBottomClick(InventoryPreClickEvent e) { + e.setCancelled(true); + } +} diff --git a/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/item/ItemConfigParser.java b/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/item/ItemConfigParser.java index 91ffbb382..5a96e7b13 100644 --- a/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/item/ItemConfigParser.java +++ b/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/item/ItemConfigParser.java @@ -119,6 +119,10 @@ public static ConfigurableSkyBlockItem parseItem(Map config) { List animations = (List) config.get("disabled_animations"); yield new DisableAnimationComponent(animations); } + case "SOULFLOW" -> { + int amount = (int) config.get("amount"); + yield new SoulflowComponent(amount); + } case "DRILL" -> new DrillComponent(); case "ABIPHONE" -> { List features = (List) config.get("features"); diff --git a/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/item/components/SoulflowComponent.java b/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/item/components/SoulflowComponent.java new file mode 100644 index 000000000..3af078377 --- /dev/null +++ b/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/item/components/SoulflowComponent.java @@ -0,0 +1,29 @@ +package net.swofty.type.skyblockgeneric.item.components; + +import lombok.Getter; +import net.swofty.type.skyblockgeneric.gui.inventories.GUIConsumeSoulflow; +import net.swofty.type.skyblockgeneric.item.SkyBlockItemComponent; + +import java.util.List; + +public class SoulflowComponent extends SkyBlockItemComponent { + + @Getter + private final int amount; + + public SoulflowComponent(int amount) { + addInheritedComponent(new LoreUpdateComponent( + List.of( + "§7Hold and right-click to consume,", + "§7gaining §3+" + amount + "⸎ Soulflow§7." + ), false + )); + addInheritedComponent( + new InteractableComponent((player, item) -> { + new GUIConsumeSoulflow(item).open(player); + }, null, null) + ); + this.amount = amount; + } + +} diff --git a/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/item/handlers/ability/AbilityRegistry.java b/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/item/handlers/ability/AbilityRegistry.java index 6b70ddad8..f3de83e00 100644 --- a/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/item/handlers/ability/AbilityRegistry.java +++ b/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/item/handlers/ability/AbilityRegistry.java @@ -1,5 +1,8 @@ package net.swofty.type.skyblockgeneric.item.handlers.ability; +import net.minestom.server.coordinate.BlockVec; +import net.minestom.server.coordinate.Point; +import net.minestom.server.coordinate.Pos; import net.swofty.type.skyblockgeneric.item.handlers.ability.abilities.BuildersWandAbility; import java.util.HashMap; @@ -24,13 +27,29 @@ public class AbilityRegistry { register(new RegisteredAbility( "INSTANT_TRANSMISSION", "Instant Transmission", - "§7Teleports §a8 Blocks §7ahead of you and gain §a+50 §fSpeed for §a3 seconds§f.", + "§7Teleports §a8 Blocks §7ahead of you and gain §a+50 §fSpeed for §a3 seconds§7.", RegisteredAbility.AbilityActivation.RIGHT_CLICK, 5, new RegisteredAbility.AbilityManaCost(50), (player, item, ignored, ignored2) -> { player.teleport(player.getPosition().add(player.getPosition().direction().mul(8))); - // add speed too + // TODO: add speed too + } + )); + + register(new RegisteredAbility( + "ETHER_TRANSMISSION", + "Ether Transmission", + "§7Teleport to your targeted block up to §a57 §7blocks away.", + RegisteredAbility.AbilityActivation.SNEAK_RIGHT_CLICK, + 5, + new RegisteredAbility.AbilityManaSoulflowCost(180, 1), + (player, item, ignored, ignored2) -> { + Point targetedBlock = player.getTargetBlockPosition(57); + if (targetedBlock == null) return; + BlockVec tpPos = targetedBlock.asBlockVec(); + if (!player.getInstance().getBlock(tpPos.add(0, 1, 0)).isAir() || !player.getInstance().getBlock(tpPos.add(0, 2, 0)).isAir()) return; // TODO: don't consume mana/soulflow if teleport fails + player.teleport(new Pos(tpPos.add(0, 1, 0), player.getPosition().yaw(), player.getPosition().pitch())); } )); diff --git a/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/item/handlers/ability/RegisteredAbility.java b/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/item/handlers/ability/RegisteredAbility.java index 5bcadbdff..ee01ca65a 100644 --- a/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/item/handlers/ability/RegisteredAbility.java +++ b/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/item/handlers/ability/RegisteredAbility.java @@ -4,6 +4,8 @@ import lombok.NonNull; import net.minestom.server.coordinate.Point; import net.minestom.server.instance.block.BlockFace; +import net.swofty.type.generic.data.datapoints.DatapointInteger; +import net.swofty.type.skyblockgeneric.data.SkyBlockDataHandler; import net.swofty.type.skyblockgeneric.item.SkyBlockItem; import net.swofty.type.skyblockgeneric.user.SkyBlockActionBar; import net.swofty.type.skyblockgeneric.user.SkyBlockPlayer; @@ -57,6 +59,8 @@ public enum AbilityActivation { LEFT_CLICK("LEFT CLICK"), LEFT_CLICK_BLOCK("LEFT CLICK"), RIGHT_CLICK_BLOCK("RIGHT CLICK"), + SNEAK_RIGHT_CLICK("SNEAK RIGHT CLICK"), + SNEAK_LEFT_CLICK("SNEAK LEFT CLICK") ; private final @NonNull String display; @@ -116,6 +120,65 @@ public String getLoreDisplay() { } } + public static class AbilityManaSoulflowCost extends AbilityCost { + private final int cost; + private final int soulflow; + + public AbilityManaSoulflowCost(int cost, int soulflow) { + this.cost = cost; + this.soulflow = soulflow; + } + + @Override + public boolean canUse(@NotNull SkyBlockPlayer player) { + return (player.getMana() >= cost) && (player.getSkyblockDataHandler().get(SkyBlockDataHandler.Data.SOULFLOW, DatapointInteger.class).getValue() >= soulflow); + } + + @Override + public void onUse(@NonNull SkyBlockPlayer player, @NonNull RegisteredAbility ability) { + SkyBlockActionBar.getFor(player).addReplacement( + SkyBlockActionBar.BarSection.MANA, + new SkyBlockActionBar.DisplayReplacement( + "§b-" + cost + " (§6" + ability.getName() + "§b)", + 20, + 2 + ) + ); + player.setMana(player.getMana() - cost); + player.getSkyblockDataHandler().get(SkyBlockDataHandler.Data.SOULFLOW, DatapointInteger.class).setValue( + player.getSkyblockDataHandler().get(SkyBlockDataHandler.Data.SOULFLOW, DatapointInteger.class).getValue() - soulflow + ); + } + + @Override + public void onFail(@NonNull SkyBlockPlayer player) { + if (player.getSkyblockDataHandler().get(SkyBlockDataHandler.Data.SOULFLOW, DatapointInteger.class).getValue() < soulflow) { + SkyBlockActionBar.getFor(player).addReplacement( + SkyBlockActionBar.BarSection.MANA, + new SkyBlockActionBar.DisplayReplacement( + "§c§lNOT ENOUGH SOULFLOW", + 20 * 2, + 2 + ) + ); + return; + } + SkyBlockActionBar.getFor(player).addReplacement( + SkyBlockActionBar.BarSection.MANA, + new SkyBlockActionBar.DisplayReplacement( + "§c§lNOT ENOUGH MANA", + 20 * 2, + 2 + ) + ); + } + + @Override + public String getLoreDisplay() { + return "§8Soulflow Cost: §3" + soulflow + "\n§8Mana Cost: §3" + cost; + } + } + public static class NoAbilityCost extends AbilityCost { @Override public boolean canUse(@NotNull SkyBlockPlayer player) {