use of blusunrize.immersiveengineering.common.entities.EntitySkylineHook in project ImmersiveEngineering by BluSunrize.
the class SkylineHelper method spawnHook.
public static EntitySkylineHook spawnHook(EntityPlayer player, TileEntity start, Connection connection) {
BlockPos cc0 = connection.end == Utils.toCC(start) ? connection.start : connection.end;
BlockPos cc1 = connection.end == Utils.toCC(start) ? connection.end : connection.start;
IImmersiveConnectable iicStart = ApiUtils.toIIC(cc1, player.worldObj);
IImmersiveConnectable iicEnd = ApiUtils.toIIC(cc0, player.worldObj);
Vec3d vStart = new Vec3d(cc1);
Vec3d vEnd = new Vec3d(cc0);
if (iicStart != null)
vStart = Utils.addVectors(vStart, iicStart.getConnectionOffset(connection));
if (iicEnd != null)
vEnd = Utils.addVectors(vEnd, iicEnd.getConnectionOffset(connection));
Vec3d[] steps = getConnectionCatenary(connection, vStart, vEnd);
double dx = (steps[0].xCoord - vStart.xCoord);
double dy = (steps[0].yCoord - vStart.yCoord);
double dz = (steps[0].zCoord - vStart.zCoord);
//connection.length;
double d = 1;
// Math.sqrt(dx*dx+dz*dz+dy*dy);
// Vec3 moveVec = Vec3.createVectorHelper(dx,dy,dz);
// Vec3 moveVec = Vec3.createVectorHelper(dx/d,dy/d,dz/d);
EntitySkylineHook hook = new EntitySkylineHook(player.worldObj, vStart.xCoord, vStart.yCoord, vStart.zCoord, connection, cc0, steps);
float speed = 1;
if (player.getActiveItemStack() != null && player.getActiveItemStack().getItem() instanceof ItemSkyhook)
speed = ((ItemSkyhook) player.getActiveItemStack().getItem()).getSkylineSpeed(player.getActiveItemStack());
Vec3d moveVec = getSubMovementVector(vStart, steps[0], speed);
//*speed;
hook.motionX = moveVec.xCoord;
//*speed;
hook.motionY = moveVec.yCoord;
//*speed;
hook.motionZ = moveVec.zCoord;
if (!player.worldObj.isRemote)
player.worldObj.spawnEntityInWorld(hook);
ItemSkyhook.existingHooks.put(player.getName(), hook);
player.startRiding(hook);
return hook;
}
use of blusunrize.immersiveengineering.common.entities.EntitySkylineHook in project ImmersiveEngineering by BluSunrize.
the class ItemSkyhook method onPlayerStoppedUsing.
@Override
public void onPlayerStoppedUsing(ItemStack stack, World world, EntityLivingBase player, int ticks) {
if (existingHooks.containsKey(player.getName())) {
EntitySkylineHook hook = existingHooks.get(player.getName());
// player.motionX = hook.motionX;
// player.motionY = hook.motionY;
// player.motionZ = hook.motionZ;
// IELogger.debug("player motion: "+player.motionX+","+player.motionY+","+player.motionZ);
hook.setDead();
existingHooks.remove(player.getName());
}
}
Aggregations