Merge branch 'clans-beta' of ssh://184.154.0.242:7999/min/mineplex into clans-beta

This commit is contained in:
libraryaddict 2015-08-29 18:58:43 -07:00
commit 4b7a4a4d5c
2 changed files with 44 additions and 19 deletions

View File

@ -7,8 +7,11 @@ import java.util.Iterator;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.entity.Silverfish;
import org.bukkit.event.EventHandler;
@ -19,6 +22,7 @@ import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Vector;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
@ -41,6 +45,8 @@ public class SnakeCreature extends EventCreature<Silverfish>
private boolean _enabled = true;
private double _speed = 0.75;
private int _ticks = 0;
public SnakeCreature(WorldEvent event, Location spawnLocation)
@ -155,7 +161,7 @@ public class SnakeCreature extends EventCreature<Silverfish>
ArrayList<Packet> packets = new ArrayList<Packet>();
for (int i = _segments.size() - 1; i >= 0; i--)
for (int i = 0 ; i < _segments.size() ; i++)
{
SnakeSegment seg = _segments.get(i);
@ -163,22 +169,13 @@ public class SnakeCreature extends EventCreature<Silverfish>
if (i == 0)
{
Vector moveTo = UtilAlg.getTrajectory(vec, _waypoint.toVector());
Vector direction = UtilAlg.getTrajectory(vec, _waypoint.toVector());
// Vector target = vec.clone().add(moveTo.multiply(3));
//
// //MATHS
// double speed = 10d;
// double right = -Math.sin(_ticks/speed) * 4;
// double up = Math.cos(_ticks/speed) * 4;
//
// target.add(UtilAlg.getRight(vec).multiply(right));
// target.add(UtilAlg.getUp(vec).multiply(up));
_velocity.add(direction.multiply(0.1 * _speed));
_velocity.add(moveTo.normalize().multiply(0.04));
if (_velocity.length() > 0.5)
_velocity.normalize().multiply(0.5);
if (_velocity.length() > _speed)
_velocity.normalize().multiply(_speed);
// Bukkit.broadcastMessage("Loc: " + UtilWorld.vecToStrClean(moveTo));
@ -186,14 +183,23 @@ public class SnakeCreature extends EventCreature<Silverfish>
// Bukkit.broadcastMessage("Loc: " + UtilWorld.vecToStrClean(vec));
if (UtilMath.offset(vec, _waypoint.toVector()) < 5)
if (UtilMath.offset(vec, _waypoint.toVector()) < 6)
{
getNewWaypoint();
}
}
else
{
vec = _segments.get(i - 1).getLocation();
Vector infront = _segments.get(i - 1).getLocation();
Vector behind = _segments.get(i - 1).getLastLocation();
vec = infront.clone().add(UtilAlg.getTrajectory(infront, behind).multiply(_seperator));
}
Block block = _waypoint.getWorld().getBlockAt(seg.getLocation().getBlockX(),seg.getLocation().getBlockY(),seg.getLocation().getBlockZ()).getRelative(BlockFace.UP);
if (block.getType() != Material.AIR && UtilBlock.isVisible(block))
{
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getType());
}
packets.addAll(Arrays.asList(seg.moveEntity(vec)));
@ -210,8 +216,19 @@ public class SnakeCreature extends EventCreature<Silverfish>
@EventHandler
public void command(PlayerCommandPreprocessEvent event)
{
if (event.getMessage().contains("start"))
_enabled = true;
if (event.getMessage().contains("speed"))
{
try
{
_speed = Double.parseDouble(event.getMessage().split(" ")[1]);
Bukkit.broadcastMessage("SPEED " + _speed);
}
catch (Exception e)
{
}
}
}
}

View File

@ -19,6 +19,7 @@ public class SnakeSegment
{
private int _entityId = UtilEnt.getNewEntityId();
private Vector _entityLocation;
private Vector _entityLastLocation;
private ItemStack _item;
private Vector _prevDir = new Vector();
@ -35,6 +36,8 @@ public class SnakeSegment
public Packet[] moveEntity(Vector newLocation)
{
_entityLastLocation = _entityLocation.clone();
Vector toMove = newLocation.clone().subtract(_entityLocation);
Packet packet1;
@ -115,6 +118,11 @@ public class SnakeSegment
{
return _entityLocation.clone();
}
public Vector getLastLocation()
{
return _entityLastLocation.clone();
}
public Packet[] getSpawn()
{