Merge branch 'clans-beta' of http://184.154.0.242:7990/scm/min/mineplex into clans_custom_gear

This commit is contained in:
Ty Sayers 2015-08-29 19:06:20 -07:00
commit 7047bbf8f6
4 changed files with 57 additions and 32 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)
@ -61,7 +67,7 @@ public class SnakeCreature extends EventCreature<Silverfish>
for (int i = 0; i < getHealth() / 50; i++)
{
SnakeSegment tail = new SnakeSegment(getSpawnLocation().toVector().subtract(dir.clone().multiply(-i)),
new ItemStack(i == 0 ? Material.EMERALD_BLOCK : Material.STONE));
new ItemStack(i == 0 ? Material.CHEST : Material.DROPPER));
_segments.add(tail);
}
@ -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(moveTo.normalize().multiply(0.04));
_velocity.add(direction.multiply(0.1 * _speed));
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;
@ -52,8 +55,8 @@ public class SnakeSegment
relMove.b = (byte) x;
relMove.c = (byte) y;
relMove.d = (byte) z;
//relMove.e = (byte) (int) (UtilAlg.GetYaw(toMove) * 256.0F / 360.0F);
//relMove.f = (byte) (int) (UtilAlg.GetPitch(toMove) * 256.0F / 360.0F);
// relMove.e = (byte) (int) (UtilAlg.GetYaw(toMove) * 256.0F / 360.0F);
// relMove.f = (byte) (int) (UtilAlg.GetPitch(toMove) * 256.0F / 360.0F);
packet1 = relMove;
}
@ -70,15 +73,15 @@ public class SnakeSegment
teleportPacket.b = x;
teleportPacket.c = y;
teleportPacket.d = z;
//teleportPacket.e = (byte) (int) (UtilAlg.GetYaw(toMove) * 256.0F / 360.0F);
//teleportPacket.f = (byte) (int) (UtilAlg.GetPitch(toMove) * 256.0F / 360.0F);
// teleportPacket.e = (byte) (int) (UtilAlg.GetYaw(toMove) * 256.0F / 360.0F);
// teleportPacket.f = (byte) (int) (UtilAlg.GetPitch(toMove) * 256.0F / 360.0F);
packet1 = teleportPacket;
}
toMove.normalize();
Vector vec = new Vector(UtilAlg.GetPitch(toMove), UtilAlg.GetYaw(toMove), 0);
if (toMove.equals(_prevDir))
if (vec.equals(_prevDir))
{
return new Packet[]
{
@ -86,14 +89,14 @@ public class SnakeSegment
};
}
_prevDir = toMove;
_prevDir = vec;
DataWatcher watcher = new DataWatcher(null);
watcher.a(0, (byte) 32);
watcher.a(0, (byte) 0);
watcher.a(1, 0);
watcher.a(10, (byte) 0);
watcher.a(11, toMove);
watcher.a(11, vec);
for (int i = 12; i < 17; i++)
{
@ -116,12 +119,17 @@ public class SnakeSegment
return _entityLocation.clone();
}
public Vector getLastLocation()
{
return _entityLastLocation.clone();
}
public Packet[] getSpawn()
{
PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving();
DataWatcher watcher = new DataWatcher(null);
watcher.a(0, (byte) 32);
watcher.a(0, (byte) 0);
watcher.a(1, 0);
packet.a = getId();

View File

@ -17,7 +17,7 @@ public class SpiderBoss extends WorldEvent
public SpiderBoss(DamageManager damageManager, BlockRestore blockRestore, ConditionManager conditionManager,
Location cornerLocation)
{
super(damageManager, blockRestore, conditionManager, "Brood Mother", cornerLocation);
super(damageManager, blockRestore, conditionManager, "Brood Mother", cornerLocation, "schematic/Golem.schematic");
}
@Override

View File

@ -137,7 +137,7 @@ public class SpiderCreature extends EventCreature<Spider>
{
try
{
ability = (BossAbility) entry.getKey().getConstructor(GolemCreature.class).newInstance(this);
ability = (BossAbility) entry.getKey().getConstructor(SpiderCreature.class).newInstance(this);
if (ability.getTarget() == null)
{