From 52f62516fa6f46b8d1c6b7b658532575ac9f2868 Mon Sep 17 00:00:00 2001 From: Sollace Date: Fri, 19 Feb 2021 18:10:49 +0200 Subject: [PATCH] Added a way to obtain both the rain cloud and storm cloud jars --- .../unicopia/ability/Abilities.java | 1 + .../ability/PegasusCaptureStormAbility.java | 124 ++++++++++++++++++ .../ability/PegasusRainboomAbility.java | 2 +- .../resources/assets/unicopia/lang/en_us.json | 6 + .../textures/gui/ability/capture_cloud.png | Bin 0 -> 1746 bytes 5 files changed, 132 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/minelittlepony/unicopia/ability/PegasusCaptureStormAbility.java create mode 100644 src/main/resources/assets/unicopia/textures/gui/ability/capture_cloud.png diff --git a/src/main/java/com/minelittlepony/unicopia/ability/Abilities.java b/src/main/java/com/minelittlepony/unicopia/ability/Abilities.java index e8c374f3..33458017 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/Abilities.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/Abilities.java @@ -26,6 +26,7 @@ public interface Abilities { // pegasus Ability RAINBOOM = register(new PegasusRainboomAbility(), "rainboom", AbilitySlot.PRIMARY); + Ability CAPTURE_CLOUD = register(new PegasusCaptureStormAbility(), "capture_cloud", AbilitySlot.SECONDARY); // pegasus / bat / alicorn / changeling Ability CARRY = register(new CarryAbility(), "carry", AbilitySlot.PASSIVE); diff --git a/src/main/java/com/minelittlepony/unicopia/ability/PegasusCaptureStormAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/PegasusCaptureStormAbility.java new file mode 100644 index 00000000..d265fcc3 --- /dev/null +++ b/src/main/java/com/minelittlepony/unicopia/ability/PegasusCaptureStormAbility.java @@ -0,0 +1,124 @@ +package com.minelittlepony.unicopia.ability; + +import javax.annotation.Nullable; + +import com.minelittlepony.unicopia.Race; +import com.minelittlepony.unicopia.ability.data.Hit; +import com.minelittlepony.unicopia.entity.player.Pony; +import com.minelittlepony.unicopia.item.UItems; +import com.minelittlepony.unicopia.particle.MagicParticleEffect; + +import net.minecraft.item.ItemStack; +import net.minecraft.network.packet.s2c.play.GameStateChangeS2CPacket; +import net.minecraft.server.world.ServerWorld; +import net.minecraft.text.TranslatableText; +import net.minecraft.util.Hand; +import net.minecraft.world.World; +import net.minecraft.world.level.ServerWorldProperties; + +/** + * Pegasus ability to capture a storm and store it in a jar + */ +public class PegasusCaptureStormAbility implements Ability { + + @Override + public int getWarmupTime(Pony player) { + return 9; + } + + @Override + public int getCooldownTime(Pony player) { + return 6; + } + + @Override + public boolean canUse(Race race) { + return race.canInteractWithClouds(); + } + + @Nullable + @Override + public Hit tryActivate(Pony player) { + + if (!player.getMaster().isCreative() && player.getMagicalReserves().getMana().getPercentFill() < 0.2F) { + return null; + } + + return Hit.INSTANCE; + } + + @Override + public Hit.Serializer getSerializer() { + return Hit.SERIALIZER; + } + + @Override + public double getCostEstimate(Pony player) { + return player.getMagicalReserves().getMana().getMax() * 0.9F; + } + + @Override + public void apply(Pony player, Hit data) { + + World w = player.getWorld(); + ItemStack stack = player.getMaster().getStackInHand(Hand.MAIN_HAND); + boolean thundering = w.isThundering(); + + if (stack.getItem() != UItems.EMPTY_JAR) { + tell(player, "ability.unicopia.empty_hooves"); + } else if (!w.isSkyVisible(player.getOrigin())) { + tell(player, "ability.unicopia.indoors"); + } else if (!(w.isRaining() || thundering)) { + tell(player, "ability.unicopia.clear_skies"); + } else if (player.getOrigin().getY() < 120) { + tell(player, "ability.unicopia.too_low"); + } else { + if (!player.getMaster().abilities.creativeMode) { + stack.decrement(1); + } + + if (thundering && w.random.nextBoolean()) { + player.getMaster().giveItemStack(UItems.STORM_CLOUD_JAR.getDefaultStack()); + + if (w instanceof ServerWorld) { + ServerWorldProperties props = (ServerWorldProperties)w.getLevelProperties(); + + int timer = (int)Math.floor(props.getRainTime() * 0.1); + + props.setThundering(timer > 0); + props.setClearWeatherTime((int)(w.random.nextFloat() * 150000)); + props.setThunderTime(timer); + ((ServerWorld)w).getServer().getPlayerManager().sendToDimension(new GameStateChangeS2CPacket(GameStateChangeS2CPacket.THUNDER_GRADIENT_CHANGED, w.getRainGradient(1)), w.getRegistryKey()); + } + } else { + player.getMaster().giveItemStack(UItems.RAIN_CLOUD_JAR.getDefaultStack()); + + if (w instanceof ServerWorld) { + ServerWorldProperties props = (ServerWorldProperties)w.getLevelProperties(); + + int timer = (int)Math.floor(props.getRainTime() * 0.1); + + props.setRaining(timer > 0); + props.setClearWeatherTime((int)(w.random.nextFloat() * 150000)); + props.setRainTime(timer); + ((ServerWorld)w).getServer().getPlayerManager().sendToDimension(new GameStateChangeS2CPacket(GameStateChangeS2CPacket.RAIN_GRADIENT_CHANGED, w.getRainGradient(1)), w.getRegistryKey()); + } + } + } + + } + + private void tell(Pony player, String translation) { + player.getMaster().sendMessage(new TranslatableText(translation), true); + } + + @Override + public void preApply(Pony player, AbilitySlot slot) { + player.getMagicalReserves().getExertion().add(6); + } + + @Override + public void postApply(Pony player, AbilitySlot slot) { + player.spawnParticles(MagicParticleEffect.UNICORN, 5); + } +} diff --git a/src/main/java/com/minelittlepony/unicopia/ability/PegasusRainboomAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/PegasusRainboomAbility.java index ddb5d907..be0bb655 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/PegasusRainboomAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/PegasusRainboomAbility.java @@ -13,7 +13,7 @@ import com.minelittlepony.unicopia.particle.UParticles; import net.minecraft.util.math.Vec3d; /** - * Changeling ability to restore health from mobs + * Pegasus ability to perform rainbooms */ public class PegasusRainboomAbility implements Ability { diff --git a/src/main/resources/assets/unicopia/lang/en_us.json b/src/main/resources/assets/unicopia/lang/en_us.json index 43a9e6a4..33087a1e 100644 --- a/src/main/resources/assets/unicopia/lang/en_us.json +++ b/src/main/resources/assets/unicopia/lang/en_us.json @@ -2,6 +2,11 @@ "block.unicopia.bed.not_safe": "You may not rest here, there are enemies nearby", + "ability.unicopia.empty_hooves": "I need to find a jar", + "ability.unicopia.indoors": "I can't see the sky from here", + "ability.unicopia.too_low": "I need to get higher up", + "ability.unicopia.clear_skies": "The skies already look pretty clear", + "itemGroup.unicopia.items": "Unicopia - Misc.", "itemGroup.unicopia.horsefeed": "Unicopia - Horse Feed", @@ -151,6 +156,7 @@ "ability.unicopia.hang": "Cling to Ceiling", "ability.unicopia.eee": "Deafening Screech", "ability.unicopia.feed": "Collect Love", + "ability.unicopia.capture_cloud": "Cloudbust", "ability.unicopia.disguise": "Shapeshift", "ability.unicopia.rainboom": "Sonic Rainboom", diff --git a/src/main/resources/assets/unicopia/textures/gui/ability/capture_cloud.png b/src/main/resources/assets/unicopia/textures/gui/ability/capture_cloud.png new file mode 100644 index 0000000000000000000000000000000000000000..9c0dd5a0bbd50be20ce56fc8804022c7f65b48bc GIT binary patch literal 1746 zcmV;@1}*uCP)PM-WTBiO3QHi!I05WL$O?iB2M9~BW1E>V ziL59QLgD}doEQ#f3mTT7Sojbj`7kFKq!o&z7-$;NA01;Vn_V~y85h?k{ zg%YJ5Lz_|x7ceNaF%&_t%9A^I?re@;3&4)2TPTwdR7}Tdd~cmN$?+XU6k-m((C#W$ zN|9%9^uvAR85D)!I)aiwErI5>9HTTCP2mdaRxnD?i|6%v)QC~kltQ%%bk;$|buukb zw)x3pb@FU!uT8<{W%sL%BCbKZ1G#{W4UqyHTiSC9M?#uJHvr&rO5=$IB5jGR=bjVS zxpOqC)ajgA-@7?zhMtEvIoFToB5RjJTC44{yREF?@G z*$f_b9qZto;m^k!XuYJY(-vC3Wb~uGD_oLBp3K9yUlD8yhdz|jTURIr4W)7A23Y`L zts(@_68OW@b)MQkEgYC$SUf)qz|V*Kludyw=EQI3x-2|?f1RMN=A?Z3E6`Q-cp`my0YM!xu_Z2w9_y?&`=`_`D(FO|G^mqkjodx#xd~l_jAS$tW-WZ?>OICxo_`aow0)#=pDAdr{q)PePs15C{10Ni_1x=J~~ z?ncyg3BZv@nxfK#TBP~jxq{;_&S69&V#w7R?YL6Dr{6MU4dcx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