Implement Mary Poppin's Umbrella cosmetic

This commit is contained in:
Sam 2018-03-28 17:02:28 +01:00 committed by Alexander Meech
parent f2bdbe9cb2
commit 49d738dd98
4 changed files with 136 additions and 0 deletions

View File

@ -1125,4 +1125,9 @@ public class UtilEnt
return null;
}
}
public static void setPosition(Entity entity, Location location)
{
((CraftEntity) entity).getHandle().setPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
}
}

View File

@ -146,6 +146,7 @@ import mineplex.core.gadget.gadgets.item.ItemFleshHook;
import mineplex.core.gadget.gadgets.item.ItemFlowerGift;
import mineplex.core.gadget.gadgets.item.ItemFreezeCannon;
import mineplex.core.gadget.gadgets.item.ItemLovePotion;
import mineplex.core.gadget.gadgets.item.ItemMaryPoppins;
import mineplex.core.gadget.gadgets.item.ItemMelonLauncher;
import mineplex.core.gadget.gadgets.item.ItemMobBomb;
import mineplex.core.gadget.gadgets.item.ItemOAndX;
@ -560,6 +561,7 @@ public class GadgetManager extends MiniPlugin
addGadget(new ItemBallCatch(this));
addGadget(new ItemTrampoline(this));
addGadget(new ItemConnect4(this));
addGadget(new ItemMaryPoppins(this));
// Costume
addGadget(new OutfitRaveSuitHelmet(this));

View File

@ -0,0 +1,128 @@
package mineplex.core.gadget.gadgets.item;
import java.awt.*;
import java.util.concurrent.TimeUnit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Chicken;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.particles.ColoredParticle;
import mineplex.core.common.util.particles.DustSpellColor;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.types.ItemGadget;
import mineplex.core.gadget.util.CostConstants;
public class ItemMaryPoppins extends ItemGadget
{
private static final DustSpellColor TOP = new DustSpellColor(Color.BLACK), BOTTOM = new DustSpellColor(new Color(90, 50, 31));
public ItemMaryPoppins(GadgetManager manager)
{
super(manager, "Umbrella", new String[]
{
}, CostConstants.POWERPLAY_BONUS, Material.STICK, (byte) 0, TimeUnit.SECONDS.toMillis(20), null);
}
@Override
public void ActivateCustom(Player player)
{
Location location = player.getLocation().add(0, 0.5, 0);
UtilAction.velocity(player, new Vector(0, 3, 0));
UtilParticle.PlayParticleToAll(ParticleType.CLOUD, location, 0.5F, 0, 0.5F, 0, 10, ViewDist.NORMAL);
location.getWorld().playSound(location, Sound.BAT_TAKEOFF, 1, 0.6F);
Manager.runSyncTimer(new BukkitRunnable()
{
Chicken chicken;
int iterations = 0;
@Override
public void run()
{
if (iterations == 0)
{
if (UtilEnt.isGrounded(player))
{
cancel();
}
else
{
Location location = player.getLocation();
chicken = player.getWorld().spawn(location, Chicken.class);
chicken.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 0, false, false));
chicken.setPassenger(player);
UtilEnt.vegetate(chicken, true);
UtilEnt.ghost(chicken, true, false);
iterations++;
}
return;
}
Location location = player.getLocation().add(0, 0.9, 0);
location.setPitch(0);
UtilEnt.setPosition(chicken, chicken.getLocation().add(location.getDirection().multiply(0.2)));
if (iterations % 4 == 0)
{
displayUmbrella(location.add(UtilAlg.getRight(location.getDirection()).multiply(0.5)));
}
if (chicken.getPassenger() == null || UtilEnt.isGrounded(chicken))
{
chicken.eject();
chicken.remove();
cancel();
}
iterations++;
}
}, 20, 1);
}
private void displayUmbrella(Location location)
{
for (double y = 0; y < 1.5; y += 0.1)
{
new ColoredParticle(ParticleType.RED_DUST, BOTTOM, location.clone().add(0, y, 0))
.display();
}
location.add(0, 1.5, 0);
double deltaY = 0;
for (double r = 0.1; r < 1; r += 0.2)
{
for (double theta = 0; theta < 2 * Math.PI; theta += Math.PI / 10)
{
double x = r * Math.cos(theta), z = r * Math.sin(theta);
location.add(x, deltaY, z);
new ColoredParticle(ParticleType.RED_DUST, TOP, location)
.display();
location.subtract(x, deltaY, z);
}
deltaY -= 0.04;
}
}
}

View File

@ -48,6 +48,7 @@ public class PowerPlayClubRewards
.put(YearMonth.of(2018, Month.JANUARY), new UnknownSalesPackageItem("Mob Bomb"))
.put(YearMonth.of(2018, Month.FEBRUARY), new UnknownSalesPackageItem("Play Catch"))
.put(YearMonth.of(2018, Month.MARCH), new UnknownSalesPackageItem("Connect 4"))
.put(YearMonth.of(2018, Month.APRIL), new UnknownSalesPackageItem("Umbrella"))
.build();
public interface PowerPlayClubItem