push so i can pull :\?

This commit is contained in:
Chiss 2013-12-18 21:17:28 +11:00
parent 54f2cb3467
commit f4edcedce3
4 changed files with 581 additions and 66 deletions

View File

@ -1,13 +1,36 @@
package nautilus.game.arcade.game.games.christmas;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.HandlerList;
import org.bukkit.event.entity.EntityCombustEvent;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import mineplex.core.common.util.C;
import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.SoloGame;
import nautilus.game.arcade.game.games.christmas.parts.*;
import nautilus.game.arcade.game.games.stacker.kits.*;
import nautilus.game.arcade.kit.Kit;
@ -15,6 +38,14 @@ public class Christmas extends SoloGame
{
private Sleigh _sleigh;
private Location _sleighSpawn;
private ArrayList<Part> _parts = new ArrayList<Part>();
private Part _part;
private ArrayList<Location> _barrier = new ArrayList<Location>();
public Christmas(ArcadeManager manager)
{
super(manager, GameType.Christmas,
@ -28,36 +59,330 @@ public class Christmas extends SoloGame
{
});
this.BlockBreakAllow.add(4);
this.HungerSet = 20;
}
@EventHandler
public void Update(UpdateEvent event)
@Override
public void ParseData()
{
if (event.getType() != UpdateType.TICK)
//Sleigh Spawn
_sleighSpawn = WorldData.GetDataLocs("RED").get(0);
//Sleigh Waypoints
ArrayList<Location> _sleighWaypoints = new ArrayList<Location>();
while (!WorldData.GetDataLocs("PINK").isEmpty())
{
Location bestLoc = null;
double bestDist = 0;
for (Location loc : WorldData.GetDataLocs("PINK"))
{
double dist = UtilMath.offset(loc, _sleighSpawn);
if (bestLoc == null || bestDist > dist)
{
bestLoc = loc;
bestDist = dist;
}
}
_sleighWaypoints.add(bestLoc);
WorldData.GetDataLocs("PINK").remove(bestLoc);
}
//Presents
ArrayList<Location> _presents = new ArrayList<Location>();
while (!WorldData.GetDataLocs("LIME").isEmpty())
{
Location bestLoc = null;
double bestDist = 0;
for (Location loc : WorldData.GetDataLocs("LIME"))
{
double dist = UtilMath.offset(loc, _sleighSpawn);
if (bestLoc == null || bestDist > dist)
{
bestLoc = loc;
bestDist = dist;
}
}
_presents.add(bestLoc);
WorldData.GetDataLocs("LIME").remove(bestLoc);
}
//Barriers
for (Location loc : WorldData.GetCustomLocs("129"))
{
_barrier.add(loc.getBlock().getLocation());
MapUtil.QuickChangeBlockAt(loc, 20, (byte)0);
}
//Parts
_parts.add(new Part1(this, _sleighWaypoints.remove(0), new Location[] {_presents.remove(0), _presents.remove(0)},
WorldData.GetDataLocs("BLACK"),
WorldData.GetDataLocs("ORANGE"),
WorldData.GetCustomLocs("19"),
WorldData.GetCustomLocs("47")));
_parts.add(new Part2(this, _sleighWaypoints.remove(0), new Location[] {_presents.remove(0), _presents.remove(0)},
WorldData.GetDataLocs("YELLOW"),
WorldData.GetDataLocs("BROWN"),
WorldData.GetDataLocs("PURPLE"),
WorldData.GetCustomLocs("48")));
_parts.add(new Part3(this, _sleighWaypoints.remove(0), new Location[] {_presents.remove(0), _presents.remove(0)},
WorldData.GetDataLocs("SILVER"),
WorldData.GetDataLocs("GRAY"),
WorldData.GetDataLocs("WHITE"),
WorldData.GetCustomLocs("113")));
_parts.add(new Part4(this, _sleighWaypoints.remove(0), new Location[] {_presents.remove(0), _presents.remove(0)}));
_parts.add(new Part5(this, _sleighWaypoints.remove(0), new Location[] {_presents.remove(0), _presents.remove(0)}));
_parts.add(new Part6(this, _sleighWaypoints.remove(0), new Location[] {_presents.remove(0), _presents.remove(0)},
WorldData.GetCustomLocs("14"),
WorldData.GetCustomLocs("15"),
WorldData.GetCustomLocs("16"),
WorldData.GetCustomLocs("87"),
WorldData.GetCustomLocs("88"),
WorldData.GetCustomLocs("89"),
WorldData.GetCustomLocs("153")));
}
@EventHandler(priority = EventPriority.MONITOR)
public void TeamGen(GameStateChangeEvent event)
{
if (event.GetState() != GameState.Live)
return;
GetTeamList().add(new GameTeam("Christmas Thieves", ChatColor.RED, WorldData.GetDataLocs("RED")));
}
@EventHandler
public void PartUpdate(UpdateEvent event)
{
if (!IsLive())
return;
if (_sleigh == null)
return;
if (event.getType() == UpdateType.SEC)
{
if ((_part == null || _part.IsDone()) && _parts != null && !_parts.isEmpty())
{
_part = _parts.remove(0);
_sleigh.Update();
_part.Prepare();
//Register Updates
UtilServer.getServer().getPluginManager().registerEvents(_part, Manager.GetPlugin());
GetSleigh().SetTarget(_part.GetSleighWaypoint());
}
}
}
public Sleigh GetSleigh()
{
if (_sleigh == null)
_sleigh = new Sleigh(this, _sleighSpawn);
return _sleigh;
}
@EventHandler
public void Test(PlayerCommandPreprocessEvent event)
public void SleighSpawn(GameStateChangeEvent event)
{
if (event.getMessage().equalsIgnoreCase("/sleigh spawn"))
if (event.GetState() != GameState.Live)
return;
GetSleigh();
}
@EventHandler
public void SleighUpdate(UpdateEvent event)
{
if (!IsLive())
return;
if (event.getType() == UpdateType.TICK)
GetSleigh().Update();
}
@EventHandler
public void BarrierDecay(UpdateEvent event)
{
if (!IsLive())
return;
if (event.getType() != UpdateType.SEC)
return;
Location breakAt = null;
for (Location loc : _barrier)
{
_sleigh = new Sleigh(this, event.getPlayer().getLocation().add(5, 0, 5));
event.setCancelled(true);
if (UtilMath.offset(GetSleigh().GetLocation(), loc) > 15)
continue;
breakAt = loc;
}
if (event.getMessage().equalsIgnoreCase("/sleigh here"))
if (breakAt != null)
BarrierBreak(breakAt);
}
private void BarrierBreak(Location loc)
{
_barrier.remove(loc);
loc.getBlock().setType(Material.AIR);
for (Block block : UtilBlock.getSurrounding(loc.getBlock(), false))
{
_sleigh.SetTarget(event.getPlayer().getLocation());
event.setCancelled(true);
if (_barrier.remove(block.getLocation()))
{
BarrierBreak(block.getLocation());
}
}
}
public void SantaSay(String string)
{
Announce(C.cRed + C.Bold + "Santa: " + ChatColor.RESET + string);
}
@EventHandler
public void Combust(EntityCombustEvent event)
{
event.setCancelled(true);
}
@EventHandler
public void ItemSpawn(ItemSpawnEvent event)
{
event.setCancelled(true);
}
@Override
public void EndCheck()
{
if (!IsLive())
return;
if (_parts.isEmpty() && _part.IsDone())
{
for (Player player : GetPlayers(false))
{
Manager.GetDonation().PurchaseUnknownSalesPackage(null, player.getName(), "Frosty Pumpkin Kings Head", 0, true);
Manager.GetGame().AddGems(player, 30, "Slaying the Pumpkin King", false);
Manager.GetGame().AddGems(player, 10, "Participation", false);
}
FileWriter fstream = null;
BufferedWriter out = null;
try
{
fstream = new FileWriter("ChristmasHelmets.dat", true);
out = new BufferedWriter(fstream);
for (Player player : GetPlayers(false))
{
out.write(UtilTime.now() + "\t\t" + player.getName());
out.newLine();
}
out.close();
}
catch (Exception e)
{
System.err.println("Christmas Helmet Save: " + e.getMessage());
}
finally
{
if (out != null)
{
try
{
out.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
if (fstream != null)
{
try
{
fstream.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
SetState(GameState.End);
SetCustomWinLine("You earned Frosty Pumpkin Kings Head!");
AnnounceEnd(this.GetTeamList().get(0));
}
else if (GetPlayers(true).size() == 0)
{
for (Player player : GetPlayers(false))
{
Manager.GetGame().AddGems(player, 10, "Participation", false);
}
SetState(GameState.End);
SetCustomWinLine("You lost...");
AnnounceEnd(this.GetTeamList().get(1));
}
}
@EventHandler
public void Skip(PlayerCommandPreprocessEvent event)
{
if (event.getMessage().equals("/skip"))
if (event.getPlayer().getName().equals("Chiss"))
{
event.setCancelled(true);
if (_part != null)
HandlerList.unregisterAll(_part);
if (_parts != null && !_parts.isEmpty())
{
_part = _parts.remove(0);
_part.Prepare();
//Register Updates
UtilServer.getServer().getPluginManager().registerEvents(_part, Manager.GetPlugin());
GetSleigh().SetTarget(_part.GetSleighWaypoint());
//XXX REMOVE
for (Player player : UtilServer.getPlayers())
player.teleport(_part.GetSleighWaypoint());
}
}
if (event.getMessage().equals("/present"))
if (event.getPlayer().getName().equals("Chiss"))
{
event.setCancelled(true);
GetSleigh().AddPresent(event.getPlayer().getLocation());
}
}
}

View File

@ -2,16 +2,24 @@ package nautilus.game.arcade.game.games.christmas;
import java.util.ArrayList;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilMath;
import net.minecraft.server.v1_6_R3.EntityCreature;
import mineplex.core.recharge.Recharge;
import org.bukkit.Color;
import org.bukkit.Effect;
import org.bukkit.FireworkEffect;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftCreature;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftFallingSand;
import org.bukkit.Material;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.entity.Chicken;
import org.bukkit.entity.Entity;
import org.bukkit.entity.FallingBlock;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
public class Sleigh
{
@ -22,6 +30,10 @@ public class Sleigh
private ArrayList<SleighPart> SleighEnts;
private ArrayList<SleighHorse> SleighHorses;
private ArrayList<SleighPart> PresentSlots;
private ArrayList<Location> PresentsCollected = new ArrayList<Location>();;
private Location Target;
public Sleigh(Christmas host, Location loc)
@ -34,50 +46,84 @@ public class Sleigh
CentralEntity = loc.getWorld().spawn(loc, Chicken.class);
UtilEnt.Vegetate(CentralEntity);
UtilEnt.ghost(CentralEntity, true);
//Presents
PresentSlots = new ArrayList<SleighPart>();
PresentSlots.add(new SleighPart(2, 0, 0, loc.clone(), -1, -2));
PresentSlots.add(new SleighPart(2, 0, 0, loc.clone(), 0, -2));
PresentSlots.add(new SleighPart(2, 0, 0, loc.clone(), 1, -2));
PresentSlots.add(new SleighPart(2, 0, 0, loc.clone(), -1, -1));
PresentSlots.add(new SleighPart(2, 0, 0, loc.clone(), 0, -1));
PresentSlots.add(new SleighPart(2, 0, 0, loc.clone(), 1, -1));
PresentSlots.add(new SleighPart(6, 0, 0, loc.clone(), -1, -2));
PresentSlots.add(new SleighPart(6, 0, 0, loc.clone(), 0, -2));
PresentSlots.add(new SleighPart(6, 0, 0, loc.clone(), 1, -2));
PresentSlots.add(new SleighPart(6, 0, 0, loc.clone(), -1, -1));
PresentSlots.add(new SleighPart(6, 0, 0, loc.clone(), 0, -1));
PresentSlots.add(new SleighPart(6, 0, 0, loc.clone(), 1, -1));
//Sleigh
SleighEnts = new ArrayList<SleighPart>();
SleighEnts.add(new SleighPart(5, 0, loc.clone(), 0, -3));
SleighEnts.add(new SleighPart(5, 0, loc.clone(), -1, -3));
SleighEnts.add(new SleighPart(5, 0, loc.clone(), -2, -3));
SleighEnts.add(new SleighPart(5, 0, loc.clone(), 1, -3));
SleighEnts.add(new SleighPart(5, 0, loc.clone(), 2, -3));
for (SleighPart part : PresentSlots)
SleighEnts.add(part);
SleighEnts.add(new SleighPart(5, 0, loc.clone(), -2, -2));
SleighEnts.add(new SleighPart(126, 0, loc.clone(), -1, -2));
SleighEnts.add(new SleighPart(126, 0, loc.clone(), 0, -2));
SleighEnts.add(new SleighPart(126, 0, loc.clone(), 1, -2));
SleighEnts.add(new SleighPart(5, 0, loc.clone(), 2, -2));
SleighEnts.add(new SleighPart(0, 159, 14, loc.clone(), 0, -3));
SleighEnts.add(new SleighPart(0, 159, 14, loc.clone(), -1, -3));
SleighEnts.add(new SleighPart(0, 159, 14, loc.clone(), -2, -3));
SleighEnts.add(new SleighPart(0, 159, 14, loc.clone(), 1, -3));
SleighEnts.add(new SleighPart(0, 159, 14, loc.clone(), 2, -3));
SleighEnts.add(new SleighPart(5, 0, loc.clone(), -2, -1));
SleighEnts.add(new SleighPart(126, 0, loc.clone(), -1, -1));
SleighEnts.add(new SleighPart(126, 0, loc.clone(), 0, -1));
SleighEnts.add(new SleighPart(126, 0, loc.clone(), 1, -1));
SleighEnts.add(new SleighPart(5, 0, loc.clone(), 2, -1));
SleighEnts.add(new SleighPart(0, 159, 14, loc.clone(), -2, -2));
SleighEnts.add(new SleighPart(0, 44, 7, loc.clone(), -1, -2));
SleighEnts.add(new SleighPart(0, 44, 7, loc.clone(), 0, -2));
SleighEnts.add(new SleighPart(0, 44, 7, loc.clone(), 1, -2));
SleighEnts.add(new SleighPart(0, 159, 14, loc.clone(), 2, -2));
SleighEnts.add(new SleighPart(5, 0, loc.clone(), -2, 0));
SleighEnts.add(new SleighPart(5, 0, loc.clone(), -1, 0));
//SleighEnts.add(new SleighEntity(loc.clone(), 0, 0));
SleighEnts.add(new SleighPart(5, 0, loc.clone(), 1, 0));
SleighEnts.add(new SleighPart(5, 0, loc.clone(), 2, 0));
SleighEnts.add(new SleighPart(0, 159, 14, loc.clone(), -2, -1));
SleighEnts.add(new SleighPart(0, 44, 7, loc.clone(), -1, -1));
SleighEnts.add(new SleighPart(0, 44, 7, loc.clone(), 0, -1));
SleighEnts.add(new SleighPart(0, 44, 7, loc.clone(), 1, -1));
SleighEnts.add(new SleighPart(0, 159, 14, loc.clone(), 2, -1));
SleighEnts.add(new SleighPart(5, 0, loc.clone(), -2, 1));
SleighEnts.add(new SleighPart(126, 0, loc.clone(), -1, 1));
SleighEnts.add(new SleighPart(126, 0, loc.clone(), 0, 1));
SleighEnts.add(new SleighPart(126, 0, loc.clone(), 1, 1));
SleighEnts.add(new SleighPart(5, 0, loc.clone(), 2, 1));
SleighEnts.add(new SleighPart(5, 0, loc.clone(), -2, 2));
SleighEnts.add(new SleighPart(126, 0, loc.clone(), -1, 2));
SleighEnts.add(new SleighPart(126, 0, loc.clone(), 0, 2));
SleighEnts.add(new SleighPart(126, 0, loc.clone(), 1, 2));
SleighEnts.add(new SleighPart(5, 0, loc.clone(), 2, 2));
SleighEnts.add(new SleighPart(0, 159, 14, loc.clone(), -2, 0));
SleighEnts.add(new SleighPart(0, 159, 14, loc.clone(), -1, 0));
SleighEnts.add(new SleighPart(0, 159, 14, loc.clone(), 0, 0));
SleighEnts.add(new SleighPart(0, 159, 14, loc.clone(), 1, 0));
SleighEnts.add(new SleighPart(0, 159, 14, loc.clone(), 2, 0));
SleighEnts.add(new SleighPart(126, 0, loc.clone(), -2, 3));
SleighEnts.add(new SleighPart(126, 0, loc.clone(), -1, 3));
SleighEnts.add(new SleighPart(126, 0, loc.clone(), 0, 3));
SleighEnts.add(new SleighPart(126, 0, loc.clone(), 1, 3));
SleighEnts.add(new SleighPart(126, 0, loc.clone(), 2, 3));
SleighEnts.add(new SleighPart(0, 159, 14, loc.clone(), -2, 1));
SleighEnts.add(new SleighPart(0, 44, 7, loc.clone(), -1, 1));
SleighEnts.add(new SleighPart(0, 159, 15, loc.clone(), 0, 1));
SleighEnts.add(new SleighPart(0, 44, 7, loc.clone(), 1, 1));
SleighEnts.add(new SleighPart(0, 159, 14, loc.clone(), 2, 1));
SleighEnts.add(new SleighPart(0, 44, 7, loc.clone(), -2, 2));
SleighEnts.add(new SleighPart(0, 44, 7, loc.clone(), -1, 2));
SleighEnts.add(new SleighPart(0, 44, 7, loc.clone(), 0, 2));
SleighEnts.add(new SleighPart(0, 44, 7, loc.clone(), 1, 2));
SleighEnts.add(new SleighPart(0, 44, 7, loc.clone(), 2, 2));
SleighEnts.add(new SleighPart(0, 159, 14, loc.clone(), -2, 3));
SleighEnts.add(new SleighPart(0, 159, 14, loc.clone(), -1, 3));
SleighEnts.add(new SleighPart(0, 159, 14, loc.clone(), 0, 3));
SleighEnts.add(new SleighPart(0, 159, 14, loc.clone(), 1, 3));
SleighEnts.add(new SleighPart(0, 159, 14, loc.clone(), 2, 3));
//Corners
SleighEnts.add(new SleighPart(4, 44, 7, loc.clone(), -2, -3));
SleighEnts.add(new SleighPart(4, 44, 7, loc.clone(), 2, -3));
SleighEnts.add(new SleighPart(4, 44, 7, loc.clone(), -2, 0));
SleighEnts.add(new SleighPart(4, 44, 7, loc.clone(), 2, 0));
//Santa
SleighPart part = new SleighPart(3, 0, 0, loc.clone(), 0, 1);
part.AddSanta();
SleighEnts.add(part);
SleighHorses = new ArrayList<SleighHorse>();
@ -107,18 +153,22 @@ public class Sleigh
public void Update()
{
Bump();
if (Target == null)
return;
Move(CentralEntity, Target, 1);
//Move Sleigh
for (SleighPart ent : SleighEnts)
for (SleighPart part : SleighEnts)
{
if (ent.Block != null)
((CraftFallingSand)ent.Block).getHandle().c = 1;
part.RefreshBlocks();
Move(ent.Ent, CentralEntity.getLocation().add(ent.OffsetX, 0, ent.OffsetZ), 1);
if (Move(part.Ent, CentralEntity.getLocation().add(part.OffsetX, 0, part.OffsetZ), 1.4))
if (part.OffsetZ == -3 || Math.abs(part.OffsetX) == 2)
if (Math.random() > 0.95)
part.Ent.getWorld().playEffect(part.Ent.getLocation().subtract(0, 1, 0), Effect.STEP_SOUND, 80);
}
//Move Horses
@ -128,12 +178,49 @@ public class Sleigh
}
}
public void Move(Entity ent, Location target, double speed)
public boolean Move(Entity ent, Location target, double speed)
{
if (UtilMath.offset(ent.getLocation(), target) > 0.1)
return UtilEnt.CreatureMoveFast(ent, target, (float)speed);
}
public void Bump()
{
for (Player player : Host.GetPlayers(true))
{
EntityCreature ec = ((CraftCreature)ent).getHandle();
ec.getControllerMove().a(target.getX(), target.getY(), target.getZ(), speed);
if (!Recharge.Instance.usable(player, "Sleigh Bump"))
continue;
for (SleighPart part : SleighEnts)
if (UtilMath.offset(player, part.Ent) < 1)
{
UtilAction.velocity(player, UtilAlg.getTrajectory2d(CentralEntity, player), 0.4, true, 0.2, 0, 0, true);
Recharge.Instance.useForce(player, "Sleigh Bump", 400);
}
for (SleighHorse part : SleighHorses)
if (UtilMath.offset(player, part.Ent) < 1)
{
UtilAction.velocity(player, UtilAlg.getTrajectory2d(CentralEntity, player), 0.4, true, 0.2, 0, 0, true);
Recharge.Instance.useForce(player, "Sleigh Bump", 400);
}
}
}
public boolean HasPresent(Location loc)
{
return PresentsCollected.contains(loc);
}
public void AddPresent(Location loc)
{
PresentsCollected.add(loc);
loc.getBlock().setType(Material.AIR);
UtilFirework.launchFirework(loc.clone().add(0.5, 0.5, 0.5), FireworkEffect.builder().flicker(false).withColor(Color.YELLOW).with(Type.BALL).trail(true).build(), new Vector(0,1,0), 1);
SleighPart part = PresentSlots.remove(0);
if (part == null) return;
part.SetPresent();
}
}

View File

@ -3,20 +3,22 @@ package nautilus.game.arcade.game.games.christmas;
import mineplex.core.common.util.UtilEnt;
import org.bukkit.Location;
import org.bukkit.entity.Chicken;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Horse;
public class SleighHorse
{
public Horse Ent;
public Chicken Ent;
public double OffsetX;
public double OffsetZ;
public SleighHorse(Entity owner, Location loc, double x, double z)
{
Ent = loc.getWorld().spawn(loc.add(x, 0, z), Horse.class);
Ent = loc.getWorld().spawn(loc.add(x, 0, z), Chicken.class);
//Ent.setLeashHolder(owner);
UtilEnt.Vegetate(Ent);
UtilEnt.ghost(Ent, true);
OffsetX = x;
OffsetZ = z;

View File

@ -1,10 +1,19 @@
package nautilus.game.arcade.game.games.christmas;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilMath;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftFallingSand;
import org.bukkit.entity.Chicken;
import org.bukkit.entity.Entity;
import org.bukkit.entity.FallingBlock;
import org.bukkit.entity.Skeleton;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.LeatherArmorMeta;
public class SleighPart
{
@ -13,18 +22,110 @@ public class SleighPart
public double OffsetX;
public double OffsetZ;
public SleighPart(int id, int data, Location loc, double x, double z)
public SleighPart(int rise, int id, int data, Location loc, double x, double z)
{
//Base
Ent = loc.getWorld().spawn(loc.add(x, 0, z), Chicken.class);
Ent.setBaby();
Ent.setAgeLock(true);
Block = loc.getWorld().spawnFallingBlock(loc.add(0, 1, 0), id, (byte)data);
Ent.setPassenger(Block);
UtilEnt.Vegetate(Ent);
UtilEnt.ghost(Ent, true);
//Height
Chicken top = Ent;
for (int i=0 ; i<rise ; i++)
{
Chicken newTop = loc.getWorld().spawn(loc.add(x, 0, z), Chicken.class);
newTop.setBaby();
newTop.setAgeLock(true);
UtilEnt.Vegetate(newTop);
UtilEnt.ghost(newTop, true);
top.setPassenger(newTop);
top = newTop;
}
//Block
if (id != 0)
{
Block = loc.getWorld().spawnFallingBlock(loc.add(0, 1, 0), id, (byte)data);
top.setPassenger(Block);
}
OffsetX = x;
OffsetZ = z;
}
public void RefreshBlocks()
{
if (Ent == null)
return;
Entity ent = Ent;
while (ent.getPassenger() != null)
{
ent = ent.getPassenger();
if (ent instanceof FallingBlock)
((CraftFallingSand)ent).getHandle().c = 1;
}
}
public void SetPresent()
{
if (Ent == null)
return;
Block = Ent.getWorld().spawnFallingBlock(Ent.getLocation().add(0, 1, 0), 35, (byte)UtilMath.r(15));
Entity top = Ent;
while (top.getPassenger() != null)
top = top.getPassenger();
top.setPassenger(Block);
}
public void AddSanta()
{
if (Ent == null)
return;
Skeleton skel = Ent.getWorld().spawn(Ent.getLocation().add(0, 1, 0), Skeleton.class);
UtilEnt.Vegetate(skel);
UtilEnt.ghost(skel, true);
ItemStack head = new ItemStack(Material.LEATHER_HELMET);
LeatherArmorMeta meta = (LeatherArmorMeta)head.getItemMeta();
meta.setColor(Color.RED);
head.setItemMeta(meta);
skel.getEquipment().setHelmet(head);
ItemStack chest = new ItemStack(Material.LEATHER_CHESTPLATE);
meta = (LeatherArmorMeta)chest.getItemMeta();
meta.setColor(Color.RED);
chest.setItemMeta(meta);
skel.getEquipment().setChestplate(chest);
ItemStack legs = new ItemStack(Material.LEATHER_LEGGINGS);
meta = (LeatherArmorMeta)legs.getItemMeta();
meta.setColor(Color.WHITE);
legs.setItemMeta(meta);
skel.getEquipment().setLeggings(legs);
ItemStack boots = new ItemStack(Material.LEATHER_BOOTS);
meta = (LeatherArmorMeta)boots.getItemMeta();
meta.setColor(Color.RED);
boots.setItemMeta(meta);
skel.getEquipment().setBoots(boots);
skel.setCustomName(C.Bold + "Santa Claus");
skel.setCustomNameVisible(true);
Entity top = Ent;
while (top.getPassenger() != null)
top = top.getPassenger();
top.setPassenger(skel);
}
}