mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-23 21:38:00 +01:00
Added a way to obtain both the rain cloud and storm cloud jars
This commit is contained in:
parent
fc5b50a975
commit
52f62516fa
5 changed files with 132 additions and 1 deletions
|
@ -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);
|
||||
|
|
|
@ -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<Hit> {
|
||||
|
||||
@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<Hit> 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);
|
||||
}
|
||||
}
|
|
@ -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<Hit> {
|
||||
|
||||
|
|
|
@ -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",
|
||||
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 1.7 KiB |
Loading…
Reference in a new issue