Implement basic sledge mount
This commit is contained in:
parent
1d1fdf718c
commit
3b1ce13856
@ -194,6 +194,7 @@ import mineplex.core.gadget.gadgets.mount.types.MountLoveTrain;
|
||||
import mineplex.core.gadget.gadgets.mount.types.MountMule;
|
||||
import mineplex.core.gadget.gadgets.mount.types.MountNightmareSteed;
|
||||
import mineplex.core.gadget.gadgets.mount.types.MountPumpkin;
|
||||
import mineplex.core.gadget.gadgets.mount.types.MountSledge;
|
||||
import mineplex.core.gadget.gadgets.mount.types.MountSlime;
|
||||
import mineplex.core.gadget.gadgets.mount.types.MountSpider;
|
||||
import mineplex.core.gadget.gadgets.mount.types.MountStPatricksHorse;
|
||||
@ -612,6 +613,7 @@ public class GadgetManager extends MiniPlugin
|
||||
addGadget(new MountLoveTrain(this));
|
||||
addGadget(new MountStPatricksHorse(this));
|
||||
addGadget(new MountPumpkin(this));
|
||||
addGadget(new MountSledge(this));
|
||||
|
||||
// Particles
|
||||
addGadget(new ParticleFoot(this));
|
||||
|
@ -0,0 +1,98 @@
|
||||
package mineplex.core.gadget.gadgets.mount.types;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.LineFormat;
|
||||
import mineplex.core.common.util.UtilText;
|
||||
import mineplex.core.gadget.GadgetManager;
|
||||
import mineplex.core.gadget.gadgets.mount.Mount;
|
||||
import mineplex.core.gadget.gadgets.mount.MountData;
|
||||
import mineplex.core.gadget.gadgets.mount.types.MountSledge.MountSledgeData;
|
||||
import mineplex.core.gadget.util.CostConstants;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
|
||||
public class MountSledge extends Mount<MountSledgeData>
|
||||
{
|
||||
|
||||
private static final ItemStack FRONT = new ItemStack(Material.SPRUCE_WOOD_STAIRS);
|
||||
private static final ItemStack BACK = new ItemStack(Material.WOOD_STEP, 1, (short) 0, (byte) 1);
|
||||
|
||||
public MountSledge(GadgetManager manager)
|
||||
{
|
||||
super(manager, "Sledge Mount",
|
||||
UtilText.splitLineToArray(C.cGray + "TODO", LineFormat.LORE),
|
||||
CostConstants.FOUND_IN_GINGERBREAD_CHESTS, Material.SPRUCE_WOOD_STAIRS, (byte) 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MountSledgeData spawnMount(Player player)
|
||||
{
|
||||
Location location = player.getLocation().subtract(0, 1.5, 0);
|
||||
ArmorStand front = player.getWorld().spawn(location, ArmorStand.class);
|
||||
ArmorStand back = player.getWorld().spawn(location, ArmorStand.class);
|
||||
|
||||
front.setVisible(false);
|
||||
back.setVisible(false);
|
||||
|
||||
front.getEquipment().setHelmet(FRONT);
|
||||
back.getEquipment().setHelmet(BACK);
|
||||
|
||||
back.setPassenger(player);
|
||||
|
||||
return new MountSledgeData(player, front, back);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void updateMovement(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.TICK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (MountSledgeData data : _active.values())
|
||||
{
|
||||
ArmorStand front = data.Front;
|
||||
ArmorStand back = data.Back;
|
||||
Location playerLocation = data.getOwner().getLocation();
|
||||
playerLocation.setPitch(0);
|
||||
Vector direction = playerLocation.getDirection().multiply(0.1);
|
||||
|
||||
front.teleport(front.getLocation().add(direction));
|
||||
back.teleport(back.getLocation().add(direction));
|
||||
}
|
||||
}
|
||||
|
||||
class MountSledgeData extends MountData
|
||||
{
|
||||
|
||||
final ArmorStand Front;
|
||||
final ArmorStand Back;
|
||||
|
||||
MountSledgeData(Player player, ArmorStand front, ArmorStand back)
|
||||
{
|
||||
super(player);
|
||||
|
||||
Front = front;
|
||||
Back = back;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Entity> getEntityParts()
|
||||
{
|
||||
return Arrays.asList(Front, Back);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user