else onUpdateServer(itemstack, world, pEnt, i, flag);
if(pEnt instanceof EntityPlayer)
{
EntityPlayer player = (EntityPlayer)pEnt;
PlayerData data = PlayerHandler.getPlayerData(player);
if(data == null)
return;
//if(data.lastMeleePositions == null || data.lastMeleePositions.length != type.meleeDamagePoints.size())
//{
// data.lastMeleePositions = new Vector3f[type.meleeDamagePoints.size()];
// for(int j = 0; j < type.meleeDamagePoints.size(); j++)
// data.lastMeleePositions[j] = new Vector3f(player.posX, player.posY, player.posZ);
//}
//Melee weapon
if(data.meleeLength > 0 && type.meleePath.size() > 0 && player.inventory.getCurrentItem() == itemstack)
{
for(int k = 0; k < type.meleeDamagePoints.size(); k++)
{
Vector3f meleeDamagePoint = type.meleeDamagePoints.get(k);
//Do a raytrace from the prev pos to the current pos and attack anything in the way
Vector3f nextPos = type.meleePath.get((data.meleeProgress + 1) % type.meleePath.size());
Vector3f nextAngles = type.meleePathAngles.get((data.meleeProgress + 1) % type.meleePathAngles.size());
RotatedAxes nextAxes = new RotatedAxes().rotateGlobalRoll(-nextAngles.x).rotateGlobalPitch(-nextAngles.z).rotateGlobalYaw(-nextAngles.y);
Vector3f nextPosInGunCoords = nextAxes.findLocalVectorGlobally(meleeDamagePoint);
Vector3f.add(nextPos, nextPosInGunCoords, nextPosInGunCoords);
Vector3f.add(new Vector3f(0F, 0F, 0F), nextPosInGunCoords, nextPosInGunCoords);
Vector3f nextPosInPlayerCoords = new RotatedAxes(player.rotationYaw + 90F, player.rotationPitch, 0F).findLocalVectorGlobally(nextPosInGunCoords);
if(!FlansMod.proxy.isThePlayer(player))
nextPosInPlayerCoords.y += 1.6F;
Vector3f nextPosInWorldCoords = new Vector3f(player.posX + nextPosInPlayerCoords.x, player.posY + nextPosInPlayerCoords.y, player.posZ + nextPosInPlayerCoords.z);
Vector3f dPos = data.lastMeleePositions[k] == null ? new Vector3f() : Vector3f.sub(nextPosInWorldCoords, data.lastMeleePositions[k], null);
if(player.worldObj.isRemote && FlansMod.DEBUG)
player.worldObj.spawnEntityInWorld(new EntityDebugVector(player.worldObj, data.lastMeleePositions[k], dPos, 200, 1F, 0F, 0F));
//Do the raytrace
{
//Create a list for all bullet hits
ArrayList<BulletHit> hits = new ArrayList<BulletHit>();
//Iterate over all entities
for(int j = 0; j < world.loadedEntityList.size(); j++)
{
Object obj = world.loadedEntityList.get(j);
//Get players
if(obj instanceof EntityPlayer)
{
EntityPlayer otherPlayer = (EntityPlayer)obj;
PlayerData otherData = PlayerHandler.getPlayerData(otherPlayer);
boolean shouldDoNormalHitDetect = false;
if(otherPlayer == player)
continue;
if(otherData != null)
{