diff --git a/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/event/actions/item/ActionItemAbilityBlockLeftUse.java b/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/event/actions/item/ActionItemAbilityBlockLeftUse.java index 418aac1a9..2b39efd9d 100644 --- a/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/event/actions/item/ActionItemAbilityBlockLeftUse.java +++ b/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/event/actions/item/ActionItemAbilityBlockLeftUse.java @@ -40,7 +40,9 @@ public void run(PlayerBlockBreakEvent event) { } abilityHandler.startAbilityCooldown(item); - ability.execute(player, item, event.getBlockPosition(), event.getBlockFace()); + if(ability.execute(player, item, event.getBlockPosition(), event.getBlockFace())){ + abilityHandler.startAbilityCooldown(item); + }; } } } diff --git a/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/event/actions/item/ActionItemAbilityBlockRightUse.java b/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/event/actions/item/ActionItemAbilityBlockRightUse.java index 651bd1f2c..fa9910c26 100644 --- a/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/event/actions/item/ActionItemAbilityBlockRightUse.java +++ b/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/event/actions/item/ActionItemAbilityBlockRightUse.java @@ -37,8 +37,9 @@ public void run(PlayerBlockInteractEvent event) { return; } - abilityHandler.startAbilityCooldown(item); - ability.execute(player, item, event.getBlockPosition(), event.getBlockFace()); + if(ability.execute(player, item, event.getBlockPosition(), event.getBlockFace())){ + abilityHandler.startAbilityCooldown(item); + } } } } 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 18b79ec4c..f73ae3f18 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 @@ -45,8 +45,9 @@ public void run(PlayerHandAnimationEvent event) { return; } - abilityHandler.startAbilityCooldown(item); - ability.execute(player, item); + if(ability.execute(player, item)){ + abilityHandler.startAbilityCooldown(item); + } } } } 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 ac8aa2bd7..a003cedc6 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 @@ -50,8 +50,9 @@ public void run(PlayerUseItemEvent event) { return; } - abilityHandler.startAbilityCooldown(item); - ability.execute(player, item); + if(ability.execute(player, item)){ + abilityHandler.startAbilityCooldown(item); + } } } } 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 d9f90230d..fa8ce993b 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 @@ -29,7 +29,10 @@ public class AbilityRegistry { 50, new RegisteredAbility.AbilityManaCost(25), (player, item, ignored, ignored2) -> { - player.teleport(player.getPosition().add(player.getPosition().direction().mul(10))); + BlockVec tpPos = player.getPosition().add(player.getPosition().direction().mul(10)).asBlockVec(); + if (!player.getInstance().getBlock(tpPos.add(0, 1, 0)).isAir() || !player.getInstance().getBlock(tpPos.add(0, 2, 0)).isAir()) return false; + player.teleport(new Pos(tpPos.add(0, 1, 0), player.getPosition().yaw(), player.getPosition().pitch())); + return true; // TODO: damage nearby mobs } )); @@ -42,10 +45,13 @@ public class AbilityRegistry { 5, new RegisteredAbility.AbilityManaCost(50), (player, item, ignored, ignored2) -> { - player.teleport(player.getPosition().add(player.getPosition().direction().mul(8))); + BlockVec tpPos = player.getPosition().add(player.getPosition().direction().mul(8)).asBlockVec(); + if (!player.getInstance().getBlock(tpPos.add(0, 1, 0)).isAir() || !player.getInstance().getBlock(tpPos.add(0, 2, 0)).isAir()) return false; // TODO: Make it so you can't go through walls + player.teleport(new Pos(tpPos.add(0, 1, 0), player.getPosition().yaw(), player.getPosition().pitch())); ItemStatistics speedStats = ItemStatistics.builder().withBase(ItemStatistic.SPEED, 50.0).build(); TemporaryStatistic speedBoost = TemporaryStatistic.builder().withStatistics(speedStats).withExpirationInMs(3000).withDisplayName("Instant Transmission").build(); player.getStatistics().boostStatistic(speedBoost); + return true; } )); @@ -58,10 +64,11 @@ public class AbilityRegistry { new RegisteredAbility.AbilityManaSoulflowCost(180, 1), (player, item, ignored, ignored2) -> { Point targetedBlock = player.getTargetBlockPosition(57); - if (targetedBlock == null) return; + if (targetedBlock == null) return false; 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 + if (!player.getInstance().getBlock(tpPos.add(0, 1, 0)).isAir() || !player.getInstance().getBlock(tpPos.add(0, 2, 0)).isAir()) return false; player.teleport(new Pos(tpPos.add(0, 1, 0), player.getPosition().yaw(), player.getPosition().pitch())); + return true; } )); @@ -75,6 +82,7 @@ public class AbilityRegistry { (player, item, targetedBlock, blockFace) -> { player.sendMessage(Component.text("§cThis Feature is not there yet. §aOpen a Pull request HERE to get it added quickly!") .clickEvent(ClickEvent.openUrl("https://github.com/Swofty-Developments/HypixelSkyBlock"))); + return false; } )); @@ -89,6 +97,7 @@ public class AbilityRegistry { ItemStatistics speedStats = ItemStatistics.builder().withBase(ItemStatistic.SPEED, 100.0).build(); TemporaryStatistic speedBoost = TemporaryStatistic.builder().withStatistics(speedStats).withExpirationInMs(30000).withDisplayName("Speed Boost").build(); player.getStatistics().boostStatistic(speedBoost); + return true; } )); @@ -121,12 +130,14 @@ public class AbilityRegistry { )) )); -// register(new RegisteredAbility( // TODO: Figure out how to implement passive abilities +// register(new RegisteredPassiveAbility( // "BEJEWELED_BLADE", // "Bejeweled Blade", // "§7Deals §a+150% §7damage to mobs on §bMining Islands.", -// RegisteredAbility.AbilityActivation. -// )) +// List.of(new RegisteredPassiveAbility.Action<>( +// +// )) +// )); register(new BuildersWandAbility()); } 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 3c3f6a2b3..f3cb5b08f 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 @@ -36,18 +36,20 @@ public RegisteredAbility(String id, String name, BiFunction> passiveAction; public RegisteredPassiveAbility(String id, String name, BiFunction description, List> action) { - super(id, name, description, AbilityActivation.NEVER, 0, new NoAbilityCost(), ((_, _, _, _) -> {})); + super(id, name, description, AbilityActivation.NEVER, 0, new NoAbilityCost(), ((_, _, _, _) -> { + return false; + })); this.passiveAction = action; } diff --git a/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/item/handlers/ability/abilities/BuildersWandAbility.java b/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/item/handlers/ability/abilities/BuildersWandAbility.java index 57f1a67f3..a59fce0b9 100644 --- a/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/item/handlers/ability/abilities/BuildersWandAbility.java +++ b/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/item/handlers/ability/abilities/BuildersWandAbility.java @@ -7,6 +7,7 @@ import net.minestom.server.instance.block.BlockFace; import net.minestom.server.item.Material; import net.swofty.commons.skyblock.item.ItemType; +import net.swofty.type.generic.HypixelConst; import net.swofty.type.skyblockgeneric.item.handlers.ability.RegisteredAbility; import net.swofty.type.skyblockgeneric.user.SkyBlockPlayer; @@ -20,11 +21,11 @@ public BuildersWandAbility() { (player, item) -> "Right-click the face of a block to extend all connected block faces.", AbilityActivation.RIGHT_CLICK_BLOCK, 0, new RegisteredAbility.NoAbilityCost(), (player, item, origin, face) -> { - fillConnectedFaces(player, new Pos(origin), face); + return fillConnectedFaces(player, new Pos(origin), face); }); } - private static void fillConnectedFaces(SkyBlockPlayer player, Pos origin, BlockFace face) { + private static boolean fillConnectedFaces(SkyBlockPlayer player, Pos origin, BlockFace face) { Material fillMaterial = Material.fromKey(player.getInstance().getBlock(origin).key()); int blocksInInventory = player.countItem(ItemType.fromMaterial(fillMaterial)); int blockLimit = 164; @@ -64,8 +65,7 @@ private static void fillConnectedFaces(SkyBlockPlayer player, Pos origin, BlockF } } Pos fillBlock = l.add(translate); - // TODO: make sure player is on island - if (player.isOnIsland()) { + if (HypixelConst.isIslandServer()) { blocks.removeIf(blocks.getFirst()::equals); if (!player.getInstance().getBlock(fillBlock).key().equals(fillMaterial.key())) { player.getInstance().setBlock(fillBlock, Block.fromKey(fillMaterial.key())); @@ -83,10 +83,10 @@ private static void fillConnectedFaces(SkyBlockPlayer player, Pos origin, BlockF } if (blocksPlaced == 0) { player.sendMessage("§cYou cannot place any blocks! You do not have enough blocks to place with your Builder's wand!"); + return false; } - if (blocksPlaced != 0) { - player.takeItem(ItemType.fromMaterial(fillMaterial), blocksPlaced); - player.sendMessage("&eYou built &a" + blocksPlaced + "&e blocks!"); - } + player.takeItem(ItemType.fromMaterial(fillMaterial), blocksPlaced); + player.sendMessage("&eYou built &a" + blocksPlaced + "&e blocks!"); + return true; } } diff --git a/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/item/handlers/interactable/InteractableRegistry.java b/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/item/handlers/interactable/InteractableRegistry.java index 96745274c..3033f4e21 100644 --- a/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/item/handlers/interactable/InteractableRegistry.java +++ b/type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/item/handlers/interactable/InteractableRegistry.java @@ -58,6 +58,7 @@ public class InteractableRegistry { ServerHolograms.addExternalHologram(hologram); jerryInformation.setHologram(hologram); + skyBlockItem.setAmount(0); }) ).build()); }