Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
));
Expand All @@ -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;
}
));

Expand All @@ -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;
}
));

Expand All @@ -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;
}
));

Expand All @@ -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;
}
));

Expand Down Expand Up @@ -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());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,20 @@ public RegisteredAbility(String id, String name, BiFunction<SkyBlockPlayer, SkyB
this.action = action;
}

public void execute(SkyBlockPlayer player, SkyBlockItem item) {
execute(player, item, null, null);
public boolean execute(SkyBlockPlayer player, SkyBlockItem item) {
return execute(player, item, null, null);
}

public void execute(SkyBlockPlayer player, SkyBlockItem item, Point targetedBlock, BlockFace blockFace) {
public boolean execute(SkyBlockPlayer player, SkyBlockItem item, Point targetedBlock, BlockFace blockFace) {
if (!cost.canUse(player)) {
cost.onFail(player);
return;
return false;
}
if (!action.execute(player, item, targetedBlock, blockFace)){
return false;
}

cost.onUse(player, this);
action.execute(player, item, targetedBlock, blockFace);
return true;
}

@FunctionalInterface
Expand All @@ -57,7 +59,7 @@ public interface Description {

@FunctionalInterface
public interface AbilityAction {
void execute(SkyBlockPlayer player, SkyBlockItem item, Point targetedBlock, BlockFace blockFace);
boolean execute(SkyBlockPlayer player, SkyBlockItem item, Point targetedBlock, BlockFace blockFace);
}

@Getter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ public class RegisteredPassiveAbility extends RegisteredAbility {
private final List<Action<?>> passiveAction;

public RegisteredPassiveAbility(String id, String name, BiFunction<SkyBlockPlayer, SkyBlockItem, String> description, List<Action<?>> action) {
super(id, name, description, AbilityActivation.NEVER, 0, new NoAbilityCost(), ((_, _, _, _) -> {}));
super(id, name, description, AbilityActivation.NEVER, 0, new NoAbilityCost(), ((_, _, _, _) -> {
return false;
}));
this.passiveAction = action;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand Down Expand Up @@ -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()));
Expand All @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public class InteractableRegistry {

ServerHolograms.addExternalHologram(hologram);
jerryInformation.setHologram(hologram);
skyBlockItem.setAmount(0);
})
).build());
}
Expand Down